Skip to content

Linux Basics

Core Areas for Sysadmin and DevOps

Files and Directories

pwd
ls -lah
tree
cd /path
cp -r src dst
mv old new
rm -rf tmp/
find /etc -name '*.conf'
du -sh *
df -h

Permissions and Ownership

chmod 644 file
chmod +x script.sh
chown user:user file
umask
id
getfacl file

Classic permission model:

  • r read
  • w write
  • x execute

Processes

ps aux
top
htop
pgrep nginx
kill -15 <pid>
kill -9 <pid>
pkill nginx
nohup ./job.sh &

systemd

systemctl status nginx
systemctl start nginx
systemctl stop nginx
systemctl restart nginx
systemctl enable nginx
systemctl disable nginx
systemctl daemon-reload
journalctl -u nginx -xe
journalctl -f

Users and sudo

useradd deploy
passwd deploy
usermod -aG sudo deploy
su - deploy
sudo -l
visudo

Archives and Transfers

tar -czf backup.tar.gz /etc
tar -xzf backup.tar.gz
scp file user@host:/tmp/
rsync -avz ./app/ user@host:/srv/app/
curl -I https://example.com
wget https://example.com/file.tar.gz

Package Managers

Debian/Ubuntu

apt update
apt install nginx
apt remove nginx
apt search docker

RHEL/Rocky/Alma

dnf install nginx
dnf update
dnf remove nginx
rpm -qa | grep nginx

Logs and Diagnostics

tail -f /var/log/syslog
less /var/log/messages
dmesg -T
free -h
vmstat 1
iostat
ss -tulpn
ip a
ip r

Bash and Pipes

cat file | grep nginx
grep -R "server_name" /etc/nginx
awk '{print $1}' file
sed -n '1,20p' file
cut -d: -f1 /etc/passwd
sort file | uniq
xargs -I{} echo {}

Practice

  • Prefer ip, ss, journalctl, and systemctl over older tools such as ifconfig, netstat, and service when the distro uses a modern userspace.
  • Use rm -rf and kill -9 as a last resort, not as a default habit.
  • If an action is repeated, write a script, role, or automation job early.