Linux Unveiled: Exploring the Heart of Open-Source Operating Systems

What is Linux? ๐Ÿง

Linux is an open-source operating system (OS) that powers everything from personal computers to servers, smartphones, and even supercomputers! ๐ŸŒ Itโ€™s known for its stability, security, and flexibility. Unlike proprietary systems like Windows or macOS, Linux is freely available for anyone to use, modify, and distribute.

Imagine having a car you can modify to suit your needs without any restrictions. Thatโ€™s what Linux offers in the world of operating systems.

Difference Between Linux and Unix ๐Ÿ”

While Linux and Unix may seem similar, there are key differences:

  • Origin: Unix was developed in the 1970s at AT&Tโ€™s Bell Labs, while Linux was created by Linus Torvalds in 1991.

  • Licensing: Unix is often proprietary, meaning you need to purchase it. Linux, on the other hand, is open-source and free.

  • Usage: Unix is typically used in large enterprise environments, whereas Linux is used in both enterprise and personal environments.

  • Compatibility: Unix systems can be quite different from each other, whereas Linux distributions (like Ubuntu, Fedora, etc.) maintain a high level of compatibility.

Imagine Unix as the blueprint for a house and Linux as a house built from that blueprint but freely available to modify and improve by anyone. ๐Ÿก

Linux Architecture ๐Ÿ—๏ธ

The Linux architecture is composed of several layers that work together to manage the computerโ€™s hardware and provide services to the user.

  • Hardware Layer ๐Ÿ–ฅ๏ธ This is the physical layer that includes all the hardware components like the CPU, memory, disk drives, etc.

  • Kernel ๐Ÿง  The kernel is the core part of Linux. It acts as a bridge between the hardware and the applications. It manages resources, handles system calls, and ensures everything runs smoothly. Think of it as the brain of the operating system.

  • Shell ๐Ÿš The shell is a command-line interface that allows users to interact with the kernel. It takes commands from the user and tells the kernel what to do. Itโ€™s like a translator between you and the system.

  • System Utilities ๐Ÿ”ง These are essential tools and programs that help manage and maintain the system. They perform a variety of tasks like file manipulation, process management, and more.

  • Application Layer ๐Ÿ“ฑ This is where all user applications run, like web browsers, office suites, and games.

Linux File System Hierarchy ๐Ÿ“‚

The Linux file system is structured in a hierarchical directory tree. Here are some key directories youโ€™ll encounter:

Linux Directory Structure - GeeksforGeeks

  • /: The root directory where everything starts.

  • /bin: Essential binary executables (like basic commands).

  • /etc: Configuration files.

  • /home: User home directories.

  • /var: Variable files like logs and databases.

  • /usr: User utilities and applications.

  • /lib: Essential shared libraries and kernel modules.

Think of the file system hierarchy like an organizational chart for a company, with directories for each department and specific roles within those directories.

Some basic commands

  1. Lists files and directories in the current directory.

     ls
    
  2. Creates a new directory with the specified name.

     mkdir <directory_name>
    
  3. Lists files and directories with detailed information (long format).

     ls -l
    
  4. Prints the current working directory.

     pwd
    
  5. Creates a new empty file or updates the timestamp of an existing file.

     touch <file_name>
    
  6. The cd command changes the current directory. cd / takes you to the root directory, and cd .. moves you up one level in the directory hierarchy.

     cd <directory_name>   # Change to the specified directory
     cd /                  # Change to the root directory
     cd ..                 # Move up one directory level
    
  7. To remove the file and the folder related to that file recursively

     rm <file_name>          # Deletes the specified file.
     rm -r <directory_name>  #Deletes the specified directory and its contents recursively.
    
  8. Displays the contents of a file.

     cat <file_name>
    
  9. Outputs the specified text to the terminal.

     echo "text"
    
  10. Writes "hello world" to newfile.txt, creating the file if it doesn't exist or overwriting it if it does.

    echo "hello world" > newfile.txt
    
  11. Displays the contents of a compressed file (gzip format) without decompressing it.

    zcat <compressed_file.gz>
    
  12. Shows the first 10 lines of a file by default.

    head <file_name>
    
  13. Shows the last 10 lines of a file by default.

    tail <file_name> 
    or
    tail  -f <file_name> # -f shows all the last 10 lines even after we update the file
    
  14. Allows you to view and scroll through a file one screen at a time.

    less <file_name>
    
  15. Displays file contents one screen at a time (older command, similar to less).

    more <file_name>
    
  16. Copies files or directories from source to destination.

    cp <source> <destination>
    
  17. Copies directories recursively, including all files and subdirectories.

    cp -r <source_directory> <destination_directory>
    
  18. Moves or renames files or directories from source to destination.

    mv <source> <destination>
    
  19. Displays the number of lines, words, and characters in a file.

    wc <file_name>
    
    -l: Counts the number of lines.
    -w: Counts the number of words.
    -c: Counts the number of characters (or bytes).
    
  20. Extracts sections from each line of a file based on the specified delimiter and field number. Replace <delimiter> with the actual delimiter.

    cut -d '<delimiter>' -f <field_number> <file_name>
    
  21. Reads from standard input and writes to both standard output and the specified file.

    tee <file_name>
    eg: echo "hello world" | tee
             or
        echo "hello world" | tee <file.txt>
    
  22. Sorts the lines of a file in alphabetical or numerical order.

    sort <file_name>
    
  23. Compares two files line by line and shows the differences.

    diff <file1> <file2>
    
  24. Opens a file in the vi text editor for editing.

    vi <file_name>
       or            #to exit from the editor first click on esc then type:wq
    vim <file_name>
    
  25. To see disk information and disk usage.

    df or df -h
    du
    
  26. To see all the process.

    top or ps
    
  27. Kill the process.

    kill
    eg. kill -a 'process id'
    
  28. Shows free disk space.

    free or free -h
    
0
Subscribe to my newsletter

Read articles from Kiran Ramakrishna Dunka directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Kiran  Ramakrishna Dunka
Kiran Ramakrishna Dunka