Shell Commands for Directory Management

list of commonly used shell commands for directory management:

  1. mkdir: Create a new directory.

Example: mkdir mydir will create a new directory called "mydir" in the current directory.

 

  1. rmdir: Remove an empty directory.

Example: rmdir mydir will remove the directory called "mydir" if it is empty.

 

  1. rm: Remove files and directories.

Example: rm myfile.txt will delete the file called "myfile.txt". rm -r mydir will remove the directory "mydir" and its contents recursively.

 

  1. mv: Move or rename files and directories.

Example: mv myfile.txt newfile.txt will rename the file "myfile.txt" to "newfile.txt". mv myfile.txt /path/to/destination will move the file "myfile.txt" to the specified destination.

 

  1. cp: Copy files and directories.

Example: cp myfile.txt mydir/ will copy the file "myfile.txt" to the directory "mydir".

 

  1. cd: Change directory. It is used to navigate between directories.

Example: cd Documents will change the current directory to "Documents".

 

  1. ls: List files and directories in the current directory.

Example: ls will list the files and directories in the current directory.

 

  1. pwd: Print the current working directory.

Example: pwd will display the current directory path.

 

  1. tree: Display the directory structure as a tree.

Example: tree will show the directory structure starting from the current directory.

 

  1. find: Search for files and directories.

Example: find /path/to/search -name myfile.txt will search for the file "myfile.txt" in the specified path.

Each command has additional options and flags that can be used to customize their behaviour. You can refer to the manual pages for each command by using the man command followed by the command name ( e.g., man ls) to get more detailed information about their usage.

 


Posted

in

by

Tags: