Linux Survival Basics
Read-onlyCheck Owner and Mode in One Line
A path exists but access fails, and you need owner, group, and mode quickly.
Command
stat -c '%A %U:%G %n' /var/www/example/index.html
Before you run this
System impact: Read-only. Low when scoped to the shown target.
When not to use it: Do not stop at the file if parent directories may block access.
Expected output
A compact permission and ownership line.
System impact
Read-only. Nothing changes. The command prints permissions, owner, group, and filename.
May require elevated permissions on protected paths or service-owned files.
Recovery / rollback: no state is changed.
When to use it
Use this before changing file permissions or ownership.
When not to use it
Do not stop at the file if parent directories may block access.
Watch this command run
Command transcript
This sanitized transcript shows the commands and output shape without exposing host details.
$ stat -c '%A %U:%G %n' /var/www/example/index.html
-rw-r----- root:root /var/www/example/index.html
$ namei -l /var/www/example/index.html
f: /var/www/example/index.html
drwxr-xr-x root root /
drwxr-xr-x root root var
drwxr-x--- root root www
drwxr-x--- root root example
-rw-r----- root root index.html
$ ls -ld /var/www /var/www/example
drwxr-x--- 3 root root 60 Jun 26 00:27 /var/www
drwxr-x--- 2 root root 60 Jun 26 00:27 /var/www/example
View commands shown
These are the commands shown in the sanitized transcript.
Commands shown
stat -c '%A %U:%G %n' /var/www/example/index.htmlnamei -l /var/www/example/index.htmlls -ld /var/www /var/www/example
next steps
Related commands
Inspect Permissions Before Changing Them
The permission fix was easy. Knowing what not to chmod was the hard part.
namei -l /var/www/example/index.html
Find Errors Before Reading Every Log Line
The error was in the log. The problem was finding it without reading noise.
grep -iE 'error|failed|denied|timeout' /var/log/nginx/error.log | tail -40
Find the Exact Log Line Before You Scroll
The error was there. The useful part was knowing exactly where it was.
grep -inE 'error|failed|denied|timeout' /var/log/nginx/error.log
Trace Every Parent Directory on a Permission Denial
The file mode can look fine while a parent directory blocks the whole path.
namei -l fixtures/perm-audit/current/app/config/prod.token
Find Which Folder Is Filling the Disk
The disk was full. The fastest clue was the folder, not the file.
du -sh /var/* 2>/dev/null | sort -h
Study mapping
Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.
Useful for
- LPIC-1 style command-line practice
- LFCS style performance tasks
- Linux+ style troubleshooting review
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.