Home » Linux » Tips » Etc Bin Etc Dev Linux Directories And Whats In Them

/etc /bin /etc /dev – Linux Filesystem Directories and What’s in Them

If you’re new to the Linux operating system, you might be a bit confused about exactly what is stored where on your hard drive.  Directories like /etc and /bin might seem confusing to you if you’re used to Windows‘ directory structure. This article will tell you what everything is.

As an end-user, you’ll probably only need to worry about the actual contents of a few of these directories – /home, /etc/, /var, /srv, /media.

The contents of the other directories are mostly managed by package managers (for installing software) and system services (for device management etc.).

A Note on Permissions

Most users won’t have permission to modify (and sometimes even read) many of the below directories. Generally, non-administrative users will only be guaranteed permission to write to their directory in /home.

The Filesystem Root (/)

The filesystem root is the top level of the file storage system on your computer. It contains all of the files and directories accessible on your computer.

It is accessible at the location /.

Other file systems (including those on other physical devices), to be accessible, are usually mounted under a directory in the root filesystem called a mount point.

Thus, there are no drive letters like in windows – everything will appear somewhere under /.

Binaries (/bin)

The /bin directory holds the binaries (executable programs) essential for system operation. This includes things like the bash shell and other programs that must be loaded for a functional computer system.

Boot (/boot)

The /boot directory holds the files that Linux OS needs to boot. This includes the boot-loader.

Devices (/dev)

Linux represents attached devices as files in the file system (which is super convenient when scripting). These file representations of devices are stored in /dev.

Be warned that these aren’t real files – you can’t copy a sound card onto a USB stick – they are just representations of the device on the file system so that they can be easily accessed and interacted with by programs on the system.

Configuration (/etc)

Most users will wind up modifying the contents of /etc. This is the directory where system-wide configuration files are stored, and if you’re running a server of some kind (Apache, MySQL), the configuration files for it will appear somewhere in here.

Home Directories (/home)

The /home directory contains each user’s own files in a subdirectory, usually named for the username of the user.

For example, the user tim would probably find his home directory at /home/tim.

Per-user configuration is also stored in the user’s own home directory.

/root (Root’s Home)

The home directory, but for the system’s administrative root user.

This is not the root filesystem but the home of the root user.

Code Libraries (/lib)

Code libraries required by the essential programs in /bin and /sbin are stored in the /lib directory.

Lost & Found (/lost+found)

If corrupted files are found after a crash or after a device is disconnected unexpectedly, and they are later found, they’ll appear in the /lost+found directory for recovery purposes.

You might see this directory appear on your USB sticks as well – this directory is created on any filesystem on a Linux system where recoverable files are found.

Removable Media (/media)

This is where removable media such as USB sticks will be mounted for use. The /media directory should contain a subdirectory for each attached removable storage device (such as a USB stick or CD-ROM).

Linux systems that are set up to mount removable storage automatically will usually mount them here. If you’re manually mounting a drive, it’s worth mounting it here also for consistency.

Optional Packages (/opt)

/opt is a directory for optional (non-system-essential) software packages to put their files. It’s usually used by packages that don’t have a structure that will conform to placing files in the /usr/bin and /usr/lib directories.

Process Files (/proc)

This directory contains a file representation of the running system processes. Like /dev, the contents of /proc are not real files.

System Binaries (/sbin)

Similar to /bin/sbin contains essential system binaries which are intended for system administration.

Temporary Files (/tmp)

Does what it says on the tin. Temporary files go in /tmp.

User Binaries (/usr)

The /usr folder contains programs intended for the user which aren’t vital to the systems operating functions.

Whereas the Bash Shell executable will probably be located in /bin – as it’s essential for the operating of your system – your web browser will probably be in the /usr directory as it isn’t essential to the operating system.

This distinction is made so that the contents of /usr can be mounted after the system is booted and all essential software is loaded – so that it can be stored on another physical device if need be.

Inside the /usr directory are /usr/bin and /usr/lib which are analogous to /bin and /lib – but for their non-essential software counterparts.

Variable Data (/var) & Service Data (/srv)

These two directories will contain the data used by various services on the system that don’t necessarily belong to a specific user (and thus don’t belong in their home directory).

The Apache web server by default stores the web page files it serves in either /var or /srv.

The system will store log files in /var/log.

SHARE:
Photo of author
Author
I'm Brad, and I'm nearing 20 years of experience with Linux. I've worked in just about every IT role there is before taking the leap into software development. Currently, I'm building desktop and web-based solutions with NodeJS and PHP hosted on Linux infrastructure. Visit my blog or find me on Twitter to see what I'm up to.

Leave a Comment