Basic Linux Command Line Guide
FILE & DIRECTORY MANAGEMENT
---------------------------
ls - List files in current directory
ls -l - Long listing format
cd <dir> - Change directory
pwd - Print working directory
mkdir <dir> - Create a directory
rmdir <dir> - Remove empty directory
rm <file> - Remove file
rm -r <dir> - Remove directory recursively
cp <src> <dest> - Copy file/directory
mv <src> <dest> - Move or rename file/directory
touch <file> - Create an empty file
FILE VIEWING & EDITING
---------------------------
cat <file> - View file content
less <file> - View file with scroll (q to quit)
head <file> - First 10 lines of file
tail <file> - Last 10 lines of file
nano <file> - Edit file in nano editor
vim <file> - Edit file in vim editor
SEARCHING & FINDING
---------------------------
find <path> -name <file> - Find file by name
grep "text" <file> - Search text in file
grep -r "text" <dir> - Search recursively
SYSTEM INFORMATION
---------------------------
whoami - Current user
hostname - System hostname
top - Running processes (press q to quit)
df -h - Disk space usage
free -h - Memory usage
PERMISSIONS & OWNERSHIP
---------------------------
chmod +x <file> - Make file executable
chmod 755 <file> - Set file permissions (rwxr-xr-x)
chown user:group <file> - Change file ownership
PACKAGE MANAGEMENT (Ubuntu/Debian)
---------------------------
sudo apt update - Refresh package index
sudo apt upgrade - Upgrade installed packages
sudo apt install <pkg> - Install a package
sudo apt remove <pkg> - Remove a package
ARCHIVES & COMPRESSION
---------------------------
tar -cvf file.tar dir/ - Create tar archive
tar -xvf file.tar - Extract tar archive
tar -czvf file.tar.gz dir/ - Create gzip compressed tarball
tar -xzvf file.tar.gz - Extract gzip tarball
unzip file.zip - Extract zip file
OTHER USEFUL COMMANDS
---------------------------
history - Show command history
clear - Clear terminal screen
echo "text" - Print text to terminal
man <command> - Manual page for command (q to quit)
alias ll='ls -l' - Create shortcut command