Basics of Linux

Basics of Linux

Overview

In this blog, I have shared the knowledge I gained while learning Linux. I have explained the concepts related to Linux like the architecture of Linux, basic Linux commands and Linux distributions.

Introduction to Linux

Linux is an open-source, Unix-like operating system that has been around for decades. It has become increasingly popular in the last few years, particularly in the server space where it dominates. Understanding the basics of Linux is essential for any programmer or system administrator, and this post will cover some of the most important aspects of Linux.

A Brief History

Linux was created by Linus Torvalds in 1991 as a free and open-source operating system similar to Unix, but for personal computers. Its development was community-driven, leading to its rapid growth and popularity. In the early 2000s, major tech companies invested in Linux, boosting its credibility. Today, Linux is used widely in servers, desktops, smartphones, and embedded systems. It continues to evolve with the help of its dedicated community of developers.

Architecture of Linux

Linux has a monolithic kernel architecture that manages system resources, hardware drivers, and process management. It is technically a Kernel which is not genetically based on Unix, but Linux is "Unix-like".

The Linux operating system is divided into two main parts: user space and kernel space. User space is where the applications and programs run, while kernel space is where the kernel and system-level processes reside.

The diagram illustrates the structure of the Linux system, according to the layers concept.

In Linux Architecture, it's the Linux Kernel that sits on top of the hardware directly and gives the user the ability to communicate and use the hardware. Shell sits on top of the Kernel as an Interface to get commands from the user.

What is a Kernal?

The Linux kernel is the core component of the Linux operating system. It’s the software residing in memory that tells the CPU what to do. When a computer starts, the first thing a bootloader loads is a Kernel.

Kernel provides an abstraction between the hardware and software. The kernel is so named because—like a seed inside a hard shell—it exists within the OS and controls all the major functions of the hardware.

Kernal enables the users to communicate with the hardware and the software by receiving inputs from the user and providing outputs.

The kernel important jobs performed by the kernel include Memory management, Process management, Device drivers and System calls and security.

What is a shell?

A shell is a special user program which provides an interface for users to use kernel.

Shell accepts human-readable commands from a user and converts them into something which the kernel can understand. It is a command language interpreter that executes commands read from input devices. The shell gets started when the user logs in or start the terminal.

When a command is entered by the user, the shell analyses it to determine which executable file should be launched. After determining the executable file shell forks a new process and passes the command with its arguments to the new process.

The new process then executes the command by performing the appropriate system calls which may involve reading and writing files, creating new processes, or communicating with other parts of the system.

Some popular shells include Bash, Zsh, and Fish.

What is a Terminal?

The terminal (or command line interface) is a text-based interface used to interact with operating systems. By typing commands into the terminal, users can navigate the file system, launch programs, install packages, and perform a wide range of system operations. The terminal offers greater flexibility and automation capabilities compared to graphical user interfaces (GUIs).

What's the difference between CLI and terminal

In Linux architecture, the terms "CLI" or command line interface and "terminal" are often used interchangeably, but they refer to different concepts.

CLI stands for Command Line Interface, which is a method of interacting with a computer's operating system through typed commands. In other words, CLI provides a text-based interface for users to communicate with the computer's operating system.

On the other hand, a terminal is a program that provides a graphical interface for users to access the CLI. The terminal program allows users to type commands into a window, which are then executed by the computer's operating system.

In Linux architecture, the terminal is just one of several ways to access the CLI. Other methods of accessing the CLI include logging in remotely through SSH or using a virtual console. However, the terminal is the most common way for users to access the CLI on Linux systems.In summary, the CLI is a text-based interface for interacting with the operating system, while a terminal is a program that provides a graphical interface for accessing the CLI.

Basic Linux commands

  1. Is – Displays information about files in the current directory.

  2. pwd – Displays the current working directory.

  3. mkdir – Creates a directory.

  4. cd – To navigate between different folders.

  5. rmdir – Removes empty directories from the directory lists.

  6. cp – Moves files from one directory to another.

  7. mv – Rename and Replace the files

  8. rm – Delete files

  9. uname – Command to get basic information about the OS

  10. locate– Find a file in the database.

  11. touch – Create empty files

  12. ln – Create shortcuts to other files

  13. cat – Display file contents on terminal

  14. clear – Clear terminal

  15. ps- Display the processes in terminal

  16. man – Access manual for all Linux commands

  17. grep- Search for a specific string in an output

  18. echo- Display active processes on the terminal

  19. wget – download files from the internet

  20. whoami- Create or update passwords for existing users

  21. sort- sort the file content

  22. cal- View Calendar in terminal

  23. whereis – View the exact location of any command types after this command

  24. df – Check the details of the file system

  25. wc – Check the lines, word count, and characters in a file using different options

Linux Distributions

Let's discuss a few popular Linux distributions:

  • Ubuntu: A widely popular Linux distribution based on Debian that is known for its user-friendly design and ease of use, making it a great choice for new Linux users.

  • Debian: One of the oldest and most stable Linux distributions that emphasizes robustness, reliability, and security, making it a popular choice for servers and critical applications.

  • Fedora: A cutting-edge and developer-friendly Linux distribution sponsored by Red Hat that provides easy access to the latest technologies.

  • CentOS: A free and open-source community-driven Linux distribution based on Red Hat Enterprise Linux that is designed for enterprise-level support and stability, making it a popular choice for servers and workstations.

  • Arch Linux: A lightweight and highly customizable Linux distribution that is ideal for advanced users who prefer to configure their systems from scratch, making it a popular choice for power users and developers.

Why Linux?

There are several reasons why someone might choose to use Linux as their operating system:

  1. Free and open source: Linux is free to download and use, and its source code is open for anyone to access, modify and distribute. This makes it an attractive option for individuals and businesses who want to save on software licensing costs and have more control over their technology.

  2. Stability and security: Linux is known for its stability and security. Its design and development process prioritizes security, and it is less susceptible to viruses and malware than other operating systems.

  3. Customizability: Linux is highly customizable, allowing users to modify the operating system to meet their specific needs. This flexibility makes it a popular choice for developers, researchers and other tech-savvy users.

  4. Community support: Linux has a large and passionate community of users who offer support, documentation, and troubleshooting resources. This makes it easier to find help and advice when needed.

  5. Compatibility: Linux is compatible with a wide range of hardware and software, making it a versatile option for users who need to work with different types of devices and applications.

Overall, Linux offers a range of benefits that make it a compelling choice for individuals and organizations looking for a powerful, flexible, and cost-effective operating system.