Basic Linux Commands: A Quick Guide for Beginners

Linux provides a wide array of commands that allow users to navigate the system, manage files, and interact with directories efficiently. In this post, we will explore listing commands and directory commands that are frequently used, with explanations and practical examples.

Listing Commands

Listing commands help you view files and directories in the current working directory. By using various options and flags, you can customize how information is displayed.

  • ls option_flag arguments
    Used to list the subdirectories and files available in the current directory.

Examples:

  1. ls -l
    Lists the files and directories in long format with extra information, such as permissions, owner, and size.

     ls -l
    
  2. ls -a
    Lists all files, including hidden files and directories.

     ls -a
    
  3. ls \.sh Lists all files with the* .sh extension.

     ls *.sh
    
  4. ls -i
    Lists files and directories with their inode numbers.

     ls -i
    
  5. ls -d\ / Lists only directories in the current directory (you can also specify a pattern).*

     ls -d */
    

Directory Commands

Managing directories efficiently is key to mastering Linux. Below are some essential commands that help you navigate and manage directories:

  1. pwd
    Prints the current working directory.

     pwd
    
  2. cd path_to_directory
    Changes the current directory to the specified path.

     cd /home/user/Documents
    
  3. cd
    Changes the directory to the home directory.

     cd
    
  4. cd -
    Returns to the last working directory.

     cd -
    
  5. cd ..
    Moves up one directory level.

     cd ..
    
  6. cd ../..
    Moves up two levels in the directory tree.

     cd ../..
    
  7. mkdir directoryName
    Creates a directory in a specified location.

Examples:

  • mkdir newFolder
    Creates a new folder named newFolder.

      mkdir newFolder
    
  • mkdir .NewFolder
    Creates a hidden folder (adding . before the folder name makes it hidden).

      mkdir .NewFolder
    
  • mkdir A B C D
    Creates multiple directories (A, B, C, D) at the same time.

      mkdir A B C D
    
  • mkdir /home/user/MyDirectory
    Creates a new folder in a specific location.

      mkdir /home/user/MyDirectory
    
  • mkdir -p A/B/C/D
    Creates nested directories in one command.

      mkdir -p A/B/C/D
    

Conclusion

Mastering these basic Linux commands can enhance your ability to navigate and manage files in your Linux environment.

0
Subscribe to my newsletter

Read articles from sravani punreddy directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

sravani punreddy
sravani punreddy