Ravindra BagaleCourses & study guides मराठी Track your progress

AWS Cloud

Linux Commands A-Z Part 4: hostname, ip, journalctl, jq, kill, lsof, lvcreate and More with Examples

This is Part 4 of the Linux Commands A-Z reference: hostname to lvcreate. These are the commands you use to name a server, read its network, firewall and CPU, watch processes and disks, read logs with journalctl, filter JSON with jq, stop processes, see who logged in, read big files, make links, find files fast, write and rotate logs, list files and disks, find open files and create LVM volumes. Every command has why, what, an options table and step-by-step examples with real output and its meaning. ip, journalctl, ls and lsof get extra depth because you will use them in almost every incident.

In this chapter

  • Name a server with hostname and hostnamectl and read its identity with id
  • Read addresses, routes and ARP with ip, and old output from ifconfig
  • Read and add iptables rules in the right order
  • Watch CPU, memory and disks with htop, iostat, lscpu and lsblk
  • Read logs with journalctl and less, write them with logger, rotate them with logrotate
  • Filter JSON from APIs with jq
  • Stop processes with kill and killall, and manage jobs
  • Use ls, ln, locate and lsof to find files, links and holders, and grow storage with lvcreate

1. An everyday example: a Swargate housing society office

The society secretary checks the name board on each wing, reads the gate register of who came in, checks the water tank level, looks at the CCTV recorder log, calls the plumber for a leaking pipe, sends away a stray vendor, and adds a new storage room when the old one is full.

hostname is the name board. last is the gate register. lsblk and iostat are the water tank. journalctl is the CCTV log. ip is the pipes. kill is sending the vendor away. lvcreate is the new storage room.

An incident walk-throughRight server?Network up?Logs say?Who holds it?Stop the culpritAdd space
Each step uses a command from this part.

2. A five-minute incident check using Part 4 commands

Before the deep dives, see how these commands answer the first questions in an outage.

Confirm the server, check the network, read the errors, then find the process.

QuestionCommand
Which server am I on?hostname
Is the network up?ip -br a
What failed?journalctl -p err -b
Who holds the port?lsof -i :8080
Is the disk the bottleneck?iostat -x
  1. Run the check in one go.
hostname; ip -br a | grep -v lo; sudo journalctl -p err -b -n 2 --no-pager

Output:

web01.prod.example.in
eth0  UP  10.0.1.5/24
app[3120]: java.net.BindException: Address already in use
systemd[1]: app.service: Failed with result 'exit-code'.

Right server, network up, the app could not bind its port.

  1. Find who holds the port.
sudo lsof -i :8080 -P -n

Output:

COMMAND  PID USER FD TYPE NODE NAME
java    2950 app  45u IPv6 TCP  *:8080 (LISTEN)

An old copy (PID 2950) still runs. Stop it with kill, then start the service.

3. hostname: Show or set the host name

hostname in depth: the server's name and IPs

Prompts, logs, monitoring and certificates all show the host name. A wrong name puts alerts on the wrong server. You also often need the server IP quickly.

hostname prints or sets the current host name. A change made with hostname alone is lost at reboot; on systemd systems use hostnamectl to make it permanent. hostname -I lists all IP addresses of the machine.

Common options

OptionWhat it does
hostnamePrint the name.
hostname -fFull name (FQDN).
hostname -sShort name.
hostname -IAll IP addresses.
sudo hostname newSet until reboot.
  1. Which server am I on?
hostname

Output:

web01

Always check before risky commands.

  1. Full name.
hostname -f

Output:

web01.prod.example.in

Short name plus domain.

  1. My IPs.
hostname -I

Output:

10.0.1.15 172.17.0.1

The server IP and the docker bridge.

  1. Temporary change.
sudo hostname test01; hostname

Output:

test01

Gone after reboot. Use hostnamectl for permanent.

Practise this in the tasks below: Practice tasks

Real use: A Pune hospital names servers like opd-db01 and checks hostname in every script before touching data.

4. hostnamectl: Manage host name with systemd

hostnamectl in depth: set the name permanently and see system info

New VMs come with random names like ip-10-0-1-15. You need a meaningful name that survives reboot, and a quick view of the OS, kernel and hardware.

hostnamectl talks to systemd-hostnamed. It writes /etc/hostname, sets the running name and also shows OS, kernel, architecture, virtualization and machine ID in one screen.

Common options

OptionWhat it does
hostnamectlShow status.
hostnamectl set-hostname nameSet permanently.
hostnamectl --staticOnly the saved name.
hostnamectl set-hostname "Pretty" --prettyDisplay name with spaces.
hostnamectl set-location "Pune DC"Note the location.
  1. See system info.
hostnamectl

Output:

  Static hostname: ip-10-0-1-15
Operating System: Rocky Linux 9.4 (Blue Onyx)
          Kernel: Linux 5.14.0-427.el9.x86_64
  Virtualization: amazon
    Architecture: x86-64

OS, kernel and cloud in one view.

  1. Set a real name.
sudo hostnamectl set-hostname pay-api01.prod.example.in

Saved in /etc/hostname and live now.

  1. Check.
cat /etc/hostname; hostname

Output:

pay-api01.prod.example.in
pay-api01.prod.example.in

Will survive reboot.

  1. Add it to /etc/hosts too.
echo "127.0.1.1 pay-api01.prod.example.in pay-api01" | sudo tee -a /etc/hosts

Output:

127.0.1.1 pay-api01.prod.example.in pay-api01

Stops "unable to resolve host" warnings from sudo.

Practise this in the tasks below: Practice tasks

Real use: A Hinjewadi fintech's Ansible role runs hostnamectl set-hostname from inventory so every server name matches the CMDB.

5. htop: Interactive process viewer

htop in depth: friendly live view of CPU, memory and processes

When a server is slow, you want to see at a glance which process eats CPU or memory, per core, and act on it. htop is easier to read and use than top.

htop is an interactive process viewer (install from EPEL on RHEL). It shows bars for every CPU core, memory and swap, then a sortable list of processes. You can search, filter, show a tree, change priority and kill with function keys.

Common options

OptionWhat it does
htopStart.
F6 or < >Choose sort column.
F3 or /Search.
F4 or \Filter.
F5 or tTree view.
F9 or kSend a signal.
htop -u nginxOnly one user.
htop -p 811,812Only these PIDs.
  1. Install.
sudo dnf install -y epel-release && sudo dnf install -y htop

Output:

Complete!

On Ubuntu: sudo apt install htop.

  1. Open and sort by memory.
htop  (press F6, pick PERCENT_MEM)

Output:

  1[|||||||       32%]  Mem[||||||||  5.1G/7.6G]
  PID USER  %CPU %MEM COMMAND
  811 mysql  3.1 41.0 /usr/sbin/mysqld

mysqld uses 41% of RAM.

  1. Only the web user.
htop -u nginx

Output:

(only nginx processes listed)

