What are the most important directories in Linux
Working with a Linux distribution is a completely different thing. If you are a windows user you can see they have a drive-based structure for the file systems. If I take an example there is a system directory called C:/windows/system32. If you have another partition they will be D:\, E:\, etc. All the files and folders are inside of those drives. So every file path is starting with a drive letter. But in Linux, we treat all things as directories. The directory tree begins with '/'. We call it the root of the tree.
[email protected]:~$ ls / 0 dev initrd.img lib64 mnt root snap tmp vmlinuz bin etc initrd.img.old lost+found opt run srv usr vmlinuz.old boot home lib
/root and /home directories
Actually, in Linux, there are three things called root. Above the root of the directory tree is a one. Next, we have a superuser called 'root'. Also, there is a special directory as /root that's owned by the root user. this one is equal to the home folder of the root. Normal users have their own home folders in /home. If your user name is 'us3r' your home folder will be /home/us3r. I think you may have seen that many times there is a flag called root.txt in CTF s inside /root. So if you want to get that flag you need to root the mashing.
Hear you can find files that have a variable size. It's a common thing that the htdocs folder of the server is located in this directory. In early versions that was /var/www and now that's /var/www/html. Also, log files are located inside this directory. (/var/logs)
[email protected]:~$ ls /var backups lib lock mail run spool unicornscan cache local log opt snap tmp www
This is the place for temporary files. Usually, this folder has written permission for all. You may find that when uploading a shell to the server we first change the current directory to /tmp.
/sys /usr directory
This directory comes with commands and data files. There are many sub-application files in /usr/share folder.
[email protected]:~$ ls /usr bin games include lib lib64 local sbin share src var [email protected]:~$ ls /usr/share accountsservice gvfs pev aclocal hal php7.2-common aclocal-1.16 hamster-sidejack php7.2-json adduser hashcat php7.2-mysql afl hashcat-utils php7.2-opcache aglfn help php7.2-pgsql airgeddon hexorbase php7.2-readline alsa hfsprogs php7.2-sqlite3 android-framework-res highlight pipal ant homebank pixmaps
This folder is responsible for holding all configuration files. If you want to tweak your Is or programs you may need to go there. For example to change sources in apt you want to edit /etc/sources.d
[email protected]:~$ ls /etc adduser.conf gimp menu-methods rmt adjtime glvnd mercurial rpc aliases gnome-system-tools mime.types rsyslog.conf alsa gnuradio miredo rsyslog.d alternatives groff miredo.conf samba amap group mke2fs.conf sane.d anonsurf group- modprobe.d scalpel apache2 grub.d modules screenrc apm gshadow modules-load.d securetty apparmor gshadow- mono security apparmor.d gss motd selinux apt gtk-2.0 mpv sensors3.conf arpwatch gtk-3.0 mtab sensors.d
This directory contains all executable binary files required for booting the system. Commands those run in single user-mode such as ls, ping, chmod are also located here.
[email protected]:~$ ls /bin bash findmnt netstat su btrfs fsck.btrfs networkctl sync btrfsck fuser nisdomainname systemctl btrfs-find-root fusermount ntfs-3g systemd btrfs-image getfacl ntfs-3g.probe systemd-ask-password btrfs-map-logical grep ntfscat systemd-escape btrfs-select-super gunzip ntfscluster systemd-hwdb
Here you can find system libraries and kernel modules.
This folder can be used to hold custom program files. If you wanted to install sublime manually you may copy files to /opt/sublime.
[email protected]:~$ ls /opt car-hacking firmware-mod-kit sublime_text Teeth xplico
This directory Contains device-related files for all hardware devices. If you are going to mount a new drive you may need this directory.
[email protected]:~$ ls /dev agpgart kmsg serial tty20 tty47 uhid autofs log sg0 tty21 tty48 uinput block loop-control sg1 tty22 tty49 urandom bsg lp0 sg2 tty23 tty5 vcs btrfs-control mapper sg3 tty24 tty50 vcs1 bus mem sg4 tty25 tty51 vcs2 cdc-wdm0 memory_bandwidth shm tty26 tty52 vcs3 cdrom mqueue snapshot tty27 tty53 vcs4 cdrw net snd tty28 tty54 vcs5
So I hope you got an idea about the Linux directory tree. Thank you for reading. Just leave a comment if something is unclear or wrong.
Hi, I'm Thilan from Srilanka. An undergraduate Engineering student of University of Ruhuna. I love to explorer things about CS, Hacking, Reverse engineering etc.