Skip to main content

Command Palette

Search for a command to run...

Introduction for Linux

Updated
•11 min read•View as Markdown
Introduction for Linux

Linux is reliable and secures more than others and also it is completely open-source and free. Linux is everywhere! your car uses Linux, especially self-driving cars. even your refrigerators need Linux to run. approximately 85% of the universe uses Linux.

What is Linux?

One of the most popular operating systems is Linux which manages the communication between the software and hardware of a system. Linux is an open-source operating system similar to UNIX and is based on the Linux kernel.

Linux kernel is a program at the heart of the Linux operating system that takes care of fundamental stuff.

Open source

Open source means that the used to create is free and available to the public to view, edit and even contribute to its development.

Linux is also distributed under an open-source license. Open source follows these key tenets:

  • The freedom to run the program, for any purpose.

  • The freedom to study how the program works, and change it to make it do what you wish.

  • The freedom to redistribute copies so you can help your neighbour.

  • The freedom to distribute copies of your modified versions to others.

These points are crucial to understanding the community that works together to create the Linux platform. Without a doubt, Linux is an operating system that is “by the people, for the people”. These tenets are also a main factor in why many people choose Linux. It’s about freedom and freedom of use and freedom of choice.

Components of the Linux system

The Linux operating system comprises several different pieces:

  1. Bootloader – that is defined as the software that manages the boot process of your computer. For most users, this will simply be a splash screen that pops up and eventually goes away to boot into the operating system.

  2. Kernel – This is the one piece of the whole that is called ‘Linux’. The kernel is the core of the system and manages the CPU, memory, and peripheral devices. The kernel is the lowest level of the OS.

    It is the main component of a Linux os, operating system, and it is a core interface to communicate between the two managing resources as efficiently as possible.

  3. Init system – This is a sub-system that bootstraps the user space and is charged with controlling daemons.

    This is always executed by the Linux kernel after the early stages of bootup completion by the bootloader.

    Then the init system starts all the necessary daemons and background processes required to make os work, once the initial booting is handed over from the bootloader (i.e., GRUB or GRand Unified Bootloader).

  4. Daemons – These are background services (printing, sound, scheduling, etc.) that either start up during boot or after you log into the desktop.

    The daemon manages many parts of your system such as logging information, watching for devices inserted or removed and managing user login.

  5. Graphical server – This is the sub-system that displays the graphics on your monitor. It is commonly referred to as the X server or just X.

    It renders images and shapes on a computer monitor.

  6. Desktop environment – This is the piece that the users interact with. There are many desktop environments to choose from (GNOME, Cinnamon, Mate, Pantheon, Enlightenment, KDE, Xfce, etc.).

    Each desktop environment includes built-in applications (such as file managers, configuration tools, web browsers, and games).

  7. Applications – Desktop environments do not offer the full array of apps. Just like Windows and macOS, Linux offers thousands upon thousands of high-quality software titles that can be easily found and installed.

    Most modern Linux distributions (more on this below) include App Store-like tools that centralize and simplify application installation.

Linux distribution

Linux has several different versions to suit any type of user. From new users to hard-core users, you’ll find a “flavour” of Linux to match your needs. These versions are called distributions (or, in the short form, “distros”). Nearly every distribution of Linux can be downloaded for free, burned onto disk (or USB thumb drive), and installed (on as many machines as you like).

Popular Linux distributions include:

  • LINUX MINT

  • MANJARO

  • DEBIAN

  • UBUNTU

  • ANTERGOS

  • SOLUS

  • FEDORA

  • ELEMENTARY OS

  • OPENSUSE

Each distribution has a different take on the desktop. Some opt for very modern user interfaces (such as GNOME and Elementary OS’s Pantheon), whereas others stick with a more traditional desktop environment (openSUSE uses KDE).

You can check out the top 100 distributions on Distrowatch.

And don’t think the server has been left behind. For this arena, you can turn to:

  • Red Hat Enterprise Linux

  • Ubuntu Server

  • Centos

  • SUSE Enterprise Linux

