Essential Linux Commands for Efficient File and Directory Management

Are you new to Linux or looking to enhance your command-line skills? Mastering basic commands for navigating and organizing files and directories is crucial. Let's dive into some essential Linux commands that will help you become more proficient in managing your system.

Understanding Directory Listings

ls Command:

  1. ls: Lists all files and directories in the current folder.

  2. ls -l: Shows detailed information about files and directories in a long list format.

  3. ls -a: Displays all files, including hidden ones (those starting with a dot .).

  4. ls *.sh: Lists files with names ending in .sh (shell scripts).

  5. ls -i: Lists files and directories along with their inode numbers (unique identifiers).

  6. ls -d */: Shows only directories within the current directory.

Navigating Directories:

Directory Navigation:

  1. pwd: Displays the path of the current directory (Present Working Directory).

  2. cd path_to_directory: Moves to the specified directory path.

  3. cd ~ or just cd: Takes you back to your home directory.

  4. cd -: Returns to the previous directory you were in.

  5. cd ..: Moves up one directory level (parent directory).

  6. cd ../../: Jumps up two directory levels.

Creating Directories:

  1. mkdir directoryName: Creates a new directory in the current location.

  2. mkdir .NewFolder: Makes a hidden directory (starting with a dot).

  3. mkdir A B C D: Creates multiple directories at once.

  4. mkdir /home/user/Mydirectory: Makes a directory in a specific path.

  5. mkdir -p A/B/C/D: Creates nested directories recursively.

0
Subscribe to my newsletter

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

Written by

Pankaj Chaudhari
Pankaj Chaudhari

Experienced Software Engineer with over 1 year of expertise in backend development, microservices architecture, and cloud-native applications. Skilled in Java, Spring Boot, AWS, Docker, and Kubernetes. Proficient in deploying, scaling, and managing applications. Ready to contribute technical excellence to collaborative software development teams.