Linux kernel directories

Linux kernel should not be seen by the users, users use programs not the kernel directly, programs communicate with the kernel for resource reservation and other input/output functions. Linux at first is very difficult to get used to because everything in Linux is a file, including your hardware devices they are all stored in files, regular Windows will find this concept hard to grasp at first and wonder where your downloaded files are located and what files are stored in the directories.

Typical directories which you will find in all linux distributions.

Directory and its function

/bin

Linux utilities programs are stored here. Utility programs such as bash, cut, more, chmod, mount, touch, umount, ping, cp, tty…etc. These utility programs are essential for day to day Linux administration.

/dev

Here stores all your devices. All your devices are stored in files, the files are created during system boot up, if you are doing backup you can exclude files in this directories. Files such as your hard disk, hard disk partitions, terminal (tty), usb devices…etc. A thing to note about a file known as ptmx, this file has to be mounted to /dev/pts in order for you to telnet or ssh.

/home

Here stores user’s own data and other stuffs you as a user chooses to store. Usually the default download location is under /home/you/Download, if you have downloaded something from the net via browser such as Chromium they will by default saved in your /home/you/Download directory. Each user has their own /home/username sub directory under /home. /home/you is represented by ~/ as well. When you change directory (cd) to ~/ you effectively change directory to your /home/you.

/lost+found

Supposed your hdd is crashed for some reason, on the next reboot fsck is checking your file system, some lost file fragments found by fsck will be dumped here.

/mnt

This directory can be the mount point for your external devices or external disk (it is not limited to only storage devices, basically you can mount anything here), such as CDROM or DVDROM, or an external HDD. To mount your external storage devices you do this:

Example your storage devices is at /dev/sdb1

install -d /mnt/myhdd (optional)

mount -t ntfs /dev/sdb1 /mnt/myhdd/

You can mount directly to /mnt if you want, it is not mandatory to create a sub directory under /mnt.

If your external hdd is formated in ext4 filesystem you can just do:

mount /dev/sdb1 /mnt/

There is no need to specify ext4 filesystem when mounting your external storage device.

To mount an iso image:

mount -o loop /home/me/myiso.iso /mnt/

You cannot mount .bin image though. You have to convert .bin image into .iso image in order to mount it. To convert .bin to .iso you can use bchunk program to do so.

/proc

This directory stores files of your system processes, resource information and other system hardware information. When doing backup you can exclude the contents of /proc as well since the files in /proc will be created during run time.

To check your memory you can do this:

cat /proc/meminfo

To check your cpu information you can do this:

cat /proc/cpuinfo

To check your kernel version you can do this, the result is the same as uname -r command:

cat /proc/version | cut -f 3 -d ‘ ‘

/run

This directory stores your system current running processes.

/srv

Not exactly sure the use of /srv.

/tmp

Temporary files will be dumped here, when you stream video in youtube some files may be stored here temporarily, I encountered video unable stucked at buffering when my /tmp folder is 100% full.

/var

Variable files are stored here, when installing Linux Mint liveCD, liveCD will copy all files to /usr folder first then proceed the installation, during installation files will start to fill up /var, I have made a 400MB partition for /var which proved to be insufficient, the Mint installation crashed. /var stores some cache files as well. Most of the log files can be found under /var/log, your running processes may also create files in /var, this directory need to be reasonable large enough, I am still observing how much space for /var is reasonable for Linux Mint 12.

If you have apache http server installed you may also find the default location under /var/www/.

/boot

This is where your Linux kernel is stored, grub bootloader configuration is also stored here. When boot up the bootloader will by default look for Linux kernel and image from /boot/ directory based on the configuration of /boot/grub/grub.cfg.

/etc

Most of your program or daemon configuration files are stored here. Grub file which influences the creation of /boot/grub/grub.cfg can also be found in /etc/default/.

To customise your grub.cfg you cannot change the settings directly from /boot/grub/grub.cfg, you should change it from /etc/default/grub.

/lib

Contains library files when compiling your program from the source codes.

/media

Your removable devices will be mounted here automatically by many modern Linux distribution, devices such as external usb hdd, external cd/dvd rom drive and external usb thumbdrive will be automatically mounted here.

/opt

Your firefox profile and extensions might be located in /opt directory, google earth also creates sub directory under /opt. If you are installing OSSEC the default location is created under /opt unless you specify the destination.

/root

This is the home directory for root.

/sbin

Contains system utility programs. Programs like blkid which identifies your hdd UUID, iptables (firewall), your wireless utility tools, system reboot and system shutdown programs. These programs most of them requires root permission.

/sys

Contains kernel, filesystem, firmware, power files, drivers…etc.

/usr

This could be the largest directory, most of your installed programs are located here, such as your firefox, chromium browser, wireshark, libreoffice….etc. A note on /usr/local/ sub directory is that you can create customize programs or scripts and copy to the local sub directory and make a partition dedicated for /usr/local.

Reference: http://www.debianadmin.com/linux-directory-structure-overview.html

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s