Some of the above server distributions are free (such as Ubuntu Server and CentOS) and some have an associated price (such as Red Hat Enterprise Linux and SUSE Enterprise Linux). Those with an associated price also include support.

Why use Linux?

with Linux, the license is free, installing software is free and you can install Linux on any number of machines you want. there are a lot of Linux distributions and you can choose one from them. more secure than windows and viruses can't easily break the kernel.

Linux File System Hierarchy

You want to know about the hierarchy and structure of the Linux File system. You may also wonder why different types of software are installed in their different directories.

Linux uses the Filesystem Hierarchy Standard (FHS) file system structure, which defines the names, locations, and permissions for many file types and directories

To know the Linux Filesystem’s structure, let’s begin with the entry or starting point of the directories, which is known as the root directory. In this post, we will use the tree command to view the hierarchical structure of directories in the form of the tree in the terminal.

Let’s install a tool named “tree” to view the structure of directories and better understand the hierarchy.

To install the “tree” on Ubuntu, use the command below:

$ sudo apt install tree

Once “tree” is installed, first, change the directory to the root directory(/), using the “cd” command:

$ cd /

Then run the tree command here:

$ tree

It has shown all the directories and subdirectories, which was actually not needed since we only wanted to see the directories of the current folder.

So, let’s modify the tree command a little bit according to our needs, and try this command instead:

$ tree -L 1

In this command, the “-L” is representing the level we want to see, and the “1” is representing the level number.

Directories:

Let’s begin the root directory “/”:

/

This is the entry point of all directories and is described as a forward slash, which is the home of the Operating System. Everything is in it. Not every user has read and writes privileges to this directory; only the administrators or allowed users of the operating systems can have access to such privileges.

/root

Just like /home directory, /root is the house of the Administrator a.k.a. superuser. Since this is the superuser’s directory.

ls /root

/bin

The '/bin' directory contains user binaries, executable files, Linux commands that are used in single-user mode, and common commands that are used by all the users, like cat, cp, cd, ls, etc. The '/bin' directory doesn't contain directories.

ls /bin

/sbin

The '/sbin' directory also contains executable files. This directory is just like the /bin directory, but this is used by the superuser, and that’s why “s” is used before the bin.

e.g. fsck, root, init, ifconfig,fdisk, iptables etc.

ls /sbin

/dev

This directory holds the files of the devices like a USB Device or a Hard Drive. Most of the files are either created on the boot time or when a device is attached.

e.g./dev/tty and /dev/pts,/dev/null etc.

  • /dev/tty and /dev/pts: The '/dev/tty' file represents the command line interface that is a terminal or console attached to the system. Typing commands in a terminal is a part of the graphical interface like Gnome or KDE, then the terminal will be represented as '/dev/pts/1' (here 1 is replaceable by any other number).

  • /dev/null: The '/dev/null' file is considered a black hole, it has unlimited storage but nothing can be retrieved from it. You can discard your unwanted output from the terminal but can't retrieve it back.

ls /dev

/var

This is a variable directory that contains the files and folders whose size is expected to increase with the passage of time and the system’s usage.

e.g: log files, spool files and cache files.

  • /var/log: The '/var/log' directory contains all log files

  • /var/lib: The '/var/lib' directory stores the files that contain state information like databases. File data modify as their respective programs run.

  • /var/spool: The '/var/spool' directory is used to spool the files waiting to be processed. For example, printing queues and mail queues.

  • /var/cache: The '/var/cache' directory stores application cache data. Cache data are locally generated by I/O or calculation. The cache must be able to regenerate or restore the data. These files can be deleted without any loss of data.

ls /var

/mnt

The term 'mnt' stands for the mount. The '/mnt' directory should be empty and sysadmins can only mount temporary filesystems.

ls /mnt

/media

The '/media' directory acts as a mount point for removable media devices such as CD-Rom, floppy, USB devices, etc.

This is a newly introduced directory and hence a system can run without this directory also.

ls /media

/usr

This directory contains the applications installed and used by the user. It is also known as the “UNIX System Resources”. It also has its own /bin, /sbin, and /lib directory, which is different from the superuser’s /bin, /sbin, and /lib directories. It only contains shareable read-only data.

