/ 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】.

pwd

Print the current working directory.

ls -la

List all files (including hidden) with permissions, owners and timestamps.

cd /path/to/dir

Change to the specified directory.

mkdir new_folder

Create a new directory called *new_folder*.

rm -rf /tmp/old

Recursively 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/passwd

Display the contents of a text file – here the system’s user database.

grep -i "error" /var/log/syslog

Search case‑insensitively for the word *error* in the system log.

chmod 755 script.sh

Set executable permissions (rwxr‑xr‑x) on *script.sh*.

chown $USER:$USER file.txt

Change ownership of *file.txt* to the current user and group.

df -h

Show disk usage of all mounted filesystems in human‑readable units.

du -sh *

Show the total size of each item in the current directory.

top

Interactive view of running processes and resource usage.

ps aux | grep node

List all processes and filter for those containing *node*.

kill -9 1234

Force‑kill the process with PID 1234.

tar -czvf backup.tar.gz /home/$USER

Create a gzipped archive of your home directory.

ssh user@host

Open 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 nginx

Show the status of the *nginx* service (systemd).

journalctl -u nginx -f

Follow the live log of the *nginx* service.

git clone https://github.com/your/repo.git

Clone a remote Git repository into the current folder.

npm install && npm run dev

Install Node dependencies and start the dev server (common for Next.js).

docker compose up -d

Spin up your Docker‑Compose stack in detached mode.

htop

A richer, colour‑coded version of *top* (install with `sudo apt install htop`).

curl -I https://example.com

Fetch only the HTTP headers of a URL – handy for checking redirects.