Finding your way around
Linux is the operating system almost every server, container and cloud machine runs on. When you do DevOps work you are mostly typing commands into a Linux shell, often on a machine with no screen at all, so being comfortable here is the foundation for everything else.
What "Linux" actually means
Strictly, Linux is the kernel: the core program that talks to the hardware, shares out CPU time and memory, and manages files and networking. What you install is a distribution (distro) such as Ubuntu, Debian, Fedora or Rocky Linux, which bundles that kernel with tools, a package manager and default settings. You interact with it through a shell (usually bash), a program that reads the commands you type and runs them.
DevOps leans on Linux because it is free, stable enough to run for years without a reboot, easy to automate (everything can be done from a script), and it is what Docker containers and cloud images are built on.
One tree, one root
Windows gives each drive its own letter (C:, D:). Linux has a single tree that starts at / (called "root"). Extra disks, USB sticks and even information about running programs are attached somewhere inside that one tree, so every file on the system has exactly one path that starts with /.
The top-level folders each have a job, and knowing them tells you where to look:
/etcholds system-wide configuration. Nginx's settings live in/etc/nginx, SSH's in/etc/ssh./homehas one folder per user, for example/home/demee. The shortcut~always means your own home folder./varis for data that changes while the system runs, most importantly logs in/var/log./usrcontains installed programs and their shared files;/usr/binis where most commands live./tmpis scratch space that gets wiped on reboot./devrepresents hardware as files (disks show up as/dev/sda), and/procis a virtual folder where the kernel exposes live information about processes and the system.
Swap is a reserved piece of disk the kernel uses as overflow memory once RAM is full. It keeps the machine alive under memory pressure, but it is far slower than real RAM.
Absolute and relative paths
An absolute path starts at the root and works from anywhere: /home/demee/projects. A relative path starts from wherever you are right now: if you are in /home/demee, then projects means the same folder. Two special names help: . is the current folder and .. is the one above it.
Moving around
$ pwd # where am I?
/home/demee
$ ls # what's in here?
projects notes.txt scripts
$ cd projects # go into a folder (relative path)
$ cd .. # back up one level
$ cd /var/log # jump anywhere with an absolute path
$ cd # no argument = straight back home
$ ls -la # long listing, including hidden files
ls -l shows one file per line with its permissions, owner, size and date; adding -a includes hidden files, which in Linux are simply files whose names start with a dot, like .bashrc or .git.
Looking inside files
cat file prints a whole file, which is fine for short ones. For long files use less file (scroll with arrow keys, search with /word, quit with q). head -n 20 file shows the first 20 lines and tail -n 20 file the last 20. The one you will use constantly on servers is tail -f /var/log/syslog: -f keeps the file open and prints new lines as they are written, so you can watch a log live while you reproduce a problem.
Creating, copying, moving, deleting
$ mkdir -p app/config # -p creates missing parent folders too
$ touch app/config/.env # empty file (or refresh the timestamp)
$ cp notes.txt backup.txt # copy a file
$ cp -r app app-backup # -r copies a folder and everything in it
$ mv backup.txt old/ # move into a folder
$ mv draft.txt final.txt # "move" in place = rename
$ rm final.txt # delete a file
$ rm -r app-backup # delete a folder and its contents
rm is permanent, and rm -rf deletes without asking even when files are write-protected. Read the path twice before pressing Enter, especially with sudo.A symbolic link (ln -s target linkname) is a shortcut that points to another path instead of copying it. Servers use them a lot, for example Nginx enables a site by linking a file from sites-available into sites-enabled. Delete the target and the link breaks.
Finding things
find walks a folder tree and matches files by name, type, size or age: find /etc -name "*.conf" lists every .conf file under /etc, and find . -type f -mtime -1 finds files changed in the last day. To locate a command rather than a file, which python3 prints the path of the program that would run.