Basic Shell Commands
A reference for the most common Linux shell commands.
File Operations
ls: List directory contents.ls -la: List all files (including hidden) with details.
cd <dir>: Change directory.cd ..: Go up one level.cd ~: Go to home directory.
cp <source> <dest>: Copy files or directories.cp -r: Copy recursively.
mv <source> <dest>: Move or rename files.rm <file>: Remove file.rm -r <dir>: Remove directory.rm -rf <path>: Force remove (careful!).
mkdir <dir>: Create directory.mkdir -p /path/to/dir: Create nested directories.
touch <file>: Create an empty file or update timestamp.
File Viewing & Editing
cat <file>: Print file content to terminal.less <file>: View file content page by page.nano <file>: Simple terminal text editor.vim <file>: Advanced terminal text editor.grep "pattern" <file>: Search for text in a file.grep -r "pattern" .: Search recursively in current directory.
Permissions
chmod <perms> <file>: Change file mode (permissions).chmod +x script.sh: Make executable.chmod 755 file: Owner rwx, others rx.
chown <user>:<group> <file>: Change file owner and group.chown -R user:group dir/: Change recursively.
System Info
htop: Interactive process viewer.df -h: Disk space usage (human readable).du -sh <dir>: Directory size usage.free -h: Memory usage.ip a: Show network interfaces and IP addresses.