Hereβs a clear explanation of basic Linux commands with examples for each:
1. ls (List Directory Contents)
Purpose: Lists files and directories in the current folder.
Common Options:
ls -lβ Detailed list (permissions, owner, size, date)ls -aβ Shows hidden files (starting with.)ls -hβ Human-readable file sizes (KB, MB)
Example:
ls -lah # Lists all files (including hidden) in detailed, readable format2. cd (Change Directory)
Purpose: Moves you into a different directory.
Common Usage:
cd /path/to/folderβ Absolute pathcd folder_nameβ Relative pathcd ..β Go up one levelcd ~orcdβ Go to home directory
Example:
cd Documents/Projects # Enters the "Projects" folder inside "Documents"3. mkdir (Make Directory)
Purpose: Creates a new directory (folder).
Common Options:
mkdir -p parent/childβ Creates nested directories at once.
Example:
mkdir new_folder # Creates "new_folder"
mkdir -p dir1/dir2 # Creates "dir1" and "dir2" inside it4. rm (Remove Files/Directories)
Purpose: Deletes files or directories.
Common Options:
rm file.txtβ Deletes a file.rm -r folder/β Deletes a directory recursively (use with caution!).rm -fβ Forces deletion (no confirmation).
Example:
rm old_file.txt # Deletes "old_file.txt"
rm -r old_folder/ # Deletes "old_folder" and its contents5. cp (Copy Files/Directories)
Purpose: Copies files or directories.
Common Options:
cp file.txt new_location/β Copies a file.cp -r folder/ backup/β Copies a directory recursively.
Example:
cp notes.txt ~/Backups/ # Copies "notes.txt" to the "Backups" folder
cp -r project/ backup/ # Copies the entire "project" folder6. mv (Move/Rename Files/Directories)
Purpose: Moves files/directories or renames them.
Common Usage:
mv file.txt new_name.txtβ Renames a file.mv file.txt /target/path/β Moves a file.
Example:
mv old.txt new.txt # Renames "old.txt" to "new.txt"
mv file.txt ~/Documents/ # Moves "file.txt" to "Documents"