Linux/Unix Directory Management Commands

Shankar Modi
3 min readApr 11, 2021

Directories management becomes easy if you know the right command in Linux/Unix.

Directory management in linux

Let’s learn some basic commands with examples and explanations.

Directory Management

  1. pwd: This command will display the present working directory where you are currently in.
pwd

2. mkdir: This command will create a directory if not exists

mkdir

3. mkdir -p: Create nested directories.

4. rmdir: This command will delete an empty directory. If you delete a non-empty directory with this command, it will give a “Directory not empty ” error

5. rm -r: This command deletes current and subdirectories

6. cd: Change directory

7. mv: To rename the directory

8. ls: List the file and sub-directories of the current directory.

9. ls -a: When we use ls command with -a flag, it will list the content of the current directory, the current directory (.), and the parent directory (..)

10. ls -l: ls command with -l flag will display more information, like permissions, memory block, etc.

1st Column: File type and permissions, if the First character is d then the type is a directory, if the first character is (-) then the type is file.

2nd Column: No. of Hard links

3rd Column: Owner of the file

4th Column: Usergroup

5th Column: Size in Bytes

6th Column: Creation date and time.

7th Column: File/Directory name

11. ls -r: When ls command used with -r flag, the content will be displayed in reverse order.

--

--