Less noise.

  1. Tree view.
htop  (press F5)

Output:

nginx: master
 ├─ nginx: worker
 └─ nginx: worker

Shows parents and children.

Practise this in the tasks below: Practice tasks

Real use: A Wakad game studio keeps htop on a wall screen during launches to see which server is hot.

6. id: Show user and group ids

id in depth: user ID, group IDs and SELinux context

Permission problems come down to "who am I and which groups do I have". id answers with names and numbers, which matter for NFS, containers and file ownership.

id prints the user ID (uid), main group (gid) and all groups of the current or named user. With -Z it also shows the SELinux context. Numbers matter because files store the number, not the name.

Common options

OptionWhat it does
idMe, all details.
id raviAnother user.
id -uOnly my UID.
id -unMy user name.
id -GnGroup names.
id -ZSELinux context.
  1. Who am I?
id

Output:

uid=1001(ravi) gid=1001(ravi) groups=1001(ravi),10(wheel),3000(devs)

UID 1001; wheel means sudo.

  1. Am I root in a script?
[ "$(id -u)" -eq 0 ] && echo root || echo "not root"

Output:

not root

UID 0 is always root.

  1. Does the app user exist?
id app

Output:

uid=990(app) gid=988(app) groups=988(app)

A system account with low UID.

  1. NFS file shows a number as owner.
ls -ln /mnt/share/report.xlsx; id -u priya

Output:

-rw-r--r-- 1 1502 1502 ... report.xlsx
1003

UID differs between servers; that is why access fails.

Practise this in the tasks below: Practice tasks

Real use: A Pune university IT team checks id on every lab server so student UIDs match the NFS home server.

7. ifconfig: Old tool to show network interfaces

ifconfig in depth: the old network tool (and its ip replacement)

Many guides, old scripts and some interviewers still use ifconfig. You must read its output, and know the ip command that replaces it on modern Linux.

ifconfig is from the old net-tools package and is not installed by default on RHEL 8+ and new Ubuntu. It shows interfaces, IPs, MAC, MTU and packet counters, and can set an IP temporarily. Use ip addr and ip link instead.

Common options

OptionWhat it does
ifconfigActive interfaces.
ifconfig -aAll, including down.
ifconfig eth0One interface.
ifconfig eth0 up/downBring up or down.
ip addrModern equivalent.
  1. Not found on a new server?
ifconfig

Output:

bash: ifconfig: command not found

Install net-tools or use ip.

  1. Install if you must.
sudo dnf install -y net-tools

Output:

Complete!

Gives ifconfig, netstat and route.

  1. Read one interface.
ifconfig eth0

Output:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9001
        inet 10.0.1.15  netmask 255.255.255.0
        ether 0a:1b:2c:3d:4e:5f
        RX errors 0  dropped 0

UP and RUNNING, IP 10.0.1.15, no errors.

  1. Same with ip.
ip -br addr show eth0

Output:

eth0  UP  10.0.1.15/24 fe80::81b:2cff:fe3d:4e5f/64

-br gives one short line.

Practise this in the tasks below: Practice tasks

Real use: A Nigdi college lab still teaches ifconfig for old exam papers, then shows the ip equivalent for real jobs.

8. iostat: Show disk I/O stats

iostat in depth: is the disk the bottleneck?

A database is slow, CPU looks idle, but load is high. Usually the disk is too busy. iostat shows how busy each disk is and how long requests wait.

iostat is in the sysstat package. It reports CPU iowait and, with -x, per-disk reads, writes, throughput, average wait (r_await, w_await) and %util. The first report is since boot; use an interval and look at later reports.

Common options

OptionWhat it does
iostatCPU and disks since boot.
iostat -x 2Extended, every 2 s.
iostat -xz 2 5Hide idle disks, 5 reports.
iostat -hHuman units.
iostat -d nvme0n1One disk.
  1. Install.
sudo dnf install -y sysstat

Output:

Complete!

Also gives sar and mpstat.

  1. Watch disks.
iostat -xz 2 3

Output:

Device   r/s   w/s  rkB/s  wkB/s r_await w_await %util
nvme1n1 820.0 410.0 52480 26240   18.40   25.10  99.2

99% util and 18 to 25 ms waits: the data disk is saturated.

  1. Check CPU iowait.
iostat -c 2 2

Output:

avg-cpu:  %user %system %iowait  %idle
           6.1     2.4    38.7   52.8

38% of CPU time waiting for disk.

  1. Find the process.
sudo iotop -o -b -n 1 | head -4

Output:

Total DISK READ: 51.2 M/s
  PID  USER  DISK READ  COMMAND
  811 mysql  49.8 M/s   mysqld

mysqld does the reading; check its slow queries.

Practise this in the tasks below: Practice tasks

Real use: A Pune stock-broking firm moved its database to faster disks after iostat showed 100% util every market open.

9. ip: Show and set addresses and routes

ip in depth: addresses, links, routes and neighbours

Every network problem starts with: does the server have the right IP, is the link up, and is the route right? ip answers all three on any modern Linux.

ip from iproute2 replaces ifconfig, route and arp. Objects: addr (IP addresses), link (interfaces), route (routing table), neigh (ARP), rule. Changes are live but not saved; save them with nmcli or netplan.

Common options

OptionWhat it does
ip aAll addresses.
ip -br aBrief, one line each.
ip linkInterfaces and state.
ip rRouting table.
ip route get IPWhich route for this IP.
ip neighARP table.
ip -s linkPacket and error counters.
ip addr add IP/24 dev XAdd an IP (temporary).
  1. Brief view.
ip -br a

Output:

lo      UNKNOWN 127.0.0.1/8 ::1/128
eth0    UP      10.0.1.15/24

eth0 is up with 10.0.1.15.

  1. Routes.
ip r

Output:

default via 10.0.1.1 dev eth0 proto dhcp metric 100
10.0.1.0/24 dev eth0 proto kernel scope link src 10.0.1.15

Internet traffic goes to gateway 10.0.1.1.

  1. Which path to the DB?
ip route get 10.0.2.15

Output:

10.0.2.15 via 10.0.1.1 dev eth0 src 10.0.1.15

Goes through the gateway.

  1. Errors on the link?
ip -s link show eth0

Output:

RX: bytes  packets  errors  dropped
 9128371   71233    0       0

Zero errors: the cable or virtual NIC is fine.

  1. Add a test IP.
sudo ip addr add 10.0.1.99/24 dev eth0; ip -br a show eth0

Output:

eth0  UP  10.0.1.15/24 10.0.1.99/24

Lost on reboot; use nmcli for permanent.

Practise this in the tasks below: Practice tasks

Real use: A Talawade factory network engineer checks ip route get to each PLC subnet when machines stop reporting.

10. iptables: Low-level firewall rules

iptables in depth: read and add packet filter rules

Docker, Kubernetes, old servers and many cloud images still use iptables rules. When traffic is blocked or a port forward fails, you must read them.