ls /usr

  • /usr/bin: The '/usr/bin' directory contains non-essential binary commands for all users. If you can't find a command in '/bin', search for it in '/usr/bin'. It contains a lot of commands.

  • /usr/include: The '/usr/include' directory contains standard include files for C.

  • /usr/lib: The '/usr/lib directory contains libraries that are not directly executed by the users. In other words, it contains binaries for the '/usr/bin' and '/usr/bin

  • /usr/share: The '/usr/share' directory contains architecture-independent (shared) data.

  • /usr/local: The '/usr/local' directory is used to install software locally. It means all the user programs that you'll install from the source will be installed here.

  • /usr/src: The term 'src' is short for source. It is used to store source code like kernel source code with its header files.

/etc

All the machine-related configuration files are kept in '/etc'. Almost everything related to the configuration of your system is placed here. It also contains a startup and shutdown shell script which is used to start and stop a program.

The meaning of 'etc' is very controversial. Earlier it was referred to as 'Etcetera' because it could contain all the files that did not belong anywhere else. But recently its most likely meaning is 'Editable Text Configuration' or 'Extended Tool chest'.

Configuration files will have an extension of .conf.

ls /etc

Some common directories of /etc are:

  • /etc/init.d/: The term 'init' is short for initialization. This directory contains a script to control the system or to start and stop the daemons (background process). The 'init' is a daemon process that continues running until the system is shut down.

  • /etc/X11/: The X Window system configuration files are stored in this directory. The configuration file of the graphical display (xorg.conf) is also stored here.

  • /etc/skel/: The term 'skel' is short for the skeleton. Everything in the system has a skeleton which is called a hidden file and is stored in this directory. It is not an important part of the system and can be deleted but still, it serves a specific purpose. Its purpose is to serve the basic set of files, a basic framework which can be used in the creation of a new user.

/boot

The '/boot' directory contains boot loader files which are essential to boot the system. In other words, they only contain files which are needed for a basic Linux system to get up and going.

You may find the '/boot/grub' directory which contains '/boot/grub/grub.cfg' (the older system may have /boot/grub/grub.conf) which defines the boot menu that is displayed before the kernel starts.

ls /boot

/opt

The term 'opt' is short for optional. Its main purpose is to store optional application software packages. Add-on applications from individual vendors should be installed in '/opt'. And so in some systems '/opt' is empty as they may not have any add-on application.

ls /opt

/home

The '/home' directory stores users' personnel files. After the '/home' there is a directory which is generally named at the user's name like we have '/home/sssit'. Inside this directory, we have our sub-directories like Desktop, Downloads, Documents, pictures, etc.

  1. ls /home

  2. ls /home/sssit

Note: Tilde (~) sign indicates "/home/sssit". For example, if you want to give the command "/home/sssit/Desktop" so instead of writing this you can also write "~/Desktop", both are the same.

/tmp

The term 'tmp' stands for temporary. Data stored in '/tmp' is temporary and may use either disk space or RAM. When the system is rebooted, files under this directory are automatically deleted. So it is advisable that never use '/tmp' to store important data.

/proc

This is the directory with the pseudo files. The pseudo files contain information about the processes.

ls /proc

/srv

The term 'srv' is short for service. The '/srv' directory contains server-specific data for services provided by the system like www, CVS, rsync, FTP, etc.

ls /srv

/lib

The '/lib' directory contains shared libraries which are often used by the '/bin' and '/sbin' directories. It also contains a kernel module. These filenames are identifiable as ld* or lib*.so.*.

  • /lib/modules: The '/lib/modules' stores kernel modules and has a directory for each installed kernel. Modules are meant to use extra hardware support without making a new kernel.

  • /lib32 and /lib64: During the compilation time of libraries you'll encounter the directories named '/lib32' and '/lib64' which will clarify the register size to be used. A 64-bit system may have compatibility with a 32-bit binary.

ls /lib

/sys

The term 'sys' is short for system. It contains kernel information about hardware. It was created for Linux 2.6 kernel. It is a kind of '/proc' and is used for plug-and-play configuration.

ls /sys

More from this blog

Untitled Publication

7 posts