Linux Directory Structure & Shell

Linux Directory Structure & Shell

File types in the Linux operating system.

General Files -
Ordinary files are another name for it. It could be an image, a movie, a program, or just plain text files. These files can be in either ASCII or Binary format. It is the most frequently used file in the Linux operating system.

Directory Files -
These files serve as a repository for other file kinds. It could be a directory file contained within another directory (subdirectory).

Device Files -
Devices such as CD-ROMs and hard drives are represented as drive letters in a Windows-like operating system, whereas files are represented in a Linux system. For instance, /dev/sda1, /dev/sda2, and so on.

Linux Directory Structure

The following are some of the most popular top-level directories connected with the root directory:

/bin - contains binary or executable programs.
/etc - contains system configuration files.
/home - contains the home directory. It is the default current directory.
/opt - optional or third-party software.
/tmp - temporary space, usually removed on reboot.
/usr - user-related programs.

Other folders in the Linux system include:
/boot- This directory stores all boot-related information files and folders such as conf, grub, and so on.
/dev - This is the location of device files like dev/sda1, dev/sda2, and so on.
/lib - This directory contains kernel modules as well as a shared library. /lost+found - This command is used to locate recovered portions of corrupted files.
/media - This directory contains subdirectories containing removable media devices.
/mnt - This directory contains temporary mount directories used to mount the file system.
/proc - Virtual and pseudo-file system that stores information about ongoing processes with a unique process ID or PID.
/run - This command maintains volatile runtime data.
/sbin - executable binary programs for administrators.
/srv - This directory holds server-specific and server-related files.
/sys - Virtual filesystem used by current Linux distributions to store and modify the devices connected to the system.

What is a Shell, and Why do we need them?

The kernel launches a new shell instance whenever a user signs into the system or starts a console window. Any operating system's kernel is its beating heart.

It is in charge of controlling, managing, and executing processes, as well as ensuring proper system resource utilization.

A shell is a program that serves as a conduit between the user and the kernel. It enables the user to provide commands to the kernel and get responses in return. We can run programs and utilities on the kernel using a shell. As a result, at its core, a shell is a program that is utilized to run other programs on our system.

Shells are a powerful tool because they can communicate with the kernel. A user cannot utilize the utilities provided by their machine's operating system unless they can interface with the kernel.

Different Types of Shells in Linux

  1. Shell of Bourne (sh)
    The Bourne shell, created at AT&T Bell Labs by Steve Bourne, is widely recognized as the first UNIX shell. It's written as sh. It became famous due to its small size and rapid operating speeds.

    This is what made it the default shell for the Solaris operating system. All Solaris system administration scripts use it as the default shell. Start learning about shell scripting right now.

  2. Bourne-Again Shell (bash)
    The GNU Bourne-Again shell, also known as the Bash shell, was created to be compatible with the Bourne shell. It integrates important functionality from many Linux shells, such as the Korn shell and C shell.
    Unlike the Bourne shell, it allows us to automatically retrieve previously used commands and alter them using the arrow keys.
    The GNU Bourne-Again shell's full pathname is /bin/bash. It uses the prompt bash-VersionNumber# for the root user and bash-VersionNumber$ for non-root users by default.

  3. C Shell (csh)
    Bill Joy invented the C shell at the University of California. It is abbreviated as csh. It was created with helpful programming features in mind, such as built-in support for arithmetic operations and a syntax similar to the C programming language.
    Furthermore, it included command history, which was lacking in many types of Linux shells such as the Bourne shell. "aliases" are another major aspect of a C shell.
    The C shell's whole pathname is /bin/csh. It uses the prompt hostname# for the root user and hostname% for non-root users by default.