Linux Directories

Linux Directory Structure

Directories, files, and devices such as a mouse, keyboard, printer, and so on are all files in the Linux/Unix operating system. In this section, we will look at the Linux Directory Structure.

General Files – It's also known as ordinary files. It could be a picture, a video, a programme, or simply plain text files. These files may be in ASCII or Binary format. It is the file that is used the most in the Linux operating system.

Directory Files – These files act as a storage location for other file types. It might be a directory file contained within another directory (subdirectory).

Device Files – In a Windows-like operating system, devices such as CD-ROMs and hard drives are represented by drive letters such as F: G: H, whereas devices in a Linux system are represented by files. For instance, /dev/sda1, /dev/sda2, and so on.

Some basic Linux Directory Commands

  • pwd - The pwd command is a shortened form for the command (print working directory). It displays the current working directory or location of the user. It shows the entire working path starting with /. It is a command that has been pre-programmed.
  • ls - Displays a list of files in a folder. It will list all of the files in the specified folder.
  • cd - The command cd is a shortened form for copy (change directory). It is used to navigate from the current directory to the one in which you want to work.
  • mkdir - You can use the mkdir command to create your own directory.
  • rmdir - The rmdir command is used to delete a directory from your computer.

These are the common top-level directories associated with the root directory:

  • /bin – This directory contains executable or binary files. This directory contains programmes and Common Linux commands for use in single-user mode.
  • /etc – This directory contains system configuration files required by all programmes, as well as startup and shutdown shell scripts used to start and stop individual programmes.
  • /home – When a new user is created, a directory within the home directory that contains other directories such as Desktop, Downloads, Documents, and so on is created.
  • /opt – opt is a shortened form for optional. There is third-party application software included. Consider Java as an example.
  • /tmp –Directory containing temporary files created by the system and users, which are typically deleted when the system is rebooted.
  • /usr – This directory contains second-level programme executable binaries, documentation, source code, and libraries.
  • /var – The log is stored in this directory.
  • /boot- This directory contains all files related to the boot process or the boot loader.
  • /dev – This is where device files such as dev/sda1, dev/sda2, and so on are stored.
  • /lib – A kernel module and a shared library can be found in this directory.
  • /lost+found – This command locates recovered bits of corrupted files.
  • /media – Creates a temporary mount directory for removable devices.
  • /mnt – A temporary mount directory used to mount a file system.
  • /proc – Information about currently running processes with a unique Process-id or id.
  • /run – This command is used to save volatile runtime data.
  • /sbin – Administrators' executable binary programmes.
  • usr/sbin – This directory contains Super User and System Administration commands.
  • /srv – The server-specific and server-related files are stored in this directory.
  • /sys – A virtual filesystem used by modern Linux distributions to store and modify the system's connected devices. 
  • /usr/bin – This directory contains the majority of the executable files.

0 Comments