ls – List contents of current directory
ls -a – List all files including hidden
ls -la – List all with details (permissions, size, timestamp)
cp source dest – Copy file
cp -R dir1 dir2 – Copy directory recursively
mv oldname newname – Move or rename file or directory
mkdir dirname – Create directory
rmdir dirname – Delete empty directory
rm filename – Delete file
rm -rf dirname – Delete directory recursively
cd /path – Change to directory
cd .. – Move to parent directory
cd ~ – Move to home directory
cd - – Switch to previous directory
pwd – Show current directory
nano filename – Edit file using nano
pico filename – Edit file using pico (older systems)
tar -zcf archive.tar.gz file_or_dir – Create compressed tarball
tar -zxpf file.tar.gz – Extract .tar.gz
tar -xpf file.tar – Extract .tar
gunzip file.gz – Uncompress .gz
find / -user username – Find files owned by user
whereis command – Locate binary/source/man page
updatedb – Update file locate database
locate filename – Fast file lookup
df -c – Disk usage
quota – Show disk quota
uptime – Show system uptime
uname -a – Show OS info
whoami – Show current user
who – List logged-in users
last – Show last logins
ps – Show running processes
ps -x – Show current user processes
ps aux – Show all processes
top – Live process monitor (press q to quit)
sar -q – System load averages every 10 mins
netstat -np – Show active connections
kill PID – Kill process by PID
kill -9 PID – Force kill process
killall name – Kill all processes by name or user
ftp server.com – Connect to FTP
lynx url – View webpage in terminal
service servicename start|stop|restart|status – CentOS 6
systemctl start|stop|restart|status servicename – CentOS 7+
Common services:
httpd, mysql, named, exim, cpanel, proftpd, crond, chkservd, bandmin
crontab -e – Edit root/user’s cron jobs
crontab -u username -e – Edit another user’s cron jobs
mail – Check local mail
/scripts/pkgacct2 username – Manual backup
/scripts/restorepkg username – Restore backup
/scripts/killacct username – Terminate account
/scripts/suspendacct username – Suspend account
/scripts/unsuspendacct username – Unsuspend account
/scripts/editquota username – Edit disk quota
/scripts/fixinterchange – Fix Interchange issues
/scripts/fixwebalizer – Fix stats
/scripts/restartsrv servicename – Restart service
/scripts/mailperm – Fix mail permissions
/scripts/mysqlpasswd – Change MySQL password
/scripts/findtrojans – Scan for trojans
/scripts/fixtrojans – Remove trojans
tail -n filename – View last n lines of file
--help – View help for most commands (e.g., tar --help)
reboot – Reboot server
mv – Also used to rename directories
Delete MRTG:
rpm -e --nodeps \ $(rpm -q | grep mrtg)
Clear /tmp folder:
rm -Rf /tmp/c*
rm -Rf /tmp/s*
rm -Rf /tmp/p*
rm -Rf /tmp/*_*
rm -Rf /tmp/*-*
Add Comment