Skip to main content

Command Palette

Search for a command to run...

DAY 2 - Basics Linux Commands

Introduction to Linux

Published
5 min readView as Markdown
DAY 2 - Basics Linux Commands
T

Hey there! 👋

I'm Tushar Ranjan, a DevOps Engineer passionate. Currently, on a learning adventure, I'm here to share my journey and Blogs in the world of cloud and DevOps.

🛠️ My focus? Making sense of AWS services, improving CI/CD, and diving into infrastructure as code. Whether you're fellow interns or curious enthusiasts, let's grow together in the vibrant DevOps space.

🌐 Connect with me for friendly chats, shared experiences, and learning moments. Here's to embracing the learning curve and thriving in the exciting world of AWS DevOps Technology!

What is Linux?

Linux is a powerful and popular operating system renowned for its stability, security, and versatility. Unlike commercial operating systems such as Windows or macOS, Linux is open-source, which means its source code is freely available to the public for use, modification, and distribution.

Benefits of using Linux?

There are numerous advantages to use Linux, but some of them are mentioned below: -

  • 1. Cost-Effective: Linux is free to use and distribute, which significantly reduces software costs, especially for businesses that need to deploy it across multiple systems.

  • 2. Stability and Reliability: Linux is known for its stability and reliability, often outperforming other operating systems in uptime and performance under heavy loads.

  • 3. Security: Linux is inherently more secure due to its strong user permissions model and the ability to quickly patch vulnerabilities by the open-source community.

  • 4. Flexibility and Customization: Linux offers a high degree of flexibility and customization, allowing users to tailor the operating system to their specific needs without unnecessary bloat.

  • 5. Compatibility: Linux supports a wide range of hardware platforms and architectures, making it versatile for various devices and systems, from servers to embedded devices.

  • 6. Community Support: Being open-source, Linux benefits from a large and active community of developers and users who contribute to its development, provide support, and share knowledge.

  • 7. Performance: Linux is known for its excellent performance, particularly in server environments where it can handle high workloads efficiently.

  • 8. Scalability: Linux scales well from small embedded devices to large-scale enterprise servers, making it suitable for growth and expansion.

  • 9. Open-Source Ecosystem: Linux offers access to a vast ecosystem of open-source software and tools, empowering users with a wealth of options for development and customization.

  • 10. Long-Term Support (LTS): Many Linux distributions offer long-term support releases, providing stability and security updates for extended periods, which is crucial for enterprise environments.

Architecture of Linux

The architecture of the Linux system is a layered structure that comprises several components, each with a specific function.

The main components of Linux operating system are:

  1. Application: This is the topmost layer of the Linux architecture and consists of the various applications that run on top of the operating system and interact with its components.

  2. Shell: The shell is a command-line interface that allows users to interact with the system through a set of commands.

  3. Kernel: The kernel is the central component of the Linux operating system architecture. It manages system resources and provides services to applications and processes running on the system.

  4. Hardware: This is the bottommost layer of the Linux architecture and represents the physical hardware components of the computer, such as the processor, memory, and storage. The hardware layer is responsible for interacting with the various hardware devices and providing access to them for the rest of the operating system.

Basic Linux Commands

Listing Commands

ls

  • Description: List directory contents.

  • Examples:

    • ls: Lists files and directories in the current directory.

        ubuntu@ip-172-31-10-117:~/test$ ls
        file1.txt  file2.jpg  folder1  folder2
      
    • ls -l: Lists files and directories in long format with detailed information.

        ubuntu@ip-172-31-10-117:~/test$ ls -l
        total 8
        -rw-r--r-- 1 user user  12 Jun 24 10:15 file1.txt
        -rw-r--r-- 1 user user 208 Jun 24 10:15 file2.jpg
        drwxr-xr-x 2 user user  64 Jun 24 10:15 folder1
        drwxr-xr-x 2 user user  64 Jun 24 10:15 folder2
      
    • ls -a: Lists all files and directories, including hidden ones.

        ubuntu@ip-172-31-10-117:~/test$ ls -a
        .  ..  file1.txt  file2.jpg  .hiddenfile  folder1  folder2
      
    • ls *.sh: Lists files with .sh extension.

        ubuntu@ip-172-31-10-117:~/test$ ls *.sh
        script1.sh  script2.sh
      
    • ls -lhirt: Lists files and directories with inode numbers.

        ubuntu@ip-172-31-10-117:~/test$ ls -lhirt
        total 8.0K
        262359 -rw-rw-r-- 1 ubuntu ubuntu    0 Jun 24 15:53 file1.txt
        262360 -rw-rw-r-- 1 ubuntu ubuntu    0 Jun 24 15:53 file2.jpg
        262391 drwxrwxr-x 2 ubuntu ubuntu 4.0K Jun 24 15:53 folder1
        262392 drwxrwxr-x 2 ubuntu ubuntu 4.0K Jun 24 15:53 folder2
      

Directory Commands

pwd

  • Description: Print the current working directory.

  • Example:

      ubuntu@ip-172-31-10-117:~/test$ pwd
      /home/ubuntu/test
      ubuntu@ip-172-31-10-117:~/test$
    

cd

  • Description: Change directory.

  • Examples:

    • cd path_to_directory: Changes to the specified directory.

        ubuntu@ip-172-31-10-117:~/test$ cd /home/ubuntu
      
    • cd ~ or cd: Changes to the home directory.

        ubuntu@ip-172-31-10-117:~/test$ cd
        ubuntu@ip-172-31-10-117:~$
      
    • cd ..: Moves one directory level up.

        ubuntu@ip-172-31-10-117:~/test$ pwd
        /home/ubuntu/test
        ubuntu@ip-172-31-10-117:~/test$ cd ..
        ubuntu@ip-172-31-10-117:~$ pwd
        /home/ubuntu
      
    • cd ../..: Moves two directory levels up.

        ubuntu@ip-172-31-10-117:~/test$ pwd
        /home/ubuntu/test
        ubuntu@ip-172-31-10-117:~/test$ cd ../..
        ubuntu@ip-172-31-10-117:/home$ pwd
        /home
      

mkdir

  • Description: Create a new directory.

  • Examples:

    • mkdir newFolder: Creates a new directory named 'newFolder'.

        ubuntu@ip-172-31-10-117:~$ mkdir newFolder
        ubuntu@ip-172-31-10-117:~$ ls -ld newFolder
        drwxrwxr-x 2 ubuntu ubuntu 4096 Jun 24 15:58 newFolder
      
    • mkdir .NewFolder: Creates a hidden directory named '.NewFolder'.

        ubuntu@ip-172-31-10-117:~$ mkdir .NewFolder
        ubuntu@ip-172-31-10-117:~$ ls -ald .NewFolder/
        drwxrwxr-x 2 ubuntu ubuntu 4096 Jun 24 15:58 .NewFolder/
      
    • mkdir A B C D: Creates multiple directories 'A', 'B', 'C', and 'D'.

        ubuntu@ip-172-31-10-117:~$ mkdir A B C D
        ubuntu@ip-172-31-10-117:~$ ls -ld A B C D
        drwxrwxr-x 2 ubuntu ubuntu 4096 Jun 24 16:00 A
        drwxrwxr-x 2 ubuntu ubuntu 4096 Jun 24 16:00 B
        drwxrwxr-x 2 ubuntu ubuntu 4096 Jun 24 16:00 C
        drwxrwxr-x 2 ubuntu ubuntu 4096 Jun 24 16:00 D
        ubuntu@ip-172-31-10-117:~$
      
    • mkdir /home/ubuntu/Mydirectory: Creates a directory 'Mydirectory' in the specified location.

        ubuntu@ip-172-31-10-117:~$ mkdir /home/ubuntu/Mydirectory
        ubuntu@ip-172-31-10-117:~$ ls -ld /home/ubuntu/Mydirectory
        drwxrwxr-x 2 ubuntu ubuntu 4096 Jun 24 16:01 /home/ubuntu/Mydirectory
        ubuntu@ip-172-31-10-117:~$
      
    • mkdir -p A/B/C/D: Creates nested directories 'A/B/C/D' if they don't exist.

        ubuntu@ip-172-31-10-117:~$ mkdir -p A/B/C/D
      

These basic Linux commands are essential for navigating the file system, managing directories, and listing file contents. They are foundational for everyday tasks when working with a Linux operating system.

Conclusion

Linux is a strong and adaptable operating system that's free to use and modify. It's known for its stability, security, flexibility, and affordability. You can customize it extensively and run many different types of software. Linux is widely used across industries and has a large community of supporters. It's especially popular for servers, running much of the internet, and it's gaining popularity for desktop and mobile use too.

Overall, Linux is a dependable and effective option for anyone looking for a robust operating system.

~ Tushar Ranjan🙂

More from this blog

Tushar Ranjan's blog

72 posts