/ linux / commands
A quick‑reference cheat‑sheet of the most useful Linux CLI commands. Copy‑and‑paste them into any terminal – they work on virtually every distro (Ubuntu, Fedora, Arch, …)【1†L1-L4】.
pwdPrint the current working directory.
ls -laList all files (including hidden) with permissions, owners and timestamps.
cd /path/to/dirChange to the specified directory.
mkdir new_folderCreate a new directory called *new_folder*.
rm -rf /tmp/oldRecursively delete *old* and everything under it (use with caution!).
cp -r src/ dest/Copy a directory tree from *src* to *dest*.
mv file.txt ~/Documents/Move (or rename) *file.txt* into your *Documents* folder.
cat /etc/passwdDisplay the contents of a text file – here the system’s user database.
grep -i "error" /var/log/syslogSearch case‑insensitively for the word *error* in the system log.
chmod 755 script.shSet executable permissions (rwxr‑xr‑x) on *script.sh*.
chown $USER:$USER file.txtChange ownership of *file.txt* to the current user and group.
df -hShow disk usage of all mounted filesystems in human‑readable units.
du -sh *Show the total size of each item in the current directory.
topInteractive view of running processes and resource usage.
ps aux | grep nodeList all processes and filter for those containing *node*.
kill -9 1234Force‑kill the process with PID 1234.
tar -czvf backup.tar.gz /home/$USERCreate a gzipped archive of your home directory.
ssh user@hostOpen an encrypted remote shell to *host* as *user*.
scp file.txt user@host:/tmp/Securely copy *file.txt* to the remote host’s */tmp* directory.
systemctl status nginxShow the status of the *nginx* service (systemd).
journalctl -u nginx -fFollow the live log of the *nginx* service.
git clone https://github.com/your/repo.gitClone a remote Git repository into the current folder.
npm install && npm run devInstall Node dependencies and start the dev server (common for Next.js).
docker compose up -dSpin up your Docker‑Compose stack in detached mode.
htopA richer, colour‑coded version of *top* (install with `sudo apt install htop`).
curl -I https://example.comFetch only the HTTP headers of a URL – handy for checking redirects.