Day 2 Task: Basics and Fundamentals of linux commands

Here's a brief overview of some basic Linux commands:

  1. ls

    To list the files and directories in the current working directory. And adding options like -l or -a (including hidden files) provides more details.

    • ls - To list the files and directories in the current working directory.
    ubuntu@ip-172-31-44-248:~$ ls 
    file1  file2  file3  file4  file5
  • ls -l (long list format)
    ubuntu@ip-172-31-47-226:~$ ls -l
    total 16
    drwxrwxr-x 2 ubuntu ubuntu 4096 Jul  4 19:04 dir1
    drwxrwxr-x 2 ubuntu ubuntu 4096 Jul  4 19:09 dir2
    drwxrwxr-x 2 ubuntu ubuntu 4096 Jul  4 19:09 dir3
    drwxrwxr-x 2 ubuntu ubuntu 4096 Jul  4 19:09 dir4
  • ls -a To see all the hidden files and directory.
    ubuntu@ip-172-31-47-226:~$ ls -a
    .  ..  .bash_logout  .bashrc  .cache  .profile  .ssh  dir1  dir2  dir3
  • pwd

    This command prints the present the current working directory. It's useful for knowing your present location within the file system

    ubuntu@ip-172-31-47-226:~$ pwd
    /home/ubuntu
  1. cd

    Used to change working directory

      ubuntu@ip-172-31-47-226:~$ cd dir1
      ubuntu@ip-172-31-47-226:~/dir1
    
  2. mkdir

    To create a directory:

ubuntu@ip-172-31-44-248:~$ mkdir dir1
  1. cd ..

    change directory to one step back.

ubuntu@ip-172-31-47-226:~/dir1$ cd ..
ubuntu@ip-172-31-47-226:~$
  1. cd ../..

    change directory to two steps back.

      ubuntu@ip-172-31-47-226:~/dir1$ cd ../..
      ubuntu@ip-172-31-47-226:/home$
    
  2. To create hidden directory

      ubuntu@ip-172-31-47-226:~$ mkdir .dir5
      ubuntu@ip-172-31-47-226:~$ ls -a
      .  ..  .bash_logout  .bashrc  .cache  .dir5  .profile  .ssh  dir1
    
  3. cd -

    To go to the last working directory.

      ubuntu@ip-172-31-47-226:~$ cd -
      /home
    
  4. cd path_to_directory

    change directory to the provided path

      ubuntu@ip-172-31-47-226:/home$ cd ubuntu/dir1
      ubuntu@ip-172-31-47-226:~/dir1$
    
  5. chmod ->Modifies a file’s read, write, and execute permissions

  6. chown -> Changes a file, directory, or symbolic link’s ownership

  7. df

    Displays the system’s overall disk space usage

    ubuntu@ip-172-31-47-226:~$ df
    Filesystem     1K-blocks    Used Available Use% Mounted on
    /dev/root        7034376 1606200   5411792  23% /
    tmpfs             490212       0    490212   0% /dev/shm
    tmpfs             196088     868    195220   1% /run
    tmpfs               5120       0      5120   0% /run/lock
    /dev/xvda16       901520   76972    761420  10% /boot
    /dev/xvda15       106832    6246    100586   6% /boot/efi
    tmpfs              98040      12     98028   1% /run/user/1000
    
  8. grep

    Searches a string within a file

  9. cat

    To create files, see contents of file

  10. touch

    To create a new empty file

  11. mv

    To Move or rename files and directories

  12. cp

    To copy files and directories, including their content

  13. history

    To list previous commands that we run

    ubuntu@ip-172-31-47-226:~$ history
        1  pwd
        2  mkdir dir1
        3  cd dir1
        4  cd ..
        5  ls
        6  ls -l
        7  mkdir dir2 dir3 dir4
        8  ls
        9  ls -l
       10  ls -a
       11  cd dir1
       12  cd dir2
       13  ls
       14  cd ../.. 
       15  cd ubuntu
       16  ls
       17  mkdir .dir5
       18  ls
       19  ls -a
       20  cd -
       21  cd ~
       22  cd ..
       23  ls
       24  cd ubuntu/dir1
       25  cd ..
       26  history
       27  chown
       28  df
    
0
Subscribe to my newsletter

Read articles from Yuvraj Nath Chouhan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Yuvraj Nath Chouhan
Yuvraj Nath Chouhan

🚀 Aspiring DevOps & DevSecOps Engineer | Cloud DevOps (Azure & AWS) | Automation & Security Champion | Passionate Learner🌐 Hi, I’m Yuvraj! 🔥 I'm embarking on an exciting journey in the world of DevOps & DevSecOps, armed with hands-on expertise and a drive to excel. From automating tasks to building robust CI/CD pipelines, I’m dedicated to turning complex challenges into efficient and secure solutions. What I Bring to the Table: ●Linux & Shell Scripting 🖥️ Automating processes and mastering command-line operations. ●Git & Git Branching 🔀 Seamless version control for effective collaboration. ●Build Tools 🔧 (Maven & npm) Crafting stable builds for quality software. ●CI/CD Tools 🚄 (Jenkins, GitHub Actions, Azure DevOps, GitLab CI/CD) Ensuring smooth & automated deployments. ●Security in DevOps 🛡️ Embedding security at every stage to safeguard development processes. ●Artifact Management 📦 (Nexus & Azure Artifacts) Managing software versions efficiently. ●Containerization & Orchestration 🐳⎈ (Docker & Kubernetes) Deploying scalable, agile applications. ●Infrastructure as Code (IaC) 📜 (Terraform & Ansible) Automating environment provisioning. ●Monitoring & Troubleshooting 🔍 Keeping systems in check with proactive issue resolution. ●Real-world & Corporate Projects 🌟 Hands-on experience with practical implementations. ✨ Always eager to learn, collaborate, and innovate! ✨ I’m ready to transform my academic knowledge and project experiences into real-world impact. Let’s connect and explore how we can drive meaningful change together! 🤝