This page covers essential Linux commands to navigate, list, move, copy, and delete files and directories.
cd — Change DirectorySyntax:
cd [directory]
Examples:
cd /home/user/Documents # Go to specific directory
cd .. # Go up one level
cd ~ # Go to home directory
cd - # Go to previous directory
ls — List Directory ContentsSyntax:
ls [options] [directory]
Common examples:
ls # List files in current directory
ls -l # Long listing (detailed info)
ls -a # Show hidden files
ls -lh # Human-readable file sizes
ls /etc # List contents of /etc directory
mv — Move or Rename Files/DirectoriesSyntax:
mv [source] [destination]
Examples:
mv file.txt /tmp/ # Move file to /tmp
mv oldname.txt newname.txt # Rename a file
mv *.jpg images/ # Move all .jpg files to images/
cp — Copy Files or DirectoriesSyntax:
cp [options] source destination
Examples:
cp file.txt backup.txt # Copy file
cp file1.txt file2.txt dir/ # Copy multiple files to directory
cp -r folder1/ folder2/ # Copy directory recursively
cp -i file.txt /etc/ # Prompt before overwriting
rm — Remove Files or DirectoriesSyntax:
rm [options] target
Examples:
rm file.txt # Delete a file
rm -i file.txt # Prompt before deletion
rm -r folder/ # Delete folder and its contents
rm -rf folder/ # Force delete without prompt (dangerous!)
rm -rf / # This can erase your entire system. Use commands carefully.
Always double-check paths when using mv, cp, or rm.
| Command | Description |
|---|---|
cd |
Change directory |
ls |
List files and folders |
mv |
Move or rename files/folders |
cp |
Copy files or directories |
rm |
Delete files or directories |
Use Tab for auto-completion and man <command> to view manual pages:
man ls
man cp
man rm