Day 2 - Basic fundamentals of Linux

Day 2 - Basic fundamentals of Linux

Introduction to Linux

Linux is an open-source Unix-like operating system-based family on the Linux kernel, and the OS kernel was first published on 17 September 1991 by Linus Torvalds. Typically, Linux is packaged as the Linux distribution, which contains the supporting libraries and system software and kernel, several of which are offered by the GNU Project.

Linux is one of the most outstanding examples of open-source and free software collaboration. The source code may be distributed, modified, and used non-commercially or commercially by everyone under the conditions of its respective licenses, like the GNU GPL (General Public License). For example, the Linux kernel is licensed upon the GPLv2.

What is a distribution?

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

Some of the most popular Linux distributions include Ubuntu, Red Hat, Fedora, Oracle Linux, CentOS, Debian, Linux Mint, and Solus.

What Are the Benefits of Linux?

Due to Linux’s open-source nature, Linux-based products and operating systems can be shaped to meet the demands of the developer.

One of the primary advantages of Linux is that it’s constantly being reshaped and developed to create new products that meet emerging needs. Developers can easily access the Linux source code for customization. Additionally, Linux offers a greater degree of security than many operating systems and requires no antivirus programs for protection. Linux also offers a high degree of stability, requires little disk space, has powerful networking capabilities, and puts software updates in the hands of the user.

Architecture of Linux system

Hardware: This is the bottommost layer of the Linux architecture and represents the physical hardware components of the computer, such as the processor, memory, and storage. The hardware layer is responsible for interacting with the various hardware devices and providing access to them for the rest of the operating system.

Kernel: The kernel is the core of the operating system and is responsible for managing the resources of the computer, such as the CPU, memory, and I/O devices. It also provides services to the other components of the operating system and acts as the intermediary between the hardware and the software layers.

SHELL: Shell is an environment in which we can run our commands, programs, and shell scripts. It is a user interface for access to an operating system's services.

Applications: This is the topmost layer of the Linux architecture and consists of the various applications that run on the operating system. These can be anything from productivity software and games to web browsers and media players.

Linux File Hierarchy Structure

1. / (Root): Primary hierarchy root and root directory of the entire file system hierarchy.

  • Every single file and directory starts from the root directory

  • The only root user has the right to write under this directory

  • /root is the root user’s home directory, which is not the same as /

2. /bin : Essential command binaries that need to be available in single-user mode; for all users, e.g., cat, ls, cp.

3. /boot : Boot loader files, e.g., kernels, initrd.

  • Kernel initrd, vmlinux, grub files are located under /boot

  • Example: initrd.img-2.6.32-24-generic, vmlinuz-2.6.32-24-generic

4. /dev : Essential device files, e.g., /dev/null.

  • These include terminal devices, usb, or any device attached to the system.

  • Example: /dev/tty1, /dev/usbmon0

5. /etc : Host-specific system-wide configuration files.

  • Contains configuration files required by all programs.

  • This also contains startup and shutdown shell scripts used to start/stop individual programs.

  • Example: /etc/resolv.conf, /etc/logrotate.conf.

6. /home : Users’ home directories, containing saved files, personal settings, etc.

  • Home directories for all users to store their personal files.

  • example: /home/kishlay, /home/kv

7. /lib : Libraries essential for the binaries in /bin/ and /sbin/.

8. /media : Mount points for removable media such as CD-ROMs (appeared in FHS-2.3).

  • Temporary mount directory for removable devices.

  • Examples, /media/cdrom for CD-ROM; /media/floppy for floppy drives; /media/cdrecorder for CD writer

9. /mnt : Temporarily mounted filesystems.

  • Temporary mount directory where sysadmins can mount filesystems.

10. /opt : Optional application software packages.

  • Contains add-on applications from individual vendors.

  • Add-on applications should be installed under either /opt/ or /opt/ sub-directory.

11. /sbin : Essential system binaries, e.g., fsck, init, route.

  • Just like /bin, /sbin also contains binary executables.

  • The linux commands located under this directory are used typically by system administrator, for system maintenance purpose.

  • Example: iptables, reboot, fdisk, ifconfig, swapon

12. /srv : Site-specific data served by this system, such as data and scripts for web servers, data offered by FTP servers, and repositories for version control systems.

  • srv stands for service.

  • Contains server specific services related data.

  • Example, /srv/cvs contains CVS related data.

13. /tmp : Temporary files. Often not preserved between system reboots, and may be severely size restricted.

  • Directory that contains temporary files created by system and users.

  • Files under this directory are deleted when system is rebooted.

14. /usr : Secondary hierarchy for read-only user data; contains the majority of (multi-)user utilities and applications.

  • Contains binaries, libraries, documentation, and source-code for second level programs.

  • /usr/bin contains binary files for user programs. If you can’t find a user binary under /bin, look under /usr/bin. For example: at, awk, cc, less, scp

  • /usr/sbin contains binary files for system administrators. If you can’t find a system binary under /sbin, look under /usr/sbin. For example: atd, cron, sshd, useradd, userdel

  • /usr/lib contains libraries for /usr/bin and /usr/sbin

  • /usr/local contains users programs that you install from source. For example, when you install apache from source, it goes under /usr/local/apache2

  • /usr/src holds the Linux kernel sources, header-files and documentation.

15. /proc : Virtual filesystem providing process and kernel information as files. In Linux, corresponds to a procs mount. Generally automatically generated and populated by the system, on the fly.

  • Contains information about system process.

  • This is a pseudo filesystem contains information about running process. For example: /proc/{pid} directory contains information about the process with that particular pid.

  • This is a virtual filesystem with text information about system resources. For example: /proc/uptime.