Unlock Hidden Linux Command Options: Practical Tips for ls, find, less, and More
This guide reveals often‑overlooked Linux command parameters—such as sorting files with ls, filtering with find, viewing logs with less, and using -r, -p, -C, -d options across common utilities—providing concrete examples and code snippets to boost everyday shell productivity.
1. ls command options
Use -S to sort files by size and combine with -r for reverse order. ls -lhS Reverse (largest to smallest):
ls -lhSr-t: sort by modification time
ls -lhtFind files modified today:
ls -l / --time-style=+%D | grep `date +%D`2. find command options
-sizeis frequently used; other useful flags are highlighted below.
-iname
Case‑insensitive name matching.
find . -iname get_test-name
Case‑sensitive name matching (contrast with -iname).
-type
Search by file type.
find . -type f
find . -type d-empty
Locate empty files.
find . -type f -empty-maxdepth
Limit recursion depth.
find /etc -maxdepth 2 -name passwd3. less command options
Prefer less over vim for quick log viewing.
-N
Show line numbers.
less -N test.logFor small files, cat -n also displays line numbers.
+F
Equivalent to tail -f or tailf, continuously appending output.
less +F test.log4. -r option examples
grep
Recursively search for a pattern in all files under a directory.
grep -r "xxx" /homescp
Copy directories recursively.
scp -r [email protected]:/home/config/ .5. -p option examples
mkdir
Create nested directories in one command.
mkdir -p /home/test/logtar cp
Preserve file attributes while archiving.
tar -cpvzf mysql.tar.gz /var/lib/mysql6. -C and -d options for extraction
Extract archives directly into a target directory.
tar
tar -xzvf tt.tar.gz -C /homeAlternative without -C:
cd /home
tar -xzvf tt.tar.gzOr extract then move:
tar -xzvf tt.tar.gz
mv tt /homeunzip
unzip -d /home tt.zipSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
