| Quick system information | |
hostnamectl | shows the host name and basic system data (virtual/hardware, hostname) |
uname -a | information about the Linux kernel (version, architecture). |
lsb_release -a | Ubuntu distribution version (release, codename) |
uptime | how long the server is running + current load average. |
w | who is logged in and what they are doing (sessions, load, commands). |
who | list of logged in users |
id | UID/GID of the current user and his group. |
date | current date/time. |
timedatectl | time, time zone, NTP synchronization. |
| |
| who -b | date and time of last download |
| uptime -s | date and time of last download |
| last -x | grep boot | head -n 1 | date and time of last download |
| |
| Users and Groups | |
adduser vit | creates a user (with a home folder and basic settings). |
deluser vit | deletes the user (usually does not touch the home folder without options). |
passwd vit | sets/changes the user password. |
usermod -aG sudo vit | adds the user to the sudo group (gives sudo rights). |
chage -l vit | Shows password policy (validity/expiration). |
groupadd devs | creates the group devs. |
usermod -aG devs vit | adds the user to the devs group. |
| |
| Permissions and Ownership | |
chmod 640 file | changes access rights (example: owner rw, group r, others without rights). |
chown user:group file | changes the owner and group of a file. |
getfacl file | shows ACL rights (extended rights besides chmod). |
setfacl -m u:vit:rwx dir | issues ACL rights to the user vit on the directory. |
| |
| Sudo (admin access) | |
sudo -i | open root-shell (almost like a full root login). |
sudo -l | shows what commands the current user can run through sudo. |
visudo | secure editing /etc/sudoers (checks syntax before saving). |
journalctl _COMM=sudo | shows events related to sudo (who/when called). |
| |
| systemd/systemctl - service management | |
systemctl status nginx | service status: whether it is active, PID, last lines of logs. |
systemctl start nginx | starts the service. |
systemctl stop nginx | stops the service. |
systemctl restart nginx | restarts the service. |
systemctl enable nginx | Enables autorun on boot. |
systemctl disable nginx | turns off autorun |
systemctl is-enabled nginx | quick answer: autorun is enabled or not. |
systemctl list-units --type=service --state=running | list of all running services. |
systemctl list-unit-files --type=service | list of units and their autorun mode. |
systemctl status nginx -l | status with “long” lines without trimming. |
journalctl -u nginx -b | logs of a specific service from the moment of loading. |
journalctl -u nginx --since "1 hour ago" | service logs for the last hour. |
| |
| Processes and load | |
top | interactively shows processes, CPU, memory, load. |
htop | a more convenient analogue of top (if installed). |
ps aux --sort=-%cpu | head | top processes by CPU. |
ps aux --sort=-%mem | head | top processes by memory. |
pidof nginx | PID of the process by name (if one/several, it will show everything). |
pgrep -a nginx | PID + run command (more useful than pidof) |
kill -TERM <pid> | ”gently” asks the process to terminate (preferred). |
kill -9 <pid> | “hard” kills (use only if frozen). |
nice -n 10 <cmd> | runs a command with reduced CPU priority. |
renice 10 -p <pid> | changes the priority of an already running process. |
| |
| Memory, disk, file systems | |
free -h | Using RAM and swap in human readable form. |
vmstat 1 5 | brief CPU/memory/IO statistics every 1 second (5 times). |
df -h | busy/free on file systems. |
df -i | checking the inode (sometimes there is space, but the inode has run out). |
lsblk -f | disks/partitions/FS/UUID (convenient for diagnostics and mounting). |
blkid | UUID and file system types. |
du -h --max-depth=1 /var | sort -h | which folders in /var are taking up space. |
sudo du -xh / | sort -h | tail -n 30 | the heaviest directories are on the root. |
lsof | grep deleted | Shows processes that keep deleted files open. |
| |
| Network and Ports | |
ip a | IP addresses, interfaces, status. |
ip r | routing table (where traffic goes by default). |
ss -tulpn | which ports are listened to (TCP/UDP) and by which processes. |
ss -tpn | active TCP connections and processes. |
ping -c 4 1.1.1.1 | checking ICMP to IP (whether there is a connection to the Internet/network). |
ping -c 4 google.com | DNS + connection check. |
curl -I https://example.com | check HTTP(S) headers and availability. |
wget -S --spider https://example.com | “check without downloading” shows the server response. |
resolvectl status | current DNS settings are systemd-resolved. |
resolvectl query example.com | check how the domain resolves. |
traceroute 8.8.8.8 | the path of packets to the node (where it “dies”). |
| `mtr -rw 8.8.8.8 | traceroute + loss statistics (very convenient). |
| |
| Firewall (UFW) | |
ufw status verbose | current rules and operating hours. |
ufw allow 22/tcp | allow incoming SSH. |
ufw allow 80,443/tcp | allow HTTP/HTTPS. |
ufw deny 23/tcp | deny port (example: telnet). |
ufw delete allow 80/tcp | delete a specific rule. |
ufw enable | enable firewall. |
ufw disable | turn off the firewall. |
| |
| SSH (access and diagnostics) | |
ssh user@host | connection via SSH. |
ssh -v user@host | detailed debugging: keys, algorithms, reasons for failure. |
ssh-keygen -t ed25519 | create an SSH key. |
ssh-copy-id user@host | copy the key to the server (to log in without a password). |
systemctl status ssh | sshd status. |
journalctl -u ssh -b | sshd logs from the moment of boot. |
| |
| Packages and Updates (APT/dpkg) | |
apt update | updates the list of packages from the repositories. |
apt upgrade | updates packages without “dangerous” dependency replacements. |
apt full-upgrade | updates packages, may remove/replace dependencies (sometimes necessary). |
apt install pkg | package installation. |
apt remove pkg | removing the package (configs may remain). |
apt purge pkg | removing the package along with its configs. |
apt autoremove | removes orphaned dependencies. |
apt clean | clears the cache of downloaded packages. |
apt policy nginx | shows versions (installed/available sources). |
apt-cache madison nginx | list of available package versions. |
dpkg -l | grep nginx | what nginx packages are installed. |
dpkg -S /path/to/file | which package “owns” the file. |
| |
| File/string search and orientation | |
find / -name "nginx.conf" 2>/dev/null | search for a file by name (we hide access errors). |
grep -R "PermitRootLogin" /etc/ssh -n | search for a line in files recursively + line numbers. |
rg "server_name" /etc/nginx | quick search (ripgrep), if installed. |
which nginx | path to the executable file that will be launched from the shell. |
whereis nginx | where is the binary/sources/man pages (wider than which). |
type nginx | will show what it is: alias/function/built-in/file. |
| |
| Schedulers: cron and systemd timers | |
crontab -l | list of cron jobs for the current user. |
sudo crontab -l | cron jobs for root. |
crontab -e | editing cron. |
ls -l /etc/cron.* | system cron directories (daily/weekly/monthly). |
systemctl list-timers --all | list of systemd timers (what runs and when). |
| |
| Docker (if used) | |
docker ps | running containers. |
docker logs -f <container> | container logs (monitor in real time). |
docker exec -it <container> bash | go inside the container. |
docker stats | container load (CPU/RAM/IO). |
| |
| Quick diagnostic checklist (5 commands) | |
systemctl status <service> -l | Is the service alive and what does it say? |
journalctl -u <service> -b | tail -n 200 | service errors. |
ss -tulpn | whether the port is listening. |
df -h; df -i; free -h | location/inodes/memory. |
ip r; resolvectl query google.com; curl -I https://example.com | route/DNS/HTTP. |
| |
| |