pwd /home/kali kali@kali:~$
ls / bin home lib32 media root sys vmlinuz
boot initrd.img lib64 mnt run tmp vmlinuz.old
dev initrd.img.old libx32 opt sbin usr
etc lib lost+found proc srv var
kali@kali:~$
cat /etc/passwd root:x:0:0:root:/root:/usr/bin/zsh
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
...
king-phisher:x:133:141::/var/lib/king-phisher:/usr/sbin/nologin
kali:x:1000:1000:Kali,,,:/home/kali:/usr/bin/zsh
Listing 128 - Display content of /etc/passwd with an absolute path Next, let’s use relative pathing to achieve the same goal. We’ll display the contents of
/etc/passwd
using relative paths from the home directory of the
kali user. To move back one
directory, we can use ../. To move more than one directory backwards, we can combine multiple
../
sequences.
We can use the ls command combined with one ../ sequence to list the contents of the /home
directory, since ../ specifies one directory back. We’ll then use two ../ sequences to list the
contents of the root file system, which contains the etc directory.
kali@kali:~$
pwd /home/kali kali@kali:~$
ls ../ kali
kali@kali:~$
ls ../../ bin home lib32 media root sys vmlinuz
boot initrd.img lib64 mnt run tmp vmlinuz.old
dev initrd.img.old libx32 opt sbin usr
etc lib lost+found proc srv var
Listing 129 - Using ../ to get to the root file system From this point, we can navigate as usual through the file system. We can add etc to two ../
sequences to list all files and directories in the absolute path /etc. In the last command, we use
cat
to display the contents of the passwd file by combining the relative path (../../etc/passwd).