In: Computer Science
CompTIA Linux+ Guide to Linux Certification (4th Edition)(Please do not do it in a mac and add pictures of the machine.)
Project 4-7 In this hands-on project, you apply and modify access permissions on files and directories and test their effects.
1. Switch to a command-line terminal (tty2) by pressing Ctrl+Alt+F2 and log in to the terminal using the user name of root and the password of LNXrocks!.
2. At the command prompt, type touch permsample and press Enter. Next, type chmod 777 permsample at the command prompt and press Enter.
3. At the command prompt, type ls -l and press Enter. Who has permissions to this file?
4. At the command prompt, type chmod 000 permsample and press Enter. Next, type ls –l at the command prompt and press Enter. Who has permissions to this file?
5. At the command prompt, type rm –f permsample and press Enter. Were you able to delete this file? Why?
6. At the command prompt, type cd / and press Enter. Next, type pwd at the command prompt and press Enter. What directory are you in? Type ls –F at the command prompt and press Enter. What directories do you see?
7. At the command prompt, type ls –l and press Enter to view the owner, group owner, and permissions on the foruser1 directory created in Hands-on Project 5-1. Who is the owner and group owner? If you were logged in as the user user1, in which category would you be placed (user, group, other)? What permissions do you have as this category (read, write, execute)?
8. At the command prompt, type cd /foruser1 and press Enter to enter the foruser1 directory. Next, type ls -F at the command prompt and press Enter. Are there any files in this directory? Type cp /etc/hosts . at the command prompt and press Enter. Next, type ls -F at the command prompt and press Enter to ensure that a copy of the hosts file was made in your current directory.
9. Switch to a different command-line terminal (tty3) by pressing Ctrl+Alt+F3 and log in to the terminal using the user name of user1 and the password of LNXrocks!.
10. At the command prompt, type cd /foruser1 and press Enter. Were you successful? Why? Next, type ls -F at the command prompt and press Enter. Were you able to see the contents of the directory? Why? Next, type rm –f hosts at the command prompt and press Enter. What error message did you see? Why?
11. Switch back to your previous command-line terminal (tty2) by pressing Ctrl+Alt+F2. Note that you are logged in as the root user on this terminal.
12. At the command prompt, type chmod o+w /foruser1 and press Enter. Were you able to change the permissions on the /foruser1 directory successfully? Why?
13. Switch back to your previous command-line terminal (tty3) by pressing Ctrl+Alt+F3. Note that you are logged in as the user1 user on this terminal.
14. At the command prompt, type cd /foruser1 and press Enter. Next, type rm –f hosts at the command prompt and press Enter. Were you successful now? Why?
15. Switch back to your previous command-line terminal (tty2) by pressing Ctrl+Alt+F2. Note that you are logged in as the root user on this terminal.
16. At the command prompt, type cd /foruser1 and press Enter to enter the foruser1 directory. Type cp /etc/hosts . at the command prompt and press Enter to place another copy of the hosts file in your current directory.
17. At the command prompt, type ls –l and press Enter. Who is the owner and group owner of this file? If you were logged in as the user user1, in which category would you be placed (user, group, other)? What permissions do you have as this category (read, write, execute)?
18. Switch back to your previous command-line terminal (tty3) by pressing Ctrl+Alt+F3. Note that you are logged in as the user1 user on this terminal.
19. At the command prompt, type cd /foruser1 and press Enter to enter the foruser1 directory. Type cat hosts at the command prompt and press Enter. Were you successful? Why? Next, type vi hosts at the command prompt to open the hosts file in the vi editor. Delete the first line of this file and save your changes. Were you successful? Why? Exit the vi editor and discard your changes.
20. Switch back to your previous command-line terminal (tty2) by pressing Ctrl+Alt+F2. Note that you are logged in as the root user on this terminal.
21. At the command prompt, type chmod o+w /foruser1/hosts and press Enter.
22. Switch back to your previous command-line terminal (tty3) by pressing Ctrl+Alt+F3. Note that you are logged in as the user1 user on this terminal.
23. At the command prompt, type cd /foruser1 and press Enter to enter the foruser1 directory. Type vi hosts at the command prompt to open the hosts file in the vi editor. Delete the first line of this file and save your changes. Why were you successful this time? Exit the vi editor.
24. At the command prompt, type ls -l and press Enter. Do you have permission to execute the hosts file? Should you make this file executable? Why? Next, type ls –l /bin at the command prompt and press Enter, Note how many of these files to which you have execute permission. Type file /bin/* at the command prompt and press Enter to view the file types of the files in the /bin directory. Should these files have the execute permission?
25. Type exit and press Enter to log out of your shell.
26. Switch back to your previous command-line terminal (tty2) by pressing Ctrl+Alt+F2. Note that you are logged in as the root user on this terminal.
27. Type exit and press Enter to log out of your shell.
4)
chmod is used to change the permission of a file/directory.chmod
000 is a chmod octal notation.
here 000 means no permissions to anybody ,that means no body can
access the file permsample.
5)
rm command is used to remove files/directories from the file
system.actually rm is used to removes references to object from the
file system.
-f option in rm command is used to forcefully removal of the
file/directory.so rm -f permsample command will delete the file
succesfully.
6)
cd command is used to change the directory .here we first enter $cd
/ .so cd / command is used to change directory to the root
directory.it is the first directory in the file system
hierarchy.
pwd command is used to print the present working directory.since we
changed to root directory using cd / command .pwd command prints
that we are in / directory (ie., root directory).
ls command is used to listing all the files/directories of present
file .-F option with ls ,ie.,$ls -F is used to classifies the file
with different special character for diffefrent kind of
files.
ex:
/ represents directory
@ represnts link file
* represents executable file
if no special character is there then it is normal file.
7)
when we use $ls -l command all the list of the files with full
descriptions are displayed.
there are sevend fields for shown for each directory/file
field1 is about File Permissions,field2 is number of links,field3
is about owner,field4 is about group,field5 is size,field6 is about
the last modified date and time,field7 is the file name.
if user1 is added to a group then we will come under group ,if
user1 is not assigned to any group then he will come under
other.