Introduction to Linux

Introduction to Linux

Basics of linux

ยท

6 min read

What is Linux

Linux is an open-source operating system kernel developed by Linus Torvalds. It provides the foundation for various Linux distributions and is known for its stability, security, and flexibility. Widely used in servers, desktops, and embedded systems, Linux offers a customizable and community-driven approach to computing.

Operating system:

  • It is software that manages and operates the computing device.

  • The operating system consists of several components, including the kernel, file system, user interface, and command interpreter.

Kernel:

  • It is a fundamental component of the operating system that acts as a bridge between hardware and software.

  • The kernel facilitates communication between the hardware and software components of the system.

File system:

  • It is a method used by the operating system to organize, store, and retrieve data on storage devices.

  • The file system provides a structured approach to managing files and directories.

User interface:

  • It is the interface through which users interact with the system.

  • There are two types of user interfaces: GUI (Graphical User Interface) and CLI (Command Line Interface).

Types of operating systems:

  • Windows, Linux, and macOS are common types of operating systems.

  • Linux and macOS are UNIX-based, while Windows has a different heritage.

Advantages of using Linux:

  • Linux is open source, allowing users to access and modify the source code.

  • It supports a wide range of programming languages and comes with many pre-installed applications.

  • Linux is popular among developers and offers powerful scripting capabilities.

Boot process:

  • When a computer is powered on, the BIOS (Basic Input Output System) performs a Power-On Self Test (POST) to check hardware functionality.

  • The boot loader, such as GRUB or GRUB2, initializes the operating system and starts the boot process.

Terminal and Shell:

  • The terminal is a text-based interface that allows users to interact with the computer using commands.

  • The shell is a command-line interpreter that executes commands entered by the user.

Here, in my shell prompt, the format "shivansh@kali" indicates that my username is "shivansh" and the hostname is "kali". The hostname represents the name of the device connected to the network, while the username refers to the name of the currently logged-in user.

Tree hierarchy of directory

The way in which the file system is arranged is called a tree hierarchy. It resembles a tree with branches that lead to further branches. Similarly, each directory leads to multiple directories and files, and those directories, in turn, lead to other multiple directories.

Basic commands

  • ls(list):- It is a command used to display the contents of the present working directory. A user can use the -a flag to see all the files, including hidden files, and the -l flag to view detailed information about the content.
ls "directory name"
  • pwd(present working directory):- to check in which working directory you are in.
pwd
  • cd(change directory):-To navigate to another directory, use the command cd. Use .. to go to the one directory back for example lets say if you are in Desktop and if you use cd .. you will go back to home directory.

  • use cd ~to go to the home directory. To go to the previous directory you were in, you can use the command cd -.

cd ..
cd Desktop
cd ~
cd -
cd "directory"
  • Flags:-flags are command-line options that modify the behavior of a command. For example, in the command 'ls -al', the 'a' and 'l' are flags. These flags provide the user with detailed information about every file, including hidden ones.

  • clear:- to clean the terminal.

      clear
    
  • mkdir(make directory):- to create a directory and use the -p flag to create sub-directory.

mkdir "directory name"
mkdir -p folder/nextfolder
  • touch:- to create a file, Use this command.
touch filename
  • cat(concatenate) :- to see the details of the file in the terminal.
cat "filename"
  • history:- To see the command you have used before. you can use history command
history
  • ctrl+ c:- To interrupt a process, such as when downloading something using a package manager, you can utilize the keyboard shortcut Ctrl + C. This combination allows you to stop or terminate the ongoing process for any reason.

  • ctrl + r :- to search for the desired command used.

  • cp(copy):- cp is used to copying the file from source to destination.

cp "source file" "destination file"
  • mv:- to move the file from source to destination.
mv "source directory" "destination directory"
  • Relative path:- It refers to the path of a file or directory relative to the current directory or a specific relative directory. For example, if a file is located in the 'Desktop' directory and you are currently in the 'Documents' directory, the relative path from that directory would be used to access the file.
cat ../Desktop/file.py

  • Absolute path:- An absolute path is a complete and specific reference to a file or directory location in a file system. It describes the precise path starting from the root directory and includes all intermediate directories necessary to reach the target file or directory.
cat ~/Desktop/file.py

Here, instead of using a relative path like ../Desktop/file.py, we have utilized an absolute path~/Desktop/file.py starting from the root directory to the destination file.

  • rm : - to remove the file sometimes can be directory depends on the flags used. The -rv Flags can be used to delete all the files present in that directory, where 'r' stands for recursive. This option deletes the contents of the directory as well. The 'v' flag, which stands for verbose, provides detailed information to the user about the deleted files.
rm -rv "filename"
  • rmdir:- It is a command used to remove a directory.
rmdir "directory name"
  • find:- The find command is used to search for files starting from a specified point, recursively exploring all folders within the starting directory.
find "starting folder name" -name "filename"
find / -name file.py

System will search for the file file.py present under root(/) directory

  • man (short for manual):- It is used to view the format in which a command should be used, as well as its functionality and the flags associated with it.
man ls

This is the end of this blog, but our journey into Linux is far from over. In our upcoming articles, we will delve deeper into Linux processes, jobs, the Linux boot process, the Linux file system, and many more fascinating topics. Stay tuned for more exciting content and join us as we explore the vast world of Linux.

Source

I have written this blog after taking reference from here Apoorv Goyal's video

ย