File Operations
ls -la List all with details cd /path/to/dir Change directory pwd Print working directory cp src dest Copy file cp -r src dest Copy directory mv src dest Move/rename rm file Remove file rm -rf dir Remove directory mkdir -p path/to/dir Create directories touch file Create empty file ln -s target link Create symlink File Viewing
cat file Show file contents less file Paginate file head -n 20 file First 20 lines tail -n 20 file Last 20 lines tail -f file Follow file changes wc -l file Count lines diff file1 file2 Compare files Search & Find
find /path -name "*.log" Find by name find /path -type f -mtime -7 Modified last 7 days find /path -size +100M Files > 100MB grep "pattern" file Search in file grep -r "pattern" /path Search recursively grep -i "pattern" file Case insensitive locate filename Fast file search which command Find command path Permissions
chmod 755 file rwxr-xr-x chmod 644 file rw-r--r-- chmod +x file Add execute chmod -R 755 dir Recursive chown user:group file Change owner chown -R user:group dir Recursive owner Process Management
ps aux All processes ps aux | grep name Find process top Interactive process viewer htop Better process viewer kill PID Kill process kill -9 PID Force kill killall name Kill by name nohup cmd & Run in background jobs List background jobs fg %1 Bring job to foreground System Info
uname -a System info hostname Show hostname uptime System uptime free -h Memory usage df -h Disk usage du -sh /path Directory size lscpu CPU info lsblk Block devices dmesg | tail Kernel messages User Management
whoami Current user id User/group IDs useradd -m user Create user usermod -aG group user Add to group passwd user Set password su - user Switch user sudo command Run as root visudo Edit sudoers Archives
tar -czvf archive.tar.gz dir/ Create tar.gz tar -xzvf archive.tar.gz Extract tar.gz tar -tzvf archive.tar.gz List contents zip -r archive.zip dir/ Create zip unzip archive.zip Extract zip gzip file Compress file gunzip file.gz Decompress Systemd
systemctl status service Service status systemctl start service Start service systemctl stop service Stop service systemctl restart service Restart service systemctl enable service Enable at boot systemctl disable service Disable at boot journalctl -u service Service logs journalctl -f Follow all logs