iptables manages kernel netfilter rules in tables (filter, nat, mangle) and chains (INPUT, OUTPUT, FORWARD, PREROUTING, POSTROUTING). Rules are checked top to bottom; the first match wins. On RHEL 8+ it is a front end to nftables, and firewalld is preferred.

Common options

OptionWhat it does
-L -n -vList rules, numbers, counters.
--line-numbersShow rule positions.
-A INPUT ...Append a rule.
-I INPUT 1 ...Insert at the top.
-D INPUT 3Delete rule 3.
-t nat -LNAT table.
iptables-saveDump all rules.
  1. List the input rules.
sudo iptables -L INPUT -n -v --line-numbers

Output:

Chain INPUT (policy ACCEPT)
num pkts bytes target prot source    destination
1   1200 88K  ACCEPT tcp  0.0.0.0/0 0.0.0.0/0  tcp dpt:22
2     45 2700 DROP   tcp  0.0.0.0/0 0.0.0.0/0  tcp dpt:8080

Port 8080 is dropped; 45 packets hit that rule.

  1. Allow 8080 from the office only, above the DROP.
sudo iptables -I INPUT 2 -p tcp -s 203.0.113.0/24 --dport 8080 -j ACCEPT

Inserted at position 2, so it is checked before the DROP.

  1. See Docker port forwards.
sudo iptables -t nat -L DOCKER -n

Output:

DNAT  tcp  0.0.0.0/0  0.0.0.0/0  tcp dpt:8081 to:172.17.0.2:80

Host 8081 goes to the container port 80.

  1. Back up the rules.
sudo iptables-save > /root/iptables-$(date +%F).rules

Restore with iptables-restore.

Practise this in the tasks below: Practice tasks

Real use: A Hadapsar ISP NOC reads iptables counters to prove to a customer that their packets reach the server.

11. jobs: List shell jobs

jobs in depth: list what this shell is running

You started a few commands with & or stopped them with Ctrl+Z and lost track. jobs shows them so you can bring one back or kill it.

jobs is a shell builtin. It lists jobs of the current shell only, with a job number, state (Running, Stopped, Done) and command. Use %N with fg, bg and kill. Jobs die with the shell unless you use nohup, disown or tmux.

Common options

OptionWhat it does
jobsList jobs.
jobs -lWith PIDs.
jobs -rOnly running.
jobs -sOnly stopped.
kill %2Kill job 2.
disown %1Keep job 1 after logout.
  1. Start two jobs.
tar czf /tmp/a.tgz /srv/app & sleep 900 &

Output:

[1] 5102
[2] 5103

Job numbers and PIDs.

  1. List with PIDs.
jobs -l

Output:

[1]- 5102 Running   tar czf /tmp/a.tgz /srv/app &
[2]+ 5103 Running   sleep 900 &

Both still running.

  1. Stop the sleep job.
kill %2; jobs

Output:

[1]-  Running   tar czf ...
[2]+  Terminated  sleep 900

Job 2 is gone.

  1. Keep the tar after you log out.
disown %1

The shell forgets it, so logout does not kill it.

Practise this in the tasks below: Practice tasks

Real use: A Kothrud freelance developer runs a build with & and checks jobs while writing docs in the same terminal.

12. journalctl: Read systemd logs

journalctl in depth: read systemd logs fast

A service failed to start, the server rebooted at night, or SSH logins are failing. On systemd systems all these logs are in the journal, and journalctl filters them by service, time and severity.

journalctl reads the binary journal kept by systemd-journald. It can filter by unit (-u), boot (-b), time (--since, --until), priority (-p), and follow live (-f). Without Storage=persistent, logs are lost on reboot.

Common options

OptionWhat it does
-u nginxOne service.
-fFollow live.
-b / -b -1This boot / last boot.
--since "1 hour ago"Time filter.
-p errErrors and worse.
-n 50Last 50 lines.
-o catMessage text only.
--disk-usageJournal size.
--vacuum-size=500MShrink journal.
  1. Why did nginx fail?
sudo journalctl -u nginx -n 5 --no-pager

Output:

nginx[2210]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
systemd[1]: nginx.service: Failed with result 'exit-code'.

Port 80 is already taken by another process.

  1. Errors from this boot.
sudo journalctl -b -p err --no-pager | tail -3

Output:

kernel: nvme1n1: I/O error, dev nvme1n1, sector 1024
...

A disk I/O error: check hardware.

  1. What happened last night?
sudo journalctl --since "2026-10-25 23:00" --until "2026-10-26 01:00" -p warning

Output:

(warnings and errors in that window)

Narrow to the incident window.

  1. Failed SSH logins.
sudo journalctl -u sshd --since today | grep -c "Failed password"

Output:

312

312 failed password attempts today: check fail2ban.

  1. How big is the journal?
journalctl --disk-usage

Output:

Archived and active journals take up 585.0M in the file system.

Shrink with --vacuum-size if disk is tight.

Practise this in the tasks below: Practice tasks

Real use: A Viman Nagar travel portal gives on-call engineers one command: journalctl -u booking-api -p err --since "15 min ago".

13. jq: Read and filter JSON

jq in depth: read and filter JSON on the command line

Cloud CLIs, APIs and Kubernetes all return JSON. Reading a 500-line JSON by eye is slow. jq picks the fields you need in one line.

jq is a JSON processor. A filter like .name or .items[].id walks the structure. It can select with select(), build new objects, count with length, and print raw strings with -r for use in scripts.

Common options

OptionWhat it does
jq .Pretty print.
jq .nameOne field.
jq ".items[]"Each array item.
jq -rRaw strings, no quotes.
jq "select(.x>1)"Filter items.
jq lengthCount.
jq -cCompact, one line.
  1. Pretty print an API reply.
curl -s https://api.example.in/health | jq .

Output:

{
  "status": "ok",
  "db": "up",
  "version": "2.4.1"
}

Indented and colored.

  1. One field for a script.
curl -s https://api.example.in/health | jq -r .status

Output:

ok

-r removes the quotes.

  1. Instance IDs that are running.
aws ec2 describe-instances | jq -r '.Reservations[].Instances[] | select(.State.Name=="running") | .InstanceId'

Output:

i-0a1b2c3d4e5f60718
i-0f9e8d7c6b5a40312

Walk the arrays, filter, print.

  1. Count pods not running.
kubectl get pods -o json | jq '[.items[] | select(.status.phase!="Running")] | length'

Output:

2

Wrap in [ ] to make a list, then length.

Practise this in the tasks below: Practice tasks

Real use: A Baner cloud team builds a daily cost report by piping AWS CLI JSON through jq into a CSV.

14. kill: Send a signal to a process

kill in depth: send signals to stop or reload a process

A process hangs, eats CPU, or needs to reload its config without downtime. kill sends it a signal, from a polite request to a forced stop.

