4.5.4 Lab Navigating The Linux Filesystem and Permission Settings 1878829
4.5.4 Lab Navigating The Linux Filesystem and Permission Settings 1878829
454-LAB-NAVIGATING-THE-LINUX-FILESYSTEM-AND-
PERMISSION-SETTINGS-1878829
MAYO DE 2024
Lab - Navigating the Linux Filesystem and Permission Settings
Nombre del curso: Seguridad Informática y Nombre del profesor: Miguel Ángel Gómez
Criptografía
Modulo Netacad: 4.5.4 Marroquín
Actividad:
Lab - Navigating the Linux Filesystem and
Fecha: 26/08/2022 Permission Settings
Bibliografia (Formato APA)
Objectives
In this lab, you will use familiarize yourself with Linux filesystems.
Required Resources
• CyberOps Workstation VM
Instructions Part 1: Exploring Filesystems in Linux
The Linux filesystem is one of its most popular features. While Linux supports many
different types of filesystems, this lab focuses on the ext family, one the most
common filesystems found on Linux.
The output above shows that the CyberOps Workstation VM has three block devices
installed: sr0, sda and sdb. The tree-like output also shows partitions under sda and
sdb. Conventionally, /dev/sdX is used by Linux to represent hard drives, with the trailing
number representing the partition number inside that device. Computers with multiple
hard drives would likely display more /dev/sdX devices. If Linux was running on a
computer with four hard drives for example, it would show them as /dev/sda, /dev/sdb,
/dev/sdc and /dev/sdd, by default. The output implies that sda and sdb are hard
drives, each one containing a single partition. The output also shows that sda is
a 10GB disk while sdb has 1GB.
Note: Linux often displays USB flash drives as /dev/sdX as well, depending on their
firmware type.
b. Use the mount command to display more detailed information on the currently mounted
filesystems in the
Many of the filesystems above are out of scope of this course and irrelevant to the lab.
Let9s focus on the root filesystem, the filesystem stored in /dev/sda1. The root filesystem
is where the Linux operating system itself is stored; all the programs, tools, configuration
files are stored in root filesystem by default.
c. Run the mount command again, but this time, use the pipe | to send the output of mount
to grep to filter the output and display only the root filesystem:
[analyst@secOps ~]$ mount | grep sda1
In the filtered output above, mount shows us that the root filesystem is located in the first
partition of the sda block device (/dev/sda1). We know this is the root filesystem
because of the mounting point used: </= (the slash symbol). The output also tells us the
type of formatting used in the partition, ext4 in this case. The information in between
parentheses relates to the partition mounting options.
d. Issue the following two commands below on the CyberOps Workstation VM:
[analyst@secOp
s ~]$ cd /
[analyst@secOp
s /]$ ls -l
What is the meaning of the output? Where are the listed files physically stored?
Why is /dev/sdb1 not shown in the output above? Porque /dev/sdb1 no está montado
actualmente
Lab - Navigating the Linux Filesystem and Permission Settings
a. Use the ls -l command to verify that the directory second_drive is in the analyst's home
directory.
[analyst@secOp
s /]$ cd ~
[analyst@secO
ps ~]$ ls –l
total 28
Note: If the directory second_drive does not exist, use the mkdir second_drive
command to create it.
Note: Depending on the state of your VM, your listing will most likely have different files
and directories. b. Use ls -l again to list the contents of the newly created second_drive
directory.
c. Use the mount command to mount /dev/sdb1 on the newly created second_drive
directory. The syntax of mount is: mount [options] <device to be mounted>
<mounting point>.
Why is the directory no longer empty? Where are the listed files physically stored?
Por qué después del montaje ya que los archivos de entrada se convierten en los
archivos de punto de entrada para el almacenamiento.
e. Issue the mount command with no options again to display detailed information about the
/dev/sdb1
partition. As before, use the grep command to display only the /dev/sdX filesystems:
f. Unmounting filesystems is just as simple. Make sure you change the directory to
something outside of the mounting point and use the umount command, as shown
below:
60
Consider the cyops.mn file as an example. Who is the owner of the file? How
about the group? Propietario: analista; Grupo: analista
The permissions for cyops.mn are –rw-r--r--. What does that mean?
Que el propietario del archivo puede leer y escribir en el archivo pero no ejecutarlo.
c. The touch command is very simple and useful. It allows for the quick creation of an empty
text file. Use the command below to create an empty file in the /mnt directory:
Lab - Navigating the Linux Filesystem and
Permission Settings
Why was the file not created? List the permissions, ownership and content of the /mnt
directory and explain what happened. With the addition of -d option, it lists the
permission of the parent directory. Record the answer in the lines below.
d. The chmod command is used to change the permissions of a file or directory. As before,
mount the
183 Mar 3
15:42
myFile.txt
-
r
w
-
r
w
-
r
x
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:
g. The chown command is used to change ownership of a file or directory. Issue the
command below to make root the owner of the myFile.txt:
lost+found
Note: To change both the owner and the 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 8test9 to the end of myFile.txt.
[analyst@secOps second_drive]$ echo test >> myFile.txt
Sí por el analista es el propietario del archivo ya que los permisos aún están
configurados en 665 como antes.
[analyst@secOps second_drive]$ cd
~/lab.support.files/ [analyst@secOps
lab.support.files]$ ls -l total
580
Compare the permissions of the malware directory with the mininet_services file. What
is the difference between beginning part of the malware line and the mininet_services
line?
Hay una letra d al principio antes de los permisos para el directorio de malware.
The letter 8d9 at the beginning of the line indicates that the file type is a directory and not a
file. Another difference between file and directory permissions is the execution bit. If a file
has its execution bit turned on, it means it can be executed by the system. Directories are
different than files with the execution bit set (a file with the execution bit set is an
executable script or program). A directory with the execution bit set specifies whether a
user can enter that directory.
The chmod and chown commands work for directories in the same way they work for
files.
• Regular
files (-)
including: o
Readable
files – text
files o
Binary files -
programs o
Image files o
Compresse
d files
Folders
o Block files (b) – Files used to access physical hardware like mount points to access
hard drives.
o Character device files (c) – Files that provide a serial stream of input and output.
tty terminals are examples of this type of file.
o Pipe files (p) – A file used to pass information where the first bytes in are the first
bytes out. This is also known as FIFO (first in first out).
o Symbolic Link files (l) – Files used to link to other files or directories. There are
two types: symbolic links and hard links.
o Socket files (s) – These are used to pass information from application to
application in order to communicate over a network.
28
b. Produce a listing of the /dev directory. Scroll to the middle of the output and notice how the
block files
begin with a <b=, the character device files begin with a <c= and the symbolic link files begin
with an <l=:
[analyst@secOps ~]$ ls -l /dev/
<output omitted> crw-rw-rw- 1 root tty 5, 2 May 29
18:32 ptmx drwxr-xr-x 2 root root 0 May 23 06:40
pts crw-rw-rw- 1 root root 1, 8 May 23 06:41 random
crw-rw-r-- 1 root root 10, 56 May 23 06:41 rfkill
lrwxrwxrwx 1 root root 4 May 23 06:41 rtc -
root 40 May 28 13:47 shm crw------- 1 root root 10, 231 May
23 06:41 tty0
<output omitted>
c. Symbolic links in Linux are like shortcuts in Windows. There are two types of links in
Linux: symbolic links and hard links. The difference between symbolic links and a hard
links is that a symbolic link file points to the filename of another file and a hard link file
points to the contents of another file. Create two files by using echo:
d. Use ln –s to create a symbolic link to file1.txt, and ln to create a hard link to file2.txt:
Notice how the file file1symbolic is a symbolic link with an l at the beginning of the line
and a pointer -> to file1.txt. The file2hard appears to be a regular file, because in fact it
is a regular file that happens to point to the same inode on the hard disk drive as
file2.txt. In other words, file2hard points to the same attributes and disk block location
as file2.txt. The number 2 in the fifth column of the listing for file2hard and file2.txt
indicates that there are 2 files hard linked to the same inode. For a directory listing the
fifth column indicates the number of directories within the directory including hidden
folders.
f. Change the names of the original files: file1.txt and file2.txt, and notice how it effects the linked
files.
Notice how file1symbolic is now a broken symbolic link because the name of the file
that it pointed to file1.txt has changed, but the hard link file file2hard still works correctly
because it points to the inode of file2.txt and not its name, which is now file2new.txt.
What do you think would happen to file2hard if you opened a text editor and changed the
text in
file2new.txt?
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.
Conclusion
Gracias a esta practica supe que el sistema de archivos de Linux
es una de sus características más importantes . ya que esta
practica se enfoca en la familia ext y que tambien Linux a menudo
también muestra las unidades flash USB como /dev/sdX,
dependiendo de su tipo de firmware.