Skip to main content

Command Palette

Search for a command to run...

Introduction to Linux OS and Shell commands

Updated
3 min read
Introduction to Linux OS and Shell commands

Linux is the backbone of the internet, runs on servers, desktops, smartphones, and even powers supercomputers. Embracing Linux means tapping into a world where you control the technology, not the other way around.

Linux is the most widely used operating system for servers, holding a majority market share of around 62.7%

what exactly is it, and why should you care? Let's peel back the layers of this powerful operating system, unravel its architecture, and equip you with shell commands that'll elevate you from a curious beginner to a command-line maestro.

Understanding Linux's architecture is like decoding the blueprint of a technological marvel. Here's a breakdown:

1. The Kernel: The Core Engine

The kernel is the heart and soul of Linux. It's the bridge between your hardware and software.

  • Function: Manages system resources, including memory, processing, and devices.

  • Role: Ensures that applications and hardware communicate seamlessly.

2. System Libraries: The Essential Tools

These are special programs that help application programs interact with the kernel. They include essential libraries like GNU C Library (glibc) that offer basic functions such as file handling and memory management.

  • Function: Provide a standard way for applications to access system resources.

  • Example Libraries: GNU C Library (glibc).

3. System Utilities: The Control Panel

Utilities are programs that perform individual, specialized management tasks.

  • Function: Handle system operations like file manipulation, process management, and system configuration.

  • Examples: cp, mv, top.

4. Shell: The Command Interpreter

The shell is a command-line interface (CLI) that allows users to communicate with the kernel.

  • Function: Takes your input (commands) and tells the system what to do.

  • Popular Shells: Bash, Zsh, Fish.

5. Applications: The User-Level Software

These are programs that you interact with directly.

  • Examples: Web browsers, text editors, media players.

Basic to Advanced Shell Commands

Basic Commands

These commands help you navigate and manage files in a Linux system.

  1. pwd - Print the current working directory:

     pwd
    
  2. ls - List files and directories:

     ls -l
    
  3. cd - Change directories:

     cd /home/user/Documents
    
  4. mkdir - Create a new directory:

     mkdir my_folder
    
  5. rm - Remove files or directories (Be cautious, as deletion is irreversible):

     rm file.txt
     rm -r folder_name
    

    Warning: Running rm -rf / can delete all files on your system without prompting. Always double-check before using rm -r or rm -rf.

Intermediate Commands

  1. cp - Copy files and directories:

     cp file1.txt file2.txt
    
  2. mv - Move or rename files:

     mv oldname.txt newname.txt
    
  3. cat - View the contents of a file:

     cat file.txt
    
  4. grep - Search for text in a file:

     grep "search_term" file.txt
    
  5. chmod - Change file permissions:

    chmod 755 script.sh
    

Advanced Commands

  1. find - Search for files:

    find /home/user -name "*.txt"
    
  2. tar - Archive files:

    tar -cvf archive.tar file.txt folder/
    
  3. wget - Download files from the internet:

    wget http://example.com/file.zip
    
  4. top - Monitor system processes:

    top
    
  5. awk - Process and extract data from files:

    awk '{print $1}' file.txt
    

Package Management: Installing Software

Depending on your distribution, package managers help you install, update, and remove software.

  • Debian/Ubuntu (apt or apt-get):

    bash

      $ sudo apt update
      $ sudo apt install package-name
    
  • Red Hat/Fedora (dnf or yum):

    bash

      $ sudo dnf install package-name
    
  • Documentation: The man command is your friend.

    bash

      $ man command
    

Conclusion

Linux is a versatile and powerful operating system with a well-structured architecture. By mastering shell commands from basic to advanced levels, users can efficiently navigate, manage files, and perform system administration tasks.