3.2.2.4 Lab - Navigating The Linux Filesystem and Permission Settings
3.2.2.4 Lab - Navigating The Linux Filesystem and Permission Settings
Objectives
In this lab, you will use familiarize yourself with Linux filesystems.
Required Resources
CyberOps Workstation VM
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 1 of 9 www.netacad.com
Lab - Navigating the Linux Filesystem and Permission Settings
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 2 of 9 www.netacad.com
Lab - Navigating the Linux Filesystem and Permission Settings
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 3 of 9 www.netacad.com
Lab - Navigating the Linux Filesystem and Permission Settings
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 4 of 9 www.netacad.com
Lab - Navigating the Linux Filesystem and Permission Settings
d. The chmod command is used to change the permissions of a file or directory. As before, mount the
/dev/sdb1 partition on the /home/analyst/second_drive directory created earlier in this lab:
[analyst@secOps ~]$ sudo mount /dev/sdb1 ~/second_drive/
e. Change to the second_drive directory and list the contents of it:
[analyst@secOps ~]$ cd ~/second_drive
[analyst@secOps second_drive]$ ls -l
total 20
drwx------ 2 root root 16384 Mar 3 10:59 lost+found
-rw-r--r-- 1 root root 183 Mar 3 15:42 myFile.txt
What are the permissions of the myFile.txt file?
____________________________________________________________________________________
f. Use the chmod command to change the permissions of myFile.txt.
[analyst@secOps second_drive]$ sudo chmod 665 myFile.txt
[analyst@secOps second_drive]$ ls -l
total 20
drwx------ 2 root root 16384 Mar 3 10:59 lost+found
-rw-rw-r-x 1 root root 183 Mar 3 15:42 myFile.txt
Did the permissions change? What are the permissions of myFile.txt?
____________________________________________________________________________________
The chmod command takes permissions in the octal format. In that way, a breakdown of the 665 is as
follows:
6 in octal is 110 in binary. Assuming each position of the permissions of a file can be 1 or 0, 110 means
rw- (read=1, write=1 and execute=0).
Therefore, the chmod 665 myFile.txt command changes the permissions to:
Owner: rw- (6 or 110 in octal)
Group: rw- (6 or 110 in octal)
Other: r-x (5 or 101 in octal)
What command would change the permissions of myFile.txt to rwxrwxrwx, granting any user in the
system full access to the file?
____________________________________________________________________________________
g. The chown command is used to change ownership of a file or directory. Issue the command below to
make the analyst user the owner of the myFile.txt:
[analyst@secOps second_drive]$ sudo chown analyst myFile.txt
[sudo] password for analyst:
[analyst@secOps second_drive]$ ls -l
total 20
drwx------ 2 root root 16384 Mar 3 10:59 lost+found
-rw-rw-r-x 1 analyst root 183 Mar 3 15:42 myFile.txt
[analyst@secOps second_drive]$
Note: To change the owner and group to analyst at the same time, use the sudo chown analyst:analyst
myFile.txt format.
h. Now that analyst is the file owner, try appending the word ‘test’ to the end of myFile.txt.
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 5 of 9 www.netacad.com
Lab - Navigating the Linux Filesystem and Permission Settings
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 6 of 9 www.netacad.com
Lab - Navigating the Linux Filesystem and Permission Settings
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 7 of 9 www.netacad.com
Lab - Navigating the Linux Filesystem and Permission Settings
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 8 of 9 www.netacad.com
Lab - Navigating the Linux Filesystem and Permission Settings
Reflection
File permissions and ownership are two of the most important aspects of Linux. They are also a common
cause of problems. A file that has the wrong permissions or ownership set will not be available to the
programs that need to access it. In this scenario, the program will usually break and errors will be
encountered.
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 9 of 9 www.netacad.com