Linux from the command line
Every Mangrove store has a small Linux server in the back office, and when it struggles, the tills and scanners feel it. This lesson teaches you to log in safely, find your way around, read the signs in processes, disk, services and logs, and fix common problems without creating new ones.
By the end you can
- Log in to a store box with an SSH key and turn password logins off without locking yourself out
- Find configuration, logs and app data, and read them with less, tail and grep
- Read and set permissions with chmod and chown, and explain why 777 is never the fix
- Check processes, load and disk, and stop a process with the right signal
- Start, enable and debug a service with systemctl and journalctl
The everyday picture
Picture the back room of a store. Shelves have fixed places: deliveries here, paperwork there, cleaning things in the corner. Keys decide who opens what: the manager has a master key, a cashier has a key to the cash room only, and anyone who borrows the master key signs the book. Staff on shift each do one job, and a shift supervisor makes sure the night stock-taker turns up and finds a replacement when someone walks out. Every worker writes what happened in the logbook.
A Linux server is the same room. The folders are the shelves, users and permissions are the keys, sudo is borrowing the master key, processes are the staff, systemd is the supervisor, and the logs are the logbook. When the store feels slow, a good manager does not shout at everyone. She reads the logbook, looks at who is busy, and checks whether the back room is full. You will do exactly that, with commands.
Getting in and finding your way
Each store has a store box: a small server running Ubuntu Server 24.04 LTS. It caches prices for the scanners, queues till sales when the internet drops, and runs the receipt print service. It has no screen. You reach it over the store's VPN with SSH, using its hostname, such as store-0142. If cd, ls and pipes are new to you, do The terminal without fear first; this lesson builds on it.
Log in with a key pair, not a password. A password can be guessed, reused or passed around in a chat group. A private key cannot be guessed, and each person's public key is one line in their ~/.ssh/authorized_keys file on the box, so removing one person removes one line.
# On your laptop, once: make a key pair (choose a passphrase when asked)
ssh-keygen -t ed25519 -C "nadia@techops-laptop"
# Copy the public key to the box (asks for your password one last time)
ssh-copy-id nadia@store-0142
# From now on, the key logs you in
ssh nadia@store-0142Once keys work for everyone who needs access, switch passwords off. Ubuntu's main SSH config, /etc/ssh/sshd_config, reads the files in /etc/ssh/sshd_config.d/ first, and the SSH server uses the first value it finds for each setting. So put your rules in a file whose name sorts early:
# /etc/ssh/sshd_config.d/10-keys-only.conf
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin nosudo sshd -t # test the config: no output means it is valid
sudo sshd -T | grep -i '^passwordauthentication' # the value the server will really use
sudo systemctl reload ssh # on Ubuntu the unit is called ssh, not sshdpasswordauthentication noOnce you are in, everything has a fixed place. Linux puts every disk under one tree that starts at /, the root. These are the folders you will use every day:
| Folder | What lives there | On a store box |
|---|---|---|
/etc | Configuration, as plain text files | /etc/mangrove/pricecache.env, /etc/ssh/ |
/var/log | Log files | /var/log/mangrove/, /var/log/syslog |
/var/lib | Data programs keep between restarts | /var/lib/mangrove/tillqueue/: queued till sales |
/home | Each person's own folder | /home/nadia |
/opt | Software installed outside the package manager | /opt/mangrove/: the price cache and till queue programs |
/tmp | Scratch space; may be emptied at reboot | Never keep anything here you need |
To read files, use three tools. less is a pager: it opens a file of any size instantly, / searches, n jumps to the next match, G goes to the end and q quits. tail shows the end of a file, and tail -f keeps printing new lines as they arrive, which is how you watch a till upload happen live. grep prints only the lines that contain a word.
less /var/log/mangrove/tillqueue.log # page through; /word searches, q quits
tail -n 20 /var/log/mangrove/tillqueue.log # the last 20 lines
tail -F /var/log/mangrove/tillqueue.log # follow new lines, even after the log is rotated; Ctrl+C stops
grep -c "upload failed" /var/log/mangrove/tillqueue.log # count matching lines
grep -i "timeout" /var/log/mangrove/tillqueue.log | tail -n 5 # last 5 matches, any upper or lower caseUsers, groups and permissions
Every process runs as a user, and every file has an owner (a user) and a group. A group is a named set of users, such as techops. The id command tells you who you are:
uid=1001(nadia) gid=1001(nadia) groups=1001(nadia),4(adm),27(sudo),1005(techops)On Ubuntu, the sudo group may run commands as root, and the adm group may read most logs. Services get their own service accounts: the price cache runs as pricecache and the till queue as tillqueue, so a bug in one cannot overwrite the other's files. You create one with sudo useradd --system --no-create-home --shell /usr/sbin/nologin tillqueue.
ls -l shows the permissions:
-rwxr-x--- 1 root techops 2210 Oct 2 10:15 flush-queue.sh
-rw-r----- 1 root techops 512 Oct 2 10:15 stores.conf
drwxr-x--- 2 root techops 4096 Oct 2 10:15 reportsThe first character is the type: - for a file, d for a directory. The next nine are three groups of three: what the owner may do, what members of the group may do, and what everyone else may do. r is read, w is write, x is execute, and - means no. So flush-queue.sh can be read, changed and run by root, read and run by the techops group, and nobody else may touch it.
On a directory the letters mean something different. r lets you list the names inside, x lets you enter it and open files by name, and w (together with x) lets you create, rename and delete files in it. Deleting a file depends on the folder's permissions, not the file's.
Each group of three is often written as one digit: r = 4, w = 2, x = 1, added up. rwx is 7, r-x is 5, rw- is 6, r-- is 4. So rwxr-x--- is 750 and rw-r----- is 640. Common modes: 755 for programs everyone may run, 644 for files everyone may read, 640 for logs, 600 for secrets and SSH files. The SSH server refuses your key if your .ssh folder or authorized_keys file can be written by other users.
sudo chown root:techops /opt/mangrove/tools/flush-queue.sh # owner root, group techops
sudo chmod 750 /opt/mangrove/tools/flush-queue.sh # rwx owner, r-x group, nothing for others
chmod 600 ~/.ssh/authorized_keys # only you may read or change it
sudo chmod g+r /var/log/mangrove/tillqueue.log # add read for the group, change nothing else
sudo usermod -aG adm ops-trainee # add a user to a group (-a keeps the old groups)A group change takes effect at the user's next login, so the new member logs out and in again. When Linux decides whether you may open a file, it checks in a fixed order and stops at the first match, as the diagram shows.
Now you can see why chmod 777 is never the fix for "Permission denied". It gives write access to every account on the box: the print service, any program with a bug, and any attacker who breaks into one of them. If a script with mode 777 is run by root, anyone who can edit it can run commands as root. The right fix is to find who needs access (ls -l on the file, id for the user) and give exactly that: change the owner, or add the user to the group.
sudo runs one command as root and writes it to the log, with your name. Use it per command. Avoid staying in a root shell with sudo -i for routine work: one wrong rm in the wrong folder has no safety net.
Quick check
/opt/mangrove/tools/flush-queue.sh has mode 750, owner root, group techops. A member of techops who is not root runs nano flush-queue.sh and tries to save a change. What happens?
The 7 belongs to the owner, root. The group digit is 5, which is 4 + 1: read and execute. Being able to run a script does not let you change it. That split is the point: the team can use the tool, but only root can edit it.
Processes, signals and load
A process is a running program, and each has a number, its PID. ps takes a snapshot of them; top shows a live view that refreshes every few seconds (press M to sort by memory, P by CPU, q to quit). htop is a friendlier version, if it is installed (sudo apt install htop).
ps -eo pid,user,stat,%cpu,%mem,etime,cmd --sort=-%cpu | head -n 3 # busiest processes first PID USER STAT %CPU %MEM ELAPSED CMD
1187 priceca+ Ssl 3.1 10.2 12-03:11:40 /opt/mangrove/pricecache/bin/pricecache
912 tillque+ Ssl 0.4 2.1 12-03:11:42 /opt/mangrove/tillqueue/bin/tillqueueLong user names are cut short with a +, so priceca+ is the pricecache account. The STAT column's first letter is the state. R is running or ready to run, S is sleeping (waiting for work, which is normal), D is waiting for the disk or another device and cannot be interrupted, Z is a zombie (finished, but its parent has not collected it). Many D processes mean the disk is the bottleneck.
uptime and the first line of top show the load average: three numbers for the last 1, 5 and 15 minutes. Compare them with the number of CPUs, which nproc prints. On a 4-CPU box, a load of about 4 means the CPUs are roughly fully used; 9 means tasks are queuing. On Linux, the load also counts tasks stuck in state D, so a high load with idle CPUs points at the disk, not the CPU. In top, the wa value (time the CPUs sat waiting for disk) confirms it.
To stop a process you send it a signal. The ones you need:
- TERM (15): "please stop". The default for
kill PID. The program can catch it, finish what it is doing and save its data. - INT (2): what Ctrl+C sends to the program in front of you.
- HUP (1): many server programs reload their config when they get it. This depends on the program, so check its documentation.
- KILL (9): "stop now". The program cannot catch it. The kernel ends it at once, with no clean-up and no saving.
Mangrove's till queue holds the last few sales in memory and writes them to disk when it gets TERM. A kill -9 skips that step. So for anything run as a service, do not use kill at all: use systemctl stop or systemctl restart. systemd sends TERM, waits (90 seconds by default), and sends KILL only if the program is still running. A process in state D often cannot be killed even with -9 until the disk answers.
Quick check
The till queue on store-0142 stopped uploading sales and does not answer its health check. What is the safest way to stop it?
systemd gives the till queue a chance to save the sales it holds, and still forces it down if it does not stop in time. kill -9 throws away that chance, and the sales in memory with it. A reboot also stops the price cache and the print service, and wipes the live state you might need to find the cause.
Services with systemd, logs with journalctl
systemd starts every service on the box, watches it, and restarts it if it dies. Each service is described by a unit file. Packages install theirs in /usr/lib/systemd/system/; your own go in /etc/systemd/system/. This is the till queue's:
# /etc/systemd/system/mangrove-tillqueue.service
# (systemd allows comments only on their own lines, never after a value)
[Unit]
Description=Mangrove till sales queue
# start once the network is up
Wants=network-online.target
After=network-online.target
[Service]
# run as the service account, never as root
User=tillqueue
Group=tillqueue
EnvironmentFile=/etc/mangrove/tillqueue.env
ExecStart=/opt/mangrove/tillqueue/bin/tillqueue
# if it exits with an error, start it again after 5 seconds
Restart=on-failure
RestartSec=5
[Install]
# what "enable" hooks it into: the normal boot
WantedBy=multi-user.targetYou drive it with systemctl. start runs a service now; enable makes it start at every boot. They are separate, and forgetting enable is the classic reason a service "disappears" after a reboot. After you edit a unit file, run sudo systemctl daemon-reload so systemd reads the new version. To change a packaged unit, use sudo systemctl edit NAME: it saves your changes in a separate override file that survives package updates, and reloads for you.
systemctl status mangrove-tillqueue # running? since when? main PID, last log lines
sudo systemctl restart mangrove-tillqueue # stop (TERM, then KILL if needed), then start
sudo systemctl enable --now mangrove-tillqueue # start at boot, and start now
systemctl --failed # every unit that has failed
systemctl cat mangrove-tillqueue # the unit file plus any overridesRestart=on-failure starts it again after RestartSec. Everything the program prints goes to journald, and journalctl -u shows one service's share of it.Everything a service prints, plus systemd's own notes about starts, stops and crashes, goes to the journal. journalctl reads it, and its filters are what make it useful. On Ubuntu, members of the adm group can read the whole journal; others need sudo.
journalctl -u mangrove-tillqueue --since "07:00" # one service, from 07:00 today
journalctl -u mangrove-tillqueue --since "2026-10-19 22:00" --until "2026-10-20 06:00"
journalctl -u mangrove-tillqueue -f # follow new lines, like tail -f
journalctl -p err --since today # only errors, from every service
journalctl -b -1 -n 50 # last 50 lines of the previous boot
journalctl --disk-usage # how much space the journal takes-b -1 works only if the journal is kept on disk (the folder /var/log/journal exists). Some programs, like the price cache, also write their own log file under /var/log/mangrove/. Check both: the journal tells you when the service started, stopped or crashed, and the app's log tells you what it was doing.
Quick check
On Friday you installed a new print helper service and ran sudo systemctl start mangrove-printhelper. It worked. After Monday's power cut, it is not running, and systemctl status says inactive (dead) with no errors. What was missed?
start runs a service once; only enable hooks it into boot. Restart=on-failure restarts a program that crashed, but this one never crashed: it was never started after the reboot, which is why the status shows no errors. daemon-reload is only needed after editing unit files.
Disk space: df, du and the file that will not go away
A full disk breaks things in strange ways: the till queue cannot save sales, logins fail, services crash with No space left on device. Two commands find the cause. df -h shows each filesystem and how full it is. du adds up the size of folders, so you can walk down to the one that grew.
df -h # how full is each filesystem?
sudo du -xh --max-depth=1 /var | sort -h | tail -n 5 # the biggest folders in /var
sudo du -h /var/log/* | sort -h | tail -n 5 # then go one level deeper-h prints sizes like 41G instead of byte counts, -x stays on one filesystem so du does not wander into other disks, and sort -h sorts those human sizes correctly. Work top-down: the biggest folder, then the biggest inside it, until you find the file. If df shows free space but you still get "No space left", run df -i: the disk may have run out of inodes because something made millions of tiny files.
There is one trap everybody meets once. When you rm a file that a running process still has open, the name disappears but the space is not freed until the process closes it. du no longer sees the file, df still counts it, and the two disagree. Restarting the service frees the space. To empty a log a service is still writing, use sudo truncate -s 0 FILE instead of rm.
Build it
We will replay the store-0142 investigation command by command, fix it without losing evidence, and check that the fix held.
-
Log in and get the big picture
Log in with your key, then compare the load with the CPU count.
Terminalssh nadia@store-0142 uptime nprocOutput08:42:15 up 12 days, 3:11, 1 user, load average: 9.12, 8.47, 6.30 4A load of 9 on 4 CPUs, and still rising (the 1-minute number is the highest). Something is queuing. Do not reboot: you would lose the evidence.
-
See who is busy, and on what
Run
topand read the header before the process list.Outputtop - 08:42:31 up 12 days, 3:11, 1 user, load average: 9.05, 8.46, 6.31 Tasks: 141 total, 2 running, 139 sleeping, 0 stopped, 0 zombie %Cpu(s): 14.2 us, 9.8 sy, 0.0 ni, 11.6 id, 64.1 wa, 0.0 hi, 0.3 si, 0.0 st MiB Mem : 3916.2 total, 212.4 free, 1408.9 used, 2294.9 buff/cache PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1187 priceca+ 20 0 1254300 422500 18200 D 38.0 10.5 161:12.34 pricecache 912 tillque+ 20 0 402116 88300 12100 D 4.1 2.2 12:40.02 tillqueueThe CPUs spend 64% of their time waiting for the disk (
wa), and the two Mangrove processes are in stateD. This is a disk problem, not a CPU problem. Memory looks fine: most of it is cache that Linux gives back when needed. -
Check the disks and find what grew
Terminaldf -h / sudo du -xh --max-depth=1 /var | sort -h | tail -n 3 sudo ls -lh /var/log/mangrove/OutputFilesystem Size Used Avail Use% Mounted on /dev/mapper/ubuntu--vg-ubuntu--lv 58G 54G 1.2G 98% / 2.3G /var/lib 41G /var/log 45G /var total 41G -rw-r----- 1 pricecache adm 41G Oct 20 08:42 pricecache.log -rw-r----- 1 tillqueue adm 12M Oct 20 08:42 tillqueue.logOne file holds 41 GB. Look at what is in it:
Terminalsudo tail -n 3 /var/log/mangrove/pricecache.logOutput2026-10-20T08:42:40.118Z DEBUG lookup sku=4006381 store=0142 hit=true 0.4ms 2026-10-20T08:42:40.118Z DEBUG lookup sku=8901030 store=0142 hit=true 0.3ms 2026-10-20T08:42:40.119Z DEBUG cache stats entries=24912 bytes=88112640 -
Find what changed, and when
The journal records every start of the service. The config file shows the setting.
Terminaljournalctl -u mangrove-pricecache --since yesterday | grep -i "log level" grep -n LOG_LEVEL /etc/mangrove/pricecache.envOutputOct 19 16:10:03 store-0142 pricecache[1187]: starting, log level debug 4:LOG_LEVEL=debugDebug logging since 16:10 yesterday. Nobody changed anything today, which is exactly why Ama could not have known.
-
Fix it without losing the evidence
Keep a small sample for the ticket, set the level back, and empty the log while the service is stopped. The scanners' price checks pause for the few seconds the restart takes.
Terminal# 1. keep the last 1,000 lines as evidence, compressed, in your home folder sudo tail -n 1000 /var/log/mangrove/pricecache.log | gzip > ~/pricecache-debug-sample.log.gz # 2. set the log level back to info, and check the change sudo sed -i 's/^LOG_LEVEL=debug$/LOG_LEVEL=info/' /etc/mangrove/pricecache.env grep -n LOG_LEVEL /etc/mangrove/pricecache.env # 3. stop, empty the log in place (not rm), start again sudo systemctl stop mangrove-pricecache sudo truncate -s 0 /var/log/mangrove/pricecache.log sudo systemctl start mangrove-pricecache -
Verify, then write it up
Terminalsystemctl status mangrove-pricecache --no-pager | head -n 3 df -h / uptime # run again after a few minutes; the 1-minute load drops firstOutput● mangrove-pricecache.service - Mangrove price cache Loaded: loaded (/etc/systemd/system/mangrove-pricecache.service; enabled; preset: enabled) Active: active (running) since Tue 2026-10-20 08:51:12 UTC; 4min ago Filesystem Size Used Avail Use% Mounted on /dev/mapper/ubuntu--vg-ubuntu--lv 58G 13G 43G 23% / 08:55:40 up 12 days, 3:24, 1 user, load average: 0.61, 3.02, 4.88Ask Ama to try a price check. Then write the ticket: the symptom, each command and what it showed, the cause, the fix, and two follow-ups (log rotation for the price cache, and a disk alert at 85% on every box). The commands you typed are the ticket's best part, because the next person can run them too.
Bring it to your team
Ask these in your next TechOps review of the store boxes.
- "Who can log in to the store boxes today, and with which key? Can we remove one person from all 320 in one step?"
- "Is password login off on every box? How would we know if one was switched back on?"
- "Is every Mangrove program run by systemd as its own service account, enabled, with Restart=on-failure?"
- "Which alert fires before a disk fills up, at what percentage, and who receives it?"
- "When someone turns on debug logging, who turns it off, and when?"
Red flags
- One shared login or password for many boxes
chmod 777orchmod -Ras the answer to "Permission denied"kill -9as the first step, or a reboot before anyone has read the logsrmon a large log that a running service is still writing- Programs started by hand in a terminal instead of from a systemd unit
- Hand edits on one box with no ticket, so the next engineer cannot tell what changed
Practice
Turn permission letters into octal
Write modeToOctal(perm). It takes the nine permission letters from ls -l (without the type character), such as 'rwxr-x---', and returns the octal mode as a three-character string, such as '750'. r = 4, w = 2, x = 1, and - = 0, added up for each group of three. Keep leading zeros: '---------' is '000'.
function modeToOctal(perm) {
// perm is 9 letters: owner (0-2), group (3-5), others (6-8)
// each group of three becomes one digit: r = 4, w = 2, x = 1
return '';
}
test('rwxr-x--- is 750', () => expect(modeToOctal('rwxr-x---')).toBe('750'));
test('rw-r--r-- is 644', () => expect(modeToOctal('rw-r--r--')).toBe('644'));
test('rw------- is 600 (an SSH key file)', () => expect(modeToOctal('rw-------')).toBe('600'));
test('no permissions at all is 000, with the zeros kept', () => expect(modeToOctal('---------')).toBe('000'));
test('rwxrwxrwx is 777, the mode to avoid', () => expect(modeToOctal('rwxrwxrwx')).toBe('777'));
Show a solution
function modeToOctal(perm) {
const value = { r: 4, w: 2, x: 1, '-': 0 };
let out = '';
for (let i = 0; i < 9; i += 3) { // owner, group, others
let digit = 0;
for (const ch of perm.slice(i, i + 3)) digit += value[ch];
out += String(digit); // build a string, so '000' stays '000'
}
return out;
}Decide who may read a log
Write canRead(file, user), following the order in the first diagram. file looks like { owner: 'pricecache', group: 'adm', mode: 'rw-r-----' } and user like { name: 'nadia', groups: ['nadia', 'adm', 'sudo'] }. Root may always read. Otherwise use only the owner letters (positions 0 to 2) if the user is the owner, else only the group letters (3 to 5) if the user is in the file's group, else only the last three. Return true if the chosen set has an r. The starter says yes whenever anyone may read, which is wrong.
function canRead(file, user) {
// wrong: says yes if any of the three sets has an r
return file.mode.includes('r');
}
const log = { owner: 'pricecache', group: 'adm', mode: 'rw-r-----' };
test('root may read anything, even mode 000', () =>
expect(canRead({ owner: 'pricecache', group: 'adm', mode: '---------' }, { name: 'root', groups: ['root'] })).toBe(true));
test('a member of the group uses the group letters', () =>
expect(canRead(log, { name: 'nadia', groups: ['nadia', 'adm', 'sudo'] })).toBe(true));
test('a user in neither owner nor group uses the last three letters', () =>
expect(canRead(log, { name: 'lp', groups: ['lp'] })).toBe(false));
test('the owner uses only the owner letters, even when the group may read', () =>
expect(canRead({ owner: 'pricecache', group: 'adm', mode: '-w-r--r--' }, { name: 'pricecache', groups: ['pricecache', 'adm'] })).toBe(false));
Show a solution
function canRead(file, user) {
if (user.name === 'root') return true; // root skips read checks
let set;
if (user.name === file.owner) set = file.mode.slice(0, 3); // owner first
else if (user.groups.includes(file.group)) set = file.mode.slice(3, 6); // then group
else set = file.mode.slice(6, 9); // then others
return set[0] === 'r'; // first match wins: no fallback
}The last test is the one people get wrong: an owner whose letters say no is refused, even though the group and everyone else may read.
Fix the till queue that keeps restarting
On store-0217, the till queue stopped uploading sales after a colleague "cleaned up" /var/lib/mangrove last night. You see this:
systemctl status mangrove-tillqueue
Active: activating (auto-restart) (Result: exit-code) since Tue 2026-10-20 09:14:55 UTC; 3s ago
journalctl -u mangrove-tillqueue -n 2
Oct 20 09:14:55 store-0217 tillqueue[20931]: open /var/lib/mangrove/tillqueue/queue.db: permission denied
Oct 20 09:14:55 store-0217 systemd[1]: mangrove-tillqueue.service: Main process exited, code=exited, status=1/FAILURE
ls -ld /var/lib/mangrove/tillqueue
drwxr-xr-x 2 root root 4096 Oct 19 23:40 /var/lib/mangrove/tillqueueWrite what is happening, the commands you run next (in order), the fix, and how you check it worked.
- You explain that systemd keeps restarting the service (Restart=on-failure) and it fails each time on the same permission error
- You confirm which user the service runs as (
systemctl catshowsUser=tillqueue) before changing anything - Your fix gives ownership back to the service account with
chown, and does not usechmod 777 - You check the files inside the folder too (
ls -l), sincequeue.dbmay also be owned by root now - You verify: status shows
active (running), the journal shows uploads, and queued sales go out
Show a model answer
The folder now belongs to root with mode 755, so the tillqueue user can read it but cannot write queue.db. The program exits with status 1, and Restart=on-failure starts it again every 5 seconds, failing the same way each time. Sales stay on the tills until it works again.
systemctl cat mangrove-tillqueue | grep -E '^(User|Group)=' # confirm: tillqueue
sudo ls -l /var/lib/mangrove/tillqueue # is queue.db root-owned too?
sudo chown -R tillqueue:tillqueue /var/lib/mangrove/tillqueue # give it back, folder and files
sudo systemctl restart mangrove-tillqueue
systemctl status mangrove-tillqueue --no-pager | head -n 3 # expect: active (running)
journalctl -u mangrove-tillqueue -f # watch the queued sales uploadIn the ticket, record what the clean-up changed and ask for a rule: nobody runs chown -R or chmod -R under /var/lib/mangrove without a change ticket.
Check yourself
An hour ago a colleague ran sudo rm /var/log/mangrove/pricecache.log to free 30 GB on store-0310. df -h still shows the disk at 97%, and du cannot find the space anywhere. What is going on, and what frees the space?
A deleted file's space is freed only when the last process that has it open closes it. The running price cache still holds it, so df counts it while du, which walks file names, cannot see it. Restart the service. A reboot would also free it, but it stops every service on the box. The command line has no trash folder, and df always shows the current numbers.
A new TechOps trainee gets "Permission denied" on /var/log/mangrove/tillqueue.log, which is -rw-r----- tillqueue adm. What is the right fix?
The group already has read access, so joining the group gives exactly what is needed and nothing more. The change applies at the next login. 644 would let every account on the box, including service accounts, read logs that may contain sales data; 777 also lets anyone change or delete them; a shared root password removes the record of who did what.
A store box with 4 CPUs shows load average: 6.20, 6.05, 5.90. top says 78.0 id (idle) and 18.5 wa. What should you investigate first?
On Linux the load average counts tasks waiting for the disk as well as tasks wanting a CPU. With the CPUs 78% idle, the extra load cannot be CPU work; the wa value and processes in state D point to disk. Look at df -h, what is writing heavily, and the logs. A load of 6 on 4 CPUs is not normal; it means a queue.
Flashcards
Key takeaways
- Log in with SSH keys and personal accounts; turn password logins off, and keep a session open while you change SSH settings.
- Config lives in /etc, logs in /var/log, app data in /var/lib, Mangrove's programs in /opt. Read them with less, tail -F and grep.
- Permissions are owner, group, others, checked in that order with the first match winning. Fix access with chown or group membership, never chmod 777.
- Compare load with nproc, and check wa: Linux load includes tasks waiting for the disk. Stop services with systemctl, which sends TERM before KILL.
- systemd runs and restarts services; enable makes them survive a reboot. journalctl -u, --since and -f tell you what happened and when.
Sources
- hier(7): the file system hierarchy, Linux man-pages project
- signal(7): overview of signals, Linux man-pages project
- systemd.service(5): service unit configuration, systemd documentation on man7.org
- journalctl(1): query the systemd journal, systemd documentation on man7.org