Beginner’s Guide to Linux

Everything you need to get started with Linux!

Ritchie Pulikottil
Level Up Coding

--

Currently, the Linux kernel has 20 million lines of code and this is the smallest it has ever been! Linux is one of the biggest open-source projects in the world and about 95% of Linux is written using the C programming language.

Introduction

Linux is a Unix-based operating system developed by Linus Torvalds and thousands of other contributors (as it was opensource), and this led to several distributions or what we call Linux Distros. Linux was a Unix clone, although it behaved like Unix, it didn't contain its code. Unix had a completely different code developed by AT&T Labs. However, they both had similar architectures, and the fact that Linux was opensource caused Unix to lose its popularity among supercomputers and other leading technologies. Click here, if you want to know more about their differences.

Why Linux?

In the modern age, we all are more familiar with the Windows operating system, but that’s not the case when you get into the IT sector. In fact, some companies totally depend on Linux as it is more reliable, lightweight, secure, fast, and opensource.

The fact that it is opensource lets you take a basic Linux operating system and create your own operating system out of it, and it's pretty hard for malware to break into a Linux kernel, which adds up to its security and reliability. But wait, don’t change your operating system right away, apart from the development and IT aspects, you may not find Linux as fun as Windows, so if you don’t want to change your Windows yet but you still want to use Linux, it’s perfectly fine — you can always emulate it using VirtualBox. Click here, if you want to figure out how to Install Linux Inside Windows Using VirtualBox.

Linux used to have Command-Line Interfaces back then, but in the modern age, we are offered some nice GUI distributions as well, like Ubuntu, centOS, et cetera. Here, we are gonna use centOS, and it doesn't matter which distribution you use, all are kinda similar to each other, except for very few commands, which I’ll highlight as we move on.

There are a lot more distributions, these are some of the most popular ones.

Linux Architecture

The core Hardware of any system (CPU, RAM, etc) cannot communicate with the users directly, and that is where the Kernel level of the Linux architecture comes into use. The Kernel basically helps us to contact the hardware, it helps us to provide our input into the hardware and receive the resultant output as well. Oh, wait! but how are we supposed to access the kernel? I don’t know where the kernel is! That is where the next level of Linux architecture comes in, The Shell. So, when the outer ring of Users wants to perform a command or run an Application in a Linux OS, the users are supposed to input their needs in The Shell, it in turn communicates with the kernel, and the kernel passes our input to the hardware. After the necessary processes are done, the resultant output is sent back to the kernel from the hardware and the kernel sends it back to the shell which is finally displayed as an output to the end-user!

SHELL

Now that you know how the shell works, you need to know where it is actually compatible. Shell is basically a part of the CLI Linux System and in today’s world, GUI Linux Systems are growing rapidly, but Shell doesn't work directly in a GUI environment, so what do we do now? Yes! we will have to emulate The Shell in our GUI Environment. Therefore, in GUI Linux Systems, we are provided with a software called Terminal, which helps us to emulate a CLI Linux System Shell inside a GUI Linux System!

We have various Linux Distributions and each distribution may lead to a particular shell. The most popular shell to date is the Bash followed by zsh, fish, tcsh, and so on. These remain the most frequently used Linux Open Source Shells.

Operations performed by a Kernel

  1. Resource Management: Decides which process gets the resource for operation.
  2. Memory Management: Allocates system memory to the processes efficiently.
  3. Device Management: Helps the processes to establish a connection with external devices like USB et cetera.
  4. System Calls: Sometimes a process may not have enough permissions to access a resource, in such a situation system calls can be used to provide the necessary permissions to the processes. System calls can also be embedded in a shell script in order to avoid interrupts caused by denial of permissions.

Basic Linux Commands

Apart from these,

cd command helps us to change the current working directory,

cd .. command helps us to move back a directory,

touch command helps us to create a file in the present working directory,

man command shows up the manual of a particular command.

rm command is used to remove a file or a group of files or all the files containing a particular extension,

cp command helps us to copy file content to another file (or) copy a file to another directory (or) copy files into multiple directories,

mv command helps us to move the content of a file into another file (or) move a file into another directory (or) move multiple files into another directory,

sudo means super user do and it provides us with the root user privileges.

mkdir command creates a directory.

rmdir command removes a directory.

find command searches for a file and lists it, it also searches for a directory and lists all the files under it.

file command prints the type of the file.

grep command searches for a pattern in a file.

echo command prints text on the terminal has many attributes within it, click here to know more and click here for centOS commands cheatsheet!

Click here, for a hands-on tutorial!

Text Editor

There are several text editors, however, Vim and Emacs are the most popular ones. Vim is an improved version of the Vi Editor, Its super lightweight, its easy to open and edit, and its most probably installed in most of the distributions. When it comes to Emacs, you might have to install it and it is not a CLI editor, it is an application. Nano is my personal favorite as it has a little bar that guides us with the shortcut hotkeys, however, Vim and Nano are pretty similar yet the fact that Vim is available in most of the distributions and given its advantages makes it more popular than Nano. Gedit is another editor that provides us with a GUI environment.

Vim Editor Tutorial: https://www.youtube.com/watch?v=g-XsXEsd6xA

Emacs Editor Tutorial: https://www.youtube.com/watch?v=Iagbv974GlQ

Nano Editor Tutorial: https://www.youtube.com/watch?v=gyKiDczLIZ4

File Permissions

Linux basically offers us three types of ownerships:

  1. User
  2. Group
  3. Others/Processes

Command to add a user: sudo user add username

Command to add a group: sudo groupadd groupname

and each owner may have three types of permissions,

  1. Read also (represented as number 4)
  2. Write (also represented as number 2)
  3. Execute (also represented as number 1)

The chmod command is used to modify permissions and the chown command is used to modify the ownership.

Click here, to find more about file permissions in Linux.

Process Control Commands

When we type a command inside a Linux terminal/shell, it starts a new process that invokes a five-digit unique ID known as the Process ID or the PID. The Process ID helps us to track the processes running inside an OS.

In Linux, a process can be initialized in two ways,

  1. Foreground Process: Every process runs as a foreground process by default. Example: pwd, ls, et cetera
  2. Background Process: These processes run in the background allowing other processes to run in parallel. They can be activated by adding an ampersand after your command. Example: pwd &

These processes can be tracked using the ps command. The ps aux command shows every single process. The ps -f command shows us an even more detailed representation of the process. The ps -u username shows us the processes occurring within the user.

A foreground process can be stopped by pressing Ctrl+C and a background process can be stopped using the kill command. Click here, to find more on the process control commands.

Alright, with that we have covered all the basics you would need, to start off with your Linux Journey. It’s definitely not possible to cover everything in one single article, however, if you are serious about Linux, and you are interested in learning more, I have added a few links below, which I found useful. Happy Learning!

GitHub

LinkedIn

Twitter

Resources:

--

--