kill sends a signal to a PID. The default is SIGTERM (15): please exit and clean up. SIGHUP (1) often means reload. SIGKILL (9) cannot be caught: the kernel stops the process at once, with no cleanup. Always try 15 before 9.

Common options

OptionWhat it does
kill PIDSIGTERM (15).
kill -HUP PIDReload (1).
kill -9 PIDForce stop.
kill -0 PIDIs it alive? (no signal sent)
kill -lList signals.
kill %1Kill shell job 1.
  1. Find the PID.
pgrep -a java

Output:

4121 java -jar /opt/report/report.jar

PID 4121.

  1. Ask it to stop.
kill 4121; sleep 5; kill -0 4121 && echo alive || echo gone

Output:

gone

It exited cleanly.

  1. Reload nginx config without dropping users.
sudo kill -HUP $(cat /run/nginx.pid)

Workers restart with the new config; connections stay.

  1. Last resort for a stuck process.
kill -9 4121

No cleanup: temp files and locks may remain.

Practise this in the tasks below: Practice tasks

Real use: A Kharadi bank's runbook says: kill, wait 30 seconds, take a thread dump, and only then kill -9.

15. killall: Signal processes by name

killall in depth: signal processes by name

A program started 20 worker processes and they all hang. Killing 20 PIDs one by one is slow. killall uses the name.

killall (psmisc package) sends a signal to every process with an exact name. pkill is similar but matches patterns. Be careful on shared servers: it hits every user's process of that name unless you add -u.

Common options

OptionWhat it does
killall nameSIGTERM to all with that name.
killall -u ravi nameOnly ravi's.
killall -i nameAsk for each.
killall -9 nameForce.
killall -w nameWait until they exit.
pkill -f patternMatch full command line.
  1. How many workers?
pgrep -c php-fpm

Output:

21

21 processes.

  1. Stop them and wait.
sudo killall -w php-fpm

Returns when all have exited.

  1. Only one user's.
killall -u ravi python3

Other users are not touched.

  1. Match a script name.
pkill -f "report_job.py"

killall would only see "python3"; -f matches the arguments.

Practise this in the tasks below: Practice tasks

Real use: A Hinjewadi QA lab uses killall -u tester chrome after nightly browser tests so the next run starts clean.

16. last: Show login history

last in depth: who logged in and when the server rebooted

After an incident someone asks: who was on the server, and when did it reboot? last answers from the login records.

last reads /var/log/wtmp and lists logins, logouts, reboots and shutdowns, newest first, with source IP and duration. lastb reads failed logins from /var/log/btmp. lastlog shows each user's most recent login.

Common options

OptionWhat it does
lastAll records.
last -n 10Last 10.
last raviOne user.
last rebootReboots.
last -xInclude shutdowns and runlevel changes.
last -FFull dates and times.
sudo lastbFailed logins.
  1. Recent logins.
last -n 3

Output:

ravi   pts/0  49.36.12.8   Mon Oct 26 01:02   still logged in
priya  pts/1  10.0.1.5     Sun Oct 25 22:10 - 23:40  (01:30)
reboot system boot 5.14.0-427  Sun Oct 25 21:58   still running

ravi is on now; priya stayed 1.5 hours; reboot at 21:58.

  1. When did it reboot?
last reboot | head -2

Output:

reboot system boot 5.14.0-427 Sun Oct 25 21:58 still running
reboot system boot 5.14.0-427 Tue Oct 20 03:00 - 21:57 (5+18:57)

Up almost 6 days before last night.

  1. Failed login attempts.
sudo lastb -n 3

Output:

root ssh:notty 185.220.1.2 Mon Oct 26 00:59 - 00:59
admin ssh:notty 185.220.1.2 Mon Oct 26 00:59 - 00:59

A bot is guessing passwords.

  1. Last login per user.
lastlog | grep -v "Never"

Output:

Username Port From        Latest
ravi     pts/0 49.36.12.8  Mon Oct 26 01:02:11

Find unused accounts to disable.

Practise this in the tasks below: Practice tasks

Real use: A Yerawada BPO's audit report includes last -F output to show which admin was on each server during a change.

17. less: Page through a file

less in depth: read big files and outputs page by page

A log of 2 million lines will flood your screen with cat and freeze an editor. less opens it instantly and lets you search, jump and follow.

less is a pager: it shows one screen at a time and reads only what it needs. Keys: Space next page, b back, /word search, n next match, G end, g start, F follow like tail -f, q quit. man uses less.

Common options

OptionWhat it does
less fOpen.
less -N fLine numbers.
less -S fDo not wrap long lines.
less +F fStart in follow mode.
less -iSearch ignores case.
cmd | lessPage through output.
  1. Open a big log.
less -N /var/log/app/app.log

Output:

      1 2026-10-26 00:00:01 INFO start
      2 2026-10-26 00:00:02 INFO db connected
:

Opens at once, even for gigabytes.

  1. Search for an error.
/ERROR  then n

Output:

2026-10-26 00:41:10 ERROR payment timeout id=7781

n jumps to the next match, N goes back.

  1. Wide CSV without wrapping.
less -S sales.csv

Output:

date,region,store,amount,tax,discount,channel...

Use the arrow keys to scroll sideways.

  1. Follow a live log.
less +F /var/log/nginx/access.log

Output:

Waiting for data... (interrupt to abort)

Ctrl+C stops following so you can search; F starts again.

Practise this in the tasks below: Practice tasks

Real use: A Magarpatta support desk teaches less +F instead of tail -f, because you can pause and search without losing the log.

ln in depth: hard links and symbolic links

You want one stable path like /opt/app/current pointing to the latest release, or a config in two places without copying. Links do this, and switching a release becomes one command.

ln creates links. A hard link is a second name for the same inode (same data); it cannot cross filesystems or point to folders. A symbolic link (-s) is a small file holding a path; it can point anywhere but breaks if the target is removed.

Common options

OptionWhat it does
ln target nameHard link.
ln -s target nameSymbolic link.
ln -sf target nameReplace an existing link.
ln -sfn dir linkReplace a link to a folder.
readlink -f linkWhere does it really point?
find -L . -type lFind broken links.
  1. Point current to a release.
sudo ln -s /opt/app/releases/v41 /opt/app/current; ls -l /opt/app/current

Output:

lrwxrwxrwx 1 root root 24 Oct 26 01:30 /opt/app/current -> /opt/app/releases/v41

The arrow shows the target.

  1. Deploy v42 by switching the link.
sudo ln -sfn /opt/app/releases/v42 /opt/app/current; readlink -f /opt/app/current

Output:

/opt/app/releases/v42

-n treats the old link as a file, so it is replaced, not entered.

  1. Hard link: same inode.
ln data.csv data-copy.csv; ls -li data*.csv

Output:

1310722 -rw-r--r-- 2 ravi ravi 9.1M data.csv
1310722 -rw-r--r-- 2 ravi ravi 9.1M data-copy.csv

