Back to commands

Linux Survival Basics

Read-only

Check 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.

demo@lab:~$

$ 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

  1. stat -c '%A %U:%G %n' /var/www/example/index.html
  2. namei -l /var/www/example/index.html
  3. ls -ld /var/www /var/www/example

next steps

Related commands

Linux Survival Basics Can be slow

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
Linux Survival Basics Can be slow

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
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.

  • lpic1:103-gnu-unix-commands
  • lfcs:essential-commands
  • linuxplus:automation-scripting
  • linuxplus:provisional
  • risk:read-only

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.