Linux Server Commands Basic Handbook

📁 Section 1: Navigation & File Management

CommandDescriptionExample
pwdShow current directorypwd/home/megahost
ls -lahList files with sizes and permissionsls -lah /var/www
cdChange directorycd /etc/nginx
mkdir -pCreate nested directoriesmkdir -p /var/www/html/assets
touchCreate empty filetouch README.md
cpCopy files or folderscp config.conf /backup/
mvMove or renamemv old.conf new.conf
rm -rfRemove recursivelyrm -rf /tmp/cache
treeVisualize directory structuretree /var/www/html

🧭 Purpose: Navigate directories, inspect contents, and manage files with confidence.


🛠️ Walkthrough

pwd
ls -lah /var/www
cd /etc/nginx
mkdir -p /var/www/html/assets
touch /var/www/html/index.html
cp /etc/nginx/nginx.conf /backup/nginx.conf
mv /backup/nginx.conf /backup/nginx.bak
rm -rf /tmp/cache

✅ Test Command

ls -lah /var/www/html

⚙️ Section 2: Process Control

CommandDescriptionExample
ps auxList all running processesps aux | grep nginx
top / htopLive system monitorhtop
killTerminate process by PIDkill 1234
killallTerminate by namekillall apache2
nice / reniceSet process priorityrenice -n -5 -p 1234
systemctlManage servicessystemctl restart nginx

🧭 Purpose: Monitor and manage running processes and services.

🛠️ Walkthrough

ps aux | grep nginx
top
killall nginx
systemctl restart nginx
systemctl status nginx

✅ Test Command

systemctl is-active nginx

Expected Output:

active

🔐 Section 3: Permissions & Ownership

CommandDescriptionExample
chmodChange permissionschmod 644 index.html
chownChange ownershipchown www-data:www-data /var/www/html
statView file metadatastat config.php
umaskDefault permission maskumask 022

📦 Section 4: Package Management

CommandDescriptionExample
apt updateRefresh package listapt update
apt upgradeUpgrade packagesapt upgrade -y
apt installInstall packageapt install htop
apt removeUninstall packageapt remove apache2
dpkg -lList installed packagesdpkg -l | grep nginx

🌐 Section 5: Networking Tools

CommandDescriptionExample
ip aShow IP addressesip a
pingTest connectivityping 8.8.8.8
curlFetch URLscurl -I https://megahost.xyz
netstat -tulnShow listening portsnetstat -tuln
ss -tulnModern netstat alternativess -tuln
tracerouteTrace network pathtraceroute google.com
dig / nslookupDNS lookupdig megahost.zone

💽 Section 6: Disk & RAID Monitoring

CommandDescriptionExample
df -hDisk usagedf -h /dev/nvme0n1p1
du -shFolder sizedu -sh /var/log
lsblkBlock deviceslsblk -o NAME,SIZE,TYPE,MOUNTPOINT
smartctl -aSMART healthsmartctl -a /dev/sda
cat /proc/mdstatRAID statuscat /proc/mdstat
mdadm --detailRAID array infomdadm --detail /dev/md0

🧾 Section 7: System Info & Logs

CommandDescriptionExample
uname -aKernel infouname -a
uptimeSystem uptimeuptime
hostnamectlHostname & OS infohostnamectl
dmesgBoot messagesdmesg | tail
journalctlSystem logsjournalctl -xe
tail -fLive log viewtail -f /var/log/syslog
who / wLogged-in usersw

🧰 Section 8: Other Useful Basics

CommandDescriptionExample
aliasCreate shortcutalias ll='ls -lah'
historyShow command historyhistory | grep reboot
crontab -eEdit cron jobscrontab -e
dateShow system timedate
envShow environment variablesenv | grep PATH

Post Your Comment