Same inode number, link count 2, no extra space.

  1. Find broken links.
find /etc -xtype l

Output:

/etc/nginx/sites-enabled/old-site

The target was deleted; remove or fix the link.

Practise this in the tasks below: Practice tasks

Real use: A Baner e-commerce team rolls back a bad release in two seconds by pointing the current symlink back to the previous folder.

19. locate: Find files fast from a database

locate in depth: find files instantly from a database

find over the whole disk can take minutes. When you only need "where is a file called X", locate answers in milliseconds.

locate (mlocate or plocate package) searches a database of file names built by updatedb, usually once a day by a timer. It is fast but can be out of date: new files are missing and deleted files may still show. Run sudo updatedb to refresh.

Common options

OptionWhat it does
locate nameSearch.
locate -i nameIgnore case.
locate -c nameCount only.
locate -e nameOnly files that still exist.
locate -r regexRegex.
sudo updatedbRebuild the database.
  1. Install and build.
sudo dnf install -y mlocate && sudo updatedb

Output:

Complete!

The first build reads the whole disk once.

  1. Find a file.
locate sshd_config

Output:

/etc/ssh/sshd_config
/usr/share/man/man5/sshd_config.5.gz

Instant, every path containing the name.

  1. A file you just created is missing.
touch /tmp/newfile.txt; locate newfile.txt; echo "code=$?"

Output:

code=1

The database is older than the file.

  1. Refresh and retry.
sudo updatedb; locate newfile.txt

Output:

/tmp/newfile.txt

Now it is found.

Practise this in the tasks below: Practice tasks

Real use: A Deccan web host uses locate wp-config.php to find every WordPress site on a shared server in a second.

20. logger: Write a message to the system log

logger in depth: write your own messages to the system log

Your backup script ran at 2 AM. Did it work? If it writes to the system log, the result sits next to every other event, reaches central logging and can trigger alerts.

logger sends a message to syslog and the systemd journal. -t sets a tag (shown as the program name), -p sets facility and priority like user.err. Read it back with journalctl -t tag or in /var/log/messages.

Common options

OptionWhat it does
logger "msg"Write a message.
logger -t backup "msg"With a tag.
logger -p user.err "msg"With priority.
logger -s "msg"Also print to the screen.
logger -f fileLog each line of a file.
  1. Log a success.
logger -t backup "nightly backup ok size=4.2G"

Nothing is printed; it went to the log.

  1. Read it.
journalctl -t backup -n 1 --no-pager

Output:

Oct 26 02:00:41 web01 backup[5541]: nightly backup ok size=4.2G

Tag, PID and time are added.

  1. Log a failure with error priority.
logger -t backup -p user.err "nightly backup FAILED rc=23"

Monitoring that watches err level will alert.

  1. Use it in a script.
rsync -a /srv/ backup01:/b/ && logger -t backup ok || logger -t backup -p user.err failed

One line, both outcomes logged.

Practise this in the tasks below: Practice tasks

Real use: A Nashik Phata cold-storage company's sensor scripts log temperatures with logger so alerts reach the central server.

21. logrotate: Rotate and compress logs

logrotate in depth: stop logs from filling the disk

An app writes 2 GB of logs a day. Without rotation the disk fills in a week and the app crashes. logrotate renames, compresses and deletes old logs on a schedule.

logrotate runs daily (cron or a systemd timer) and reads /etc/logrotate.conf plus files in /etc/logrotate.d/. Each block lists log paths and rules: daily or weekly, rotate N, compress, missingok, notifempty, and postrotate to tell the app to reopen logs. copytruncate is for apps that cannot reopen.

Common options

OptionWhat it does
daily / weeklyHow often.
rotate 14Keep 14 old files.
compressgzip old files.
delaycompressKeep the newest old file unzipped.
maxsize 500MRotate early if big.
copytruncateCopy, then empty the file.
logrotate -d confDry run (debug).
logrotate -f confForce now.
  1. Write a rule for the app.
printf '/var/log/app/*.log {\n daily\n rotate 14\n compress\n delaycompress\n missingok\n notifempty\n maxsize 500M\n copytruncate\n}\n' | sudo tee /etc/logrotate.d/app

Output:

