Part 2: Linux OS Basics
Getting started
Before moving further, we need to have Linux OS installed on our machine.
If you are a windows user, you can either make your system dual-boot to Linux or use WSL to get a taste of Linux or use a live USB stick.
Another option for Windows user is to install Hyper Terminal. But in my opinion, having a full OS installed on your machine has more benefits, as you can focus more on the OS part rather than being involved in making the OS features work on Windows. Now, lets move on to the basics.
If you ever get stuck in Linux, e.g, if you want to know more about some program, command, topic or utility, the “man” command will help you. Just type the entity’s name after the man command : man <name> and you will get the manual page for that entity (if it exists). As we can infer from the following image, man git command produces the manual for git command :
Few stats about Linux that makes it a winner : 🐧
1. Every 9 out of 10 Supercomputers and more than half of world’s servers run on Linux.
2. Every day more than 1 million Linux devices come alive (Android phones and Televisions)
3. Google,Twitter, Facebook are all powered by Linux.
4. More than 8000 developers from across the world have collaborated in the Linux project since 2005.
5. Every hour almost 6 patches go into Linux project, and every 3 months a new version of kernel is released. All this is possible due to a great community that has grown around Linux, which is headed by Linus Torvalds himself.
6. It is used byb75% of stock market systems.
So, it is almost everywhere.
Now as there are many Linux distributions out there, which one should you get? For beginners and learners, “Ubuntu by Canonical” is a great choice, as it has a good community and a huge collection of resources. It is also easy to use and install, which accounts for its popularity in academics.
Basic Terminology :
You should know: Kernel, Boot-loader, Distribution, Service, file-system, X Window system, desktop environment, and command line.
- Kernel: It is the brain of Linux system which control the access to hardware.
2. Distribution: It is a collection of programs and utilities which is packed along with the Linux Kernel. Distribution is the full OS. In common Linux language, it is also known as “distros”.
3. Boot Loader: It is a program that boots the Operating System. E.g. GRUB, ISOLINUX .
4. Service : It is a program that runs as a background process. E.g httpd, ftpd, ntpd and named etc.
5. File-System: A method for organising and storing files in Linux. E.g ext3, ext4, FAT, XFS, and Btrfs.
6. X Window File system: It provides the standard toolkit and protocol to build Graphical User Interfaces (GUI’s) for Linux based systems.
7. Desktop Environment: It is a GUI interface on top of Operating system. e.g. GNOME, KDE, Fluxbox etc.
8. Command Line : Also known as Terminal. It is an interface to write commands for OS . Often, it is confused with Shell.
9. Shell: A shell is a command line interpreter that interprets the Command Line input and and directs the OS to perform tasks. E.g bash , zsh, ksh, sh etc.
A full Linux distribution consists of the kernel plus a number of other software tools for file-related operations, user management, and software package management.
How Linux Boots ?
On a x86 processor (Short for Intel’s 80x86), a BIOS (Basic Input Output Sytem) which is a firmware loaded on a small ROM chip, initialises the hardware (Keyboard, Screen etc) and then runs a POST (short for Power On Self Test)
Then, a boot loader takes control form the BIOS. It is located in the boot sector of MBR (for old systems) and EFI partition on UEFI(newer systems). The boot loader (on MBR or EFI) searches for a second stage boot loader , GRUB(Grand Unified Bootloader from GNU), which resides under /boot. The GRUB then presents a splash screen which allows the user to select from a list of installed OS’s. The selected OS gets loaded into the RAM (the main memory). Now, kernel has full control and it’s first job is to uncompress itself. It then executes initramfs which loads relevant drivers by running udev program and finds the proper mountable root file-system while checking for errors using the mount program.
Once mounting is successful, initramfs is cleared from RAM , finally, init program is executed which mounts the real file system.
Init is the root process from where other processes originate(except the essential kernel processes). It starts the text-mode login attempts which asks for username and password (if setup), and takes you to the default shell, which commonly is the BASH shell. Hence, init is also responsible for cleaning , login and logout in Linux OS.
Parallel Computing
Most recent systems have stepped away from this sequential startup way, to utilise the power of parallel computing and they use systemd . So, systemd replaced the traditional sequential init process.
If your OS is shipped with GUI like GNOME or KDE you, won’t see the shell instead you will see a beautiful GUI. (Most distros starts 6 text terminals and one GUI terminal). Congrats, now you have successfully started your Linux OS!
File System in Linux:
A partition is a physically contiguous section of a disk, or what appears to be so in some advanced setups. It acts as a container for file-system.
A file-system is a method of storing/finding files on a hard disk (usually in a partition)
Linux uses a standard layout system for files which is maintained by the Linux Foundation. It does not have drive letter and Linux uses the ‘/’ character to separate paths (unlike Windows, which uses ‘\’). Drives are mounted as directories in file-system.
The ‘/’ is the root directory , the file-system names are case-sensitive. As we can see from the image, all non-system specific files are placed under the /usr directory and the configuration files are under the /etc directory.
In the next part, we will see how to use Linux command line and learn some basic commands too. Till then, have a nice and adventurous day! 😉