Home › Other › Linux

Linux

Most servers run Linux. Knowing your way around the filesystem, permissions, and processes pays off constantly.

Linux is a free, Unix-like operating system that powers the majority of the world’s servers. You interact with it mostly through the command line, so a little fluency goes a long way.

The filesystem

Everything hangs off a single root, /. Some directories you will meet:

PathHolds
/homeUsers’ personal files
/etcSystem configuration
/varLogs, spool, changing data
/usrInstalled programs and libraries
/tmpTemporary files

Permissions

Every file has an owner, a group, and three sets of permissions — read, write, execute — for owner, group, and everyone else:

$ ls -l script.sh
-rwxr-xr-- 1 ada staff 128 Nov 8 10:00 script.sh

$ chmod +x script.sh     # make executable
$ chmod 644 notes.txt     # rw-r--r--
$ chown ada notes.txt     # change owner

The digits are octal: read=4, write=2, execute=1, added up per group. So 644 is read/write for the owner, read-only for everyone else.

Processes

$ ps aux            # list running processes
$ top               # live view of CPU/memory
$ kill 1234         # ask process 1234 to stop
$ kill -9 1234      # force it
$ systemctl status caddy   # a managed service

The superuser

root can do anything. You usually run a normal account and prefix privileged commands with sudo:

$ sudo systemctl restart nginx
Be deliberate with sudo and rm -rf. There is no recycle bin on the command line — a deleted file is gone. Double-check the path before you press enter.

Keep reading