/var/log/app/*.log {
 daily
 rotate 14
 ...

Daily, keep 14, compress, or earlier at 500 MB.

  1. Dry run.
sudo logrotate -d /etc/logrotate.d/app

Output:

considering log /var/log/app/app.log
  log needs rotating

Shows what would happen; changes nothing.

  1. Force once.
sudo logrotate -f /etc/logrotate.d/app; ls /var/log/app

Output:

app.log  app.log.1

Rotated now; next run compresses app.log.1.

  1. When did it last run?
sudo grep app.log /var/lib/logrotate/logrotate.status

Output:

"/var/log/app/app.log" 2026-10-26-1:35:0

The state file records each log.

Practise this in the tasks below: Practice tasks

Real use: A Hinjewadi telecom billing team uses maxsize 1G with hourly logrotate during month-end runs, when logs grow fast.

22. ls: List files

ls in depth: list files the way admins do

Every task starts with "what is in this folder": sizes, owners, permissions, newest files, hidden files. ls -l is the first thing interviewers expect you to read.

ls lists folder contents. -l gives the long format: type and permissions, link count, owner, group, size, change time, name. -a shows hidden dot files, -h human sizes, -t sorts by time, -S by size, -r reverses, -d shows the folder itself, -i inode, -Z SELinux label.

Common options

OptionWhat it does
-lLong format.
-a / -AHidden files (A skips . and ..).
-hHuman sizes.
-tNewest first.
-SBiggest first.
-rReverse.
-RRecursive.
-dThe folder itself.
-iInode numbers.
-ZSELinux context.
--time-style=long-isoClear dates.
  1. Read the long format.
ls -lh /etc/ssh/sshd_config

Output:

-rw-------. 1 root root 3.6K Oct 20 10:12 /etc/ssh/sshd_config

- file; rw for root only; . means an SELinux label; 3.6 KB.

  1. Newest files first.
ls -lt /var/log | head -4

Output:

total 98340
-rw-r----- 1 root root 2.1M Oct 26 01:40 secure
-rw-r----- 1 root root 8.4M Oct 26 01:40 messages
-rw------- 1 root root  12K Oct 26 01:30 cron

Which logs are being written now.

  1. Biggest first, hidden too.
ls -lAhS ~ | head -4

Output:

total 2.2G
-rw-r--r-- 1 ravi ravi 2.0G Oct 12 old.iso
-rw------- 1 ravi ravi  41K Oct 26 .bash_history

Find the space hog in a home folder.

  1. The folder, not its contents.
ls -ld /srv/devs

Output:

drwxrws--- 2 root devs 4096 Oct 26 01:10 /srv/devs

s in the group part is setgid.

  1. SELinux labels.
ls -Z /var/www/html

Output:

unconfined_u:object_r:httpd_sys_content_t:s0 index.html

httpd_sys_content_t lets the web server read it.

Practise this in the tasks below: Practice tasks

Real use: A Kothrud web agency's first check on any 403 error is ls -lZ on the web folder.

23. lsblk: List block devices

Read the storage tree as physical or virtual devices with subdivisions below them. A row marked disk identifies a device, and an indented row marked part belongs to it. A row with mount point / holds the running system. Find your lab device by type, size and identifier before choosing where to create storage. Its position in the list may change.

lsblk in depth: see disks, partitions and mounts as a tree

Before you format, mount, extend or dd anything, you must know which disk is which. lsblk shows every block device, its size and where it is mounted, in a clear tree.

lsblk reads sysfs and lists disks, partitions, LVM volumes, RAID and loop devices. -f adds filesystem type, label and UUID; -o picks columns. It changes nothing, so it is always safe to run.

Common options

OptionWhat it does
lsblkTree of devices.
lsblk -fFilesystems and UUIDs.
lsblk -o NAME,SIZE,TYPE,MOUNTPOINTSChosen columns.
lsblk -dDisks only.
lsblk -pFull /dev paths.
lsblk -JJSON output.
  1. See everything.
lsblk

Output:

NAME          SIZE TYPE MOUNTPOINTS
nvme0n1        20G disk
├─nvme0n1p1     1G part /boot
└─nvme0n1p2    19G part
  ├─rl-root    17G lvm  /
  └─rl-swap     2G lvm  [SWAP]
nvme1n1        50G disk

The second disk nvme1n1 has no partitions or mounts: it is the new one.

  1. Filesystems and UUIDs for fstab.
lsblk -f /dev/nvme1n1

Output:

NAME      FSTYPE UUID                                 MOUNTPOINTS
nvme1n1p1 xfs    7c1e2f3a-9b8d-4e5f-a1b2-c3d4e5f60718 /data

Use the UUID in /etc/fstab, not the device name.

  1. Disks only.
lsblk -d -o NAME,SIZE,MODEL

Output:

NAME    SIZE MODEL
nvme0n1  20G Amazon Elastic Block Store
nvme1n1  50G Amazon Elastic Block Store

Quick inventory.

  1. After growing a cloud disk.
lsblk /dev/nvme1n1

Output:

nvme1n1      80G disk
└─nvme1n1p1  50G part /data

Disk is 80G but the partition is still 50G: grow it with growpart.

Practise this in the tasks below: Practice tasks

Real use: A Hinjewadi data team runs lsblk before every dd and mkfs; it is the first line of their disk runbook.

24. lscpu: Show CPU details

lscpu in depth: what CPU does this server have?

Sizing a database, licensing software per core, or checking if a VM got the cores you paid for all need CPU facts. lscpu shows them neatly.

lscpu reads /proc/cpuinfo and sysfs and summarizes architecture, CPU count, threads per core, cores per socket, sockets, model, speed, caches, NUMA nodes and virtualization.

Common options

OptionWhat it does
lscpuSummary.
lscpu -eOne line per CPU.
lscpu -JJSON.
nprocJust the CPU count.
lscpu | grep -i numaNUMA layout.
  1. Summary.
lscpu | grep -E "^(Architecture|CPU\(s\)|Thread|Core|Socket|Model name)"

Output:

Architecture:            x86_64
CPU(s):                  4
Model name:              Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
Thread(s) per core:      2
Core(s) per socket:      2
Socket(s):               1

4 vCPUs = 2 cores x 2 threads.

  1. Just the count for a script.
nproc

Output:

4

Use it to set worker counts, e.g. make -j$(nproc).

  1. Is it a VM?
lscpu | grep -i hypervisor

Output:

Hypervisor vendor:       KVM

Running on KVM (AWS Nitro).

  1. ARM or Intel?
lscpu | head -1

Output:

Architecture:            aarch64

aarch64 means ARM (like AWS Graviton): use ARM images.

Practise this in the tasks below: Practice tasks

Real use: A Pune software vendor checks lscpu cores before quoting a per-core licence to a bank.

25. lsof: List open files

A removed name can leave a file open in a process. Compare the lab filesystem’s usage with what is visible by name. lsof can connect the still-open file to a process, even when it has no directory entry. Let your test process close it and repeat the space check. That last step shows why hand-checking the folder alone did not locate all allocated blocks.

lsof in depth: list open files, ports and deleted files

Disk full but du shows little, a port is busy, or "too many open files" errors appear. All three are about open files, and lsof shows them.

In Linux everything is a file: regular files, folders, sockets, pipes and devices. lsof lists them per process with PID, user, file descriptor and name. Filters: -p PID, -u user, -i network, +D folder, +L1 deleted but open.

Common options

OptionWhat it does
lsof -i :80Who uses port 80.
lsof -i -P -nAll network files, numeric.
lsof -p PIDFiles of a process.
lsof -u raviFiles of a user.
lsof +D /var/logFiles open in a folder.
lsof +L1Deleted but still open.
  1. Who listens on 443?
sudo lsof -i :443 -sTCP:LISTEN -P -n

Output:

COMMAND  PID USER FD  TYPE NODE NAME
nginx   1043 root 7u  IPv4 TCP  *:443 (LISTEN)

nginx, PID 1043.

  1. Disk full: find deleted open files.
sudo lsof +L1 | head -3

Output:

COMMAND  PID USER FD  SIZE/OFF NLINK NAME
java    4121 app  12w 7340032000  0 /var/log/app/debug.log (deleted)

7 GB still held by java. Restart it (or truncate the fd) to free space.

  1. How many files does a process have open?
sudo lsof -p 4121 | wc -l

Output:

1019

Close to a 1024 limit: raise LimitNOFILE.

  1. Connections to the database.
sudo lsof -i TCP:5432 -P -n | grep -c ESTABLISHED

Output:

48

48 open DB connections.

Practise this in the tasks below: Practice tasks

Real use: A Wakad SaaS company found a 40 GB deleted log held open by a crashed worker using lsof +L1, at 3 AM, without a reboot.

26. lvcreate: Create an LVM logical volume

lvcreate in depth: create LVM logical volumes

Partitions are hard to resize. With LVM you pool disks into a volume group and cut flexible logical volumes that you can grow later, even online. lvcreate makes those volumes.

LVM has three layers: physical volumes (pvcreate on a disk or partition), a volume group (vgcreate) that pools them, and logical volumes (lvcreate) that you format and mount. -L sets a size, -l uses extents or a percent like 100%FREE, -n names it, -s makes a snapshot.

Common options

OptionWhat it does
-L 20GSize.
-l 100%FREEUse all free space.
-n dataName.
-s -L 5G -n snap vg/lvSnapshot.
lvsList volumes.
lvextend -r -L +10G vg/lvGrow and resize the filesystem.
  1. Prepare the disk and group.
sudo pvcreate /dev/nvme1n1 && sudo vgcreate vgdata /dev/nvme1n1

Output:

Physical volume "/dev/nvme1n1" successfully created.
Volume group "vgdata" successfully created

50 GB pool named vgdata.

  1. Create a 20 GB volume.
sudo lvcreate -L 20G -n lvapp vgdata

Output:

Logical volume "lvapp" created.

Device is /dev/vgdata/lvapp.

  1. Format and mount.
sudo mkfs.xfs /dev/vgdata/lvapp && sudo mkdir -p /app && sudo mount /dev/vgdata/lvapp /app && df -h /app

Output:

/dev/mapper/vgdata-lvapp   20G  175M   20G   1% /app

Ready to use; add it to /etc/fstab.

  1. Grow it later, online.
sudo lvextend -r -L +10G /dev/vgdata/lvapp

Output:

Size of logical volume vgdata/lvapp changed from 20.00 GiB to 30.00 GiB.
data blocks changed from 5242880 to 7864320

-r grows the filesystem too. No downtime.

  1. Check.
sudo lvs

Output:

  LV    VG     Attr       LSize
  lvapp vgdata -wi-ao---- 30.00g

30 GB, active and open.

Practise this in the tasks below: Practice tasks

Real use: A Pune hospital PACS server grows its image volume with lvextend every quarter without stopping the radiology team.

27. Real examples from many industries

The same Linux skill shows up in every kind of company. Seeing it in many places helps you remember it.

Each row is a made-up team. It shows who uses this and how.

Team and cityHow they use itCommand
Kiran, SRE, KharadiReads errors from the last boot after every rebootjournalctl -b -1 -p err
Anjali, fintech, MagarpattaReads build versions from JSONjq -r .version package.json
Rohit, SaaS, BanerDeploys by switching a symlinkln -sfn /srv/releases/v43 /srv/current
Priya, cloud, HinjewadiChecks disks before any mkfslsblk -f
Amol, ERP, PimpriSnapshots the DB volume before upgradeslvcreate -s -L 5G -n db-pre vg01/db
Sneha, bank, CampPrints login history for auditlast -n 50

28. Common errors and how to fix them

Everyone hits these errors. Knowing the cause saves hours.

Read the exact message first. Then match it to a row below.

Error you seeWhy it happensHow to fix
Cannot find device "eth1"Interface name is different on this serverList interfaces first.
ip -br link
ifconfig: command not foundnet-tools not installedUse ip, or install net-tools.
ip -br a
iptables: Bad rule (does a matching rule exist in that chain?)Deleting a rule that does not existDelete by number.
iptables -L INPUT --line-numbers
New iptables ACCEPT rule never matchesAppended after a DROP ruleInsert above the DROP.
iptables -I INPUT 3 -p tcp --dport 80 -j ACCEPT
No journal files were found.Journal not kept or no permissionUse sudo; create /var/log/journal for persistence.
mkdir -p /var/log/journal; systemctl restart systemd-journald
jq: error: Cannot index array with "name"Input is a list, not an objectAdd .[] first.
jq '.[].name' f.json
parse error: Invalid numeric literal at line 1, column 10Input is not JSON (often an HTML error page)Check the raw reply first.
curl -s URL | head -c 200
kill: (3120) - Operation not permittedProcess belongs to another userUse sudo, after checking the owner.
ps -o user,pid,cmd -p 3120
ln: failed to create symbolic link '/opt/app/current': File existsLink already thereReplace it with -sfn.
ln -sfn /opt/app/releases/v43 /opt/app/current
locate: can not stat () `/var/lib/plocate/plocate.db'Database not built yetRun updatedb.
updatedb
error: skipping "/var/log/app/app.log" because parent directory has insecure permissionslogrotate sees a group or world writable folderAdd a su line in the rule.
su app app
Volume group "vg01" has insufficient free spaceAsked for more than is freeCheck vgs; use 100%FREE or add a disk.
vgs; lvcreate -l 100%FREE -n data vg01

29. Troubleshooting step by step

When a Part 4 command does not do what you expect, go through these steps.

Go top to bottom. Stop at the first step that shows the problem.

  1. Are you root where needed?
id -u
  1. Is the command installed?
command -v htop iostat jq lsof
  1. Is the name right (interface, unit, VG)?
ip -br link; systemctl list-units --type=service | head; vgs
  1. Is the change only until reboot?
cat /etc/hostname; nmcli con show
  1. Does the log say more?
journalctl -xe -n 20
  1. Is the input what you think?
head -c 200 file.json

30. Lab 1: Disk full but du looks small

Create a deleted-but-open file, find it with lsof, free the space, and add log rotation.

A full hands-on lab. Run every step on a test Linux machine (an EC2 instance, a VM, or WSL).

  1. Write a big file and keep it open.
dd if=/dev/zero of=/tmp/big.log bs=1M count=300 status=none; tail -f /tmp/big.log > /dev/null &

Output:

[1] 7001
  1. Delete it.
rm /tmp/big.log; df -h /tmp | tail -1

Output:

tmpfs 1.8G 300M 1.5G 17% /tmp
  1. Find it.
lsof +L1 2>/dev/null | grep big.log

Output:

tail 7001 ravi 3r REG 300M 0 /tmp/big.log (deleted)
  1. Free the space.
kill %1; df -h /tmp | tail -1

Output:

tmpfs 1.8G 0 1.8G 0% /tmp
  1. Dry run a logrotate rule.
sudo logrotate -d /etc/logrotate.d/app

Output:

considering log /var/log/app/app.log

31. Lab 2: Add storage with LVM on a loop disk

Record which loop device maps to the backing file you created. Check it with losetup -l before writing a PV label. After making the LV, read lvs for the allocation and findmnt for the folder that accesses its filesystem. Together those two outputs trace the learner’s practice file all the way from a simulated disk to a path where data can be written.

Make a practice disk from a file, build LVM on it, mount it and grow it.

A full hands-on lab. Run every step on a test Linux machine (an EC2 instance, a VM, or WSL).

  1. Make a 1 GB practice disk.
truncate -s 1G /tmp/disk.img && sudo losetup -f --show /tmp/disk.img

Output:

/dev/loop0
  1. See it.
lsblk /dev/loop0

Output:

loop0 7:0 0 1G 0 loop
  1. PV, VG and LV.
sudo pvcreate /dev/loop0 && sudo vgcreate vglab /dev/loop0 && sudo lvcreate -L 400M -n data vglab

Output:

Logical volume "data" created.
  1. Format and mount.
sudo mkfs.xfs -q /dev/vglab/data && sudo mkdir -p /mnt/lab && sudo mount /dev/vglab/data /mnt/lab && df -h /mnt/lab | tail -1

Output:

/dev/mapper/vglab-data 395M 24M 371M 7% /mnt/lab
  1. Grow it online.
sudo lvextend -r -L +200M /dev/vglab/data && df -h /mnt/lab | tail -1

Output:

/dev/mapper/vglab-data 595M 25M 570M 5% /mnt/lab

Ravindra Bagale's Tip

Keep a personal incident checklist: hostname, ip -br a, journalctl -p err -b, lsof -i, iostat -x, df -h. Run it in the same order every time and you will rarely miss the cause.

32. Frequently asked questions

Q. ip or ifconfig?

ip. ifconfig is old and often not installed.

Q. kill -9 first?

No. Try plain kill first so the app can clean up.

Q. Hard link or symlink?

Symlink for most uses; hard links cannot cross filesystems or point to folders.

Q. Why does locate miss a new file?

Its database updates once a day; run updatedb.

Q. Where are old journals?

In /var/log/journal if it exists; otherwise lost at reboot.

Q. Can I shrink an XFS volume?

No. XFS can only grow. Plan sizes or use ext4 if you must shrink.

33. Interview questions and answers

Beginner level

Q. How do you see your IP?

ip -br a.

Q. How do you set a permanent hostname?

hostnamectl set-hostname name.

Q. How do you list files newest first?

ls -lt.

Q. How do you see logs of one service?

journalctl -u name.

Mid level level

Q. Which process uses port 443?

lsof -i :443 or ss -ltnp.

Q. SIGTERM vs SIGKILL?

TERM can be caught and allows cleanup; KILL cannot.

Q. Read only the version from JSON in a script.

jq -r .version file.json.

Q. How do you know if the disk is the bottleneck?

iostat -x: high %util and await, plus high iowait.

Senior level

Q. Grow /data by 10 GB with no downtime.

Add disk, pvcreate, vgextend, lvextend -r -L +10G.

Q. The server rebooted overnight. How do you find why?

last reboot, journalctl -b -1 -p err, check for OOM or kernel panic.

Q. An iptables ACCEPT rule does nothing. Why?

It sits below a DROP; list with --line-numbers and insert above.

Q. Zero-downtime deploy and rollback on one server?

Release folders plus ln -sfn to switch current.

Try at home

  1. Run the incident check on your VM and save the output.
  2. Do Lab 2 on a loop disk and then remove it with lvremove, vgremove and losetup -d.
  3. Pretty print any public API reply with jq.
  4. Make a release symlink, switch it twice and check with readlink -f.

Practise this chapter

Interview questions and answers

How do lsblk, lsof and df help with a disk-space incident?

Use df to find the affected filesystem, and lsblk to relate it to the device layout. If names in that filesystem do not explain the usage, look for open unlinked files with lsof. Recheck the same mount when the file is closed.

Check your understanding

Choose an answer, then compare your reasoning with the explanation.

0 of 3 answered correctly
1. What does a mount point of / identify in the lsblk tree?

Answer and explanation

C. The filesystem serving the running system’s root directory

The root mount is in use by the system. Use a separately verified lab device for the exercise.

2. Before pvcreate on a loop device, what should you confirm?

Answer and explanation

A. Its backing file matches the image just created for the exercise

Loop numbers can vary. Check the actual mapping before writing labels.

3. After lvcreate, what proves it is mounted where you expect?

Answer and explanation

A. findmnt shows the logical device and correct target directory

lvs reports allocation. findmnt reports the active filesystem mount.

Practice Tasks

Practice checks run in your browser. They check the answer for this exercise; they do not create resources or connect to your AWS account.

About this scenario

Vidarbha Cotton Mills is a textiles business in Nagpur. Ganesh Wankhede looks after its IT and cloud work. They count money in INR and run their AWS resources in the ap-south-1 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.

0 / 22

Easy Set the name

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

Set the permanent host name to app02.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Show IPs

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

Print all IP addresses of this machine with hostname.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Group names

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

Print the group names of the user deploy.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Route to a host

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

Show the route used to reach 192.168.10.20.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy One service log

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

Show the journal for the service crond.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Polite stop

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

Send the default stop signal to PID 4410.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Reboot history

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

Show the last 4 system reboots.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Make a symlink

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

Create a symlink named /usr/local/bin/kc pointing to /opt/kube/kubectl.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Disks with UUIDs

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

List the device /dev/xvdf with filesystem type and UUID.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Tagged log line

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

Write the message deploy done to the system log with the tag ci.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Link counters

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

Show packet statistics for the interface ens5.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Disk stats

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

Show extended disk stats every 5 seconds, 3 times.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Since a time

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

Show journal entries since 30 minutes ago.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Raw value

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

Print the raw value of the key region from cfg.json.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Kill by name for a user

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

Stop all processes named node owned by the user web.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Biggest first

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

List /var/tmp in long format, human sizes, biggest first.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Folder itself

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

Show the permissions of the folder /opt itself, not its contents.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Who uses a port

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

Show which process uses port 3306.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Hard Insert at top

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

Insert a rule at the top of INPUT that accepts tcp port 9100.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Hard Errors this boot for a unit

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

Show only error priority messages from this boot for sshd.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Hard Count items

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

Print how many items are in the list users in team.json.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Hard Use all free space

BIZ runs Linux servers and uses commands from hostname to lvcreate daily.

Create a logical volume named logs in vgdata using all free space.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

In short

  1. hostnamectl for a permanent name.
  2. ip -br a, ip route, ip neigh.
  3. journalctl -u, -b, -p, --since.
  4. kill: TERM first, KILL last.
  5. lsof +L1 for deleted but open files.
  6. LVM: pvcreate, vgcreate, lvcreate, lvextend -r.

Revision, comparison and interview cards

Revise this lesson in a few minutes. Save the cards on your phone or download them as PNG files. The QR code on each card opens this lesson.

First 5 minutes of an incident. Right server? Network up? What failed? Who holds the port?
Revision card: First 5 minutes of an incident · Download PNG · Open card page
Add storage with LVM. See disks. Disk to pool. Make a volume. Grow online.
Revision card: Add storage with LVM · Download PNG · Open card page
ip vs ifconfig. Modern iproute2 tool. / Old net-tools tool.
Comparison: ip vs ifconfig · Download PNG · Open card page
kill vs killall. Signals one PID. / Signals all by name.
Comparison: kill vs killall · Download PNG · Open card page
SIGTERM or SIGKILL?. TERM lets the app clean up. KILL cannot be caught. Use KILL last.
Interview card: SIGTERM or SIGKILL? · Download PNG · Open card page
Why did the server reboot?. When did it boot? Errors from last boot. Look for OOM.
Interview card: Why did the server reboot? · Download PNG · Open card page
Hard link vs symlink?. Hard: same inode, same FS. Symlink: a path, can break. Switch a release.
Interview card: Hard link vs symlink? · Download PNG · Open card page
iptables ACCEPT does nothing?. First match wins. List with numbers. Insert above DROP.
Interview card: iptables ACCEPT does nothing? · Download PNG · Open card page

More cards: Ravi Sir's Cards.