Explore how Jenkins versions have shaped modern CI/CD practices. This comprehensive guide traces the …
13 Quirky 'ls' Command Tricks Every Linux User Should Know: Hidden Command-Line Magic 13 Quirky 'ls' Command Tricks Every Linux User Should Know: Hidden Command-Line Magic

Summary
Beyond Basic Listing: The Quirky Side of ’ls'
The ls
command is a daily companion for Linux users, but hidden within its man pages are genuinely quirky options that most people never discover. While everyone knows ls -l
or ls -a
, this guide explores the truly unusual ls command tricks built right into the command itself—no third-party tools required.
In this exploration of 13 quirky techniques, we’ll reveal the strange, wonderful, and occasionally bizarre options that the ls command’s developers buried in the codebase. These aren’t the options covered in beginner tutorials—they’re the peculiar flags and parameters that even experienced Linux users might raise an eyebrow at.
Let’s dive into these genuinely quirky ls command tricks that showcase the delightful eccentricity of Linux command design.
Expand your knowledge with Why You Need SQS in Your YouTube-like System: Beyond Basic Architecture
1. The Quote Everything Option (-Q)
One of the quirkiest ls command tricks involves the -Q
option, which wraps every filename in double quotes:
ls -Q
This produces output like:
"document.txt" "image.jpg" "script.sh" "strange file name.txt"
This odd option becomes genuinely useful when scripting with files that might contain spaces or special characters. Combined with other options:
Deepen your understanding in Comprehensive Guide to Linux ls Command: Options, Examples, and Best Practices
ls -laQ
--quoting-style
option with values like shell
, shell-always
, c
, and escape
.2. Classify Files with Strange Symbols (-F)
The -F
option appends strange symbols to different types of files:
ls -F
Output appears with slashes, asterisks, and other indicators:
directory/ executable* regular-file socket= symlink@
This quirky classification scheme uses:
/
for directories*
for executables@
for symbolic links=
for sockets|
for named pipes>
for doors (in some systems)
For even quirkier control, try:
ls --indicator-style=classify
Or the truly unusual:
Explore this further in How to Replace Text in Multiple Files with Sed: A Step-by-Step Guide
ls --indicator-style=file-type
3. Sort by Extension, Not Name (-X)
Most users sort alphabetically, but the quirky -X
option sorts files by extension instead:
ls -X
This creates unusual groupings where all .txt
files appear together regardless of filename, followed by all .jpg
files, and so on. For a truly strange sorting experience, combine with reverse ordering:
ls -rX
This sorts files by extension but in reverse alphabetical order of extensions. Files without extensions come last in normal mode but first in reverse mode.
Discover related concepts in Complete Guide to Extracting Filenames from Paths in Bash
4. Hide Specific Patterns (–hide)
The peculiar --hide
option lets you selectively hide files matching a pattern:
ls --hide="*.txt"
What makes this quirky is that you can combine multiple patterns for very specific hiding:
ls --hide="*.txt" --hide="*[0-9]*" --hide="[a-m]*"
This creates a strange filtered view showing only files that don’t contain numbers, don’t start with letters a through m, and don’t end with .txt.
Uncover more details in Sed for JSON Manipulation: Parsing Without jq in 5 Simple Patterns
5. The Forgotten Access Time Listing (-u)
Most users know about modification time, but ls can also show the rarely used access time with the -u
option:
ls -lu
This shows when files were last read rather than written, creating a quirky view into file usage. Even stranger, combine with time-style options:
ls -lu --time-style=full-iso
This reveals access times with microsecond precision, exposing a rarely seen dimension of your filesystem.
Journey deeper into this topic with How to Create Time Change Function Yourself in Bash: 13 Essential Tools for 2025
# Sample output with access times
-rw-r--r-- 1 user group 1234 2025-03-10 09:15:30.123456789 +0000 document.txt
6. Context-Aware Security Listings (-Z)
On systems with SELinux or similar security systems, the quirky -Z
option reveals hidden security contexts:
ls -Z
This displays security labels most users never see:
unconfined_u:object_r:user_home_t:s0 file.txt
For a truly unusual view, combine security context with other formats:
ls -laZ
This security information is invisible with standard ls usage but reveals a whole dimension of Linux security most users never interact with.
Enrich your learning with Security Considerations When Using envsubst: Protecting Your CI/CD Pipeline
7. Dereference Command Line Arguments Only (–dereference-command-line)
This unusually specific option follows symbolic links, but only for files specified on the command line:
ls --dereference-command-line symlink1 symlink2 directory_with_symlinks/
Even quirkier, try:
ls --dereference-command-line-symlink-to-dir
This only dereferences symlinks that point to directories specified on the command line but not those discovered during directory traversal. This hyper-specific behavior was clearly designed for a very particular use case.
Gain comprehensive insights from Why Bash Rocks: Unlocking the Power of the Command Line
8. Show Entry Per Line with Commas (-m)
The oddly formatted -m
option separates entries with commas rather than newlines:
ls -m
This produces output like:
file1.txt, file2.txt, images, scripts, strange file.jpg
Combining this with other options creates even stranger output:
ls -mF
Which gives comma-separated entries with type indicators:
Master this concept through Jenkinsfile with envsubst: Simplifying CI/CD Pipeline Configuration
file1.txt, file2.txt, images/, scripts/, strange file.jpg
9. Almost No Output with -1 vs -l
The quirky difference between -1
(numeral one) and -l
(letter l) confuses even experienced users:
ls -1
This produces a bare list with one entry per line but no details:
file1.txt
file2.txt
images
Compare with:
ls -l
Which gives the familiar detailed listing. The quirk is that -1
is the default behavior when output isn’t going to a terminal, creating confusion in scripts where the output seems to change unpredictably.
Delve into specifics at Dynamic Configuration Management with envsubst and Jinja2: Simplifying Deployments
graph TD A[ls command] --> B{Output to terminal?} B -->|Yes| C[Multi-column format] B -->|No| D[One entry per line] C --> E[Override with -1] D --> F[Already in -1 format]
10. Custom Block Sizes (–block-size)
The unusual --block-size
option lets you view file sizes in arbitrary units:
ls -l --block-size=K
But you can get truly quirky with strange units:
ls -l --block-size=M
ls -l --block-size=G
ls -l --block-size=T
For even stranger behavior, try powers of 10 instead of powers of 2:
ls -l --block-size=MB
Or the truly esoteric:
ls -l --block-size="'1"
Which groups digits with single quotes as thousands separators.
Deepen your understanding in Comprehensive Guide to Linux ls Command: Options, Examples, and Best Practices
11. Author Listing (–author)
The rarely-used --author
option shows the file author, which is often identical to the owner but can differ in some filesystems:
ls -l --author
This exposes an additional column of information most Linux users never see:
-rw-r--r-- 1 user author group 1234 Mar 10 09:15 file.txt
This option reveals that Linux internally tracks both owners and authors, a distinction almost never utilized.
Deepen your understanding in Comprehensive Guide to Linux ls Command: Options, Examples, and Best Practices
12. Bizarre Time Styles (–time-style)
The --time-style
option offers some truly unusual date formatting options:
ls -l --time-style=locale
ls -l --time-style=iso
ls -l --time-style=full-iso
But the quirkiest option is creating your own format:
ls -l --time-style="+%Y-%m-%d %H:%M:%S.%N"
For maximum strangeness, try including non-time elements:
ls -l --time-style="+Week %V of %Y, day %j, %H:%M"
This displays timestamps like “Week 10 of 2025, day 069, 09:15” instead of conventional dates.
Deepen your understanding in Comprehensive Guide to Linux ls Command: Options, Examples, and Best Practices
13. Version Sort (-v)
The peculiar -v
option sorts files in “natural” version order, understanding that version 10 comes after version 2:
ls -v
This makes files like “file2.txt” appear before “file10.txt” - a behavior normal alphabetic sorting doesn’t provide.
For the full quirky experience, combine with other sort options:
ls -lSrv
This sorts files by size (largest last), but with version-aware naming. The result is a strangely specific yet occasionally extremely useful sorting method.
Deepen your understanding in Comprehensive Guide to Linux ls Command: Options, Examples, and Best Practices
Practical Applications: When Quirky Becomes Useful
These ls command tricks might seem odd, but they solve real problems:
Dealing with Strange Filenames
The quote and escape options help when filenames contain spaces or special characters:
# Create a file with a problematic name
touch "file with spaces and $pecial characters"
# List it safely
ls -Q
ls --quoting-style=shell-escape
Creating Nicely Formatted Reports
The strange formatting options can create readable export files:
# Create a CSV-like listing
ls -la --time-style="+%Y-%m-%d" | tr -s ' ' ',' > file_report.csv
Debugging Security Issues
The -Z
context option helps understand permissions problems on SELinux systems:
Deepen your understanding in Comprehensive Guide to Linux ls Command: Options, Examples, and Best Practices
# Check why a file can't be accessed
ls -Z problematic_file.txt
Best Practices for Using Quirky ls Options
When utilizing these unusual ls command tricks:
Deepen your understanding in Comprehensive Guide to Linux ls Command: Options, Examples, and Best Practices
- Document your usage - Quirky options aren’t obvious to others
- Consider script portability - Some options are GNU-specific
- Use aliases for complex combinations - Save typing and errors
- Check the version of ls - Options may vary between distributions
# Example of documenting a quirky ls trick
# Name: Version-sorted file listing with size
# Purpose: List files with natural version ordering
# Dependencies: GNU ls
# Creator: Karandeep Singh
ls -lSv
Conclusion: The Hidden Depths of Familiar Commands
These 13 quirky ls command tricks reveal that even the most fundamental Linux commands contain surprising depths and unusual features. The designers of these tools created options for remarkably specific scenarios, many of which remain unknown to the average user.
By exploring these quirky options, we gain not just practical tools but a deeper appreciation for the thoughtfulness and flexibility built into Linux utilities. The most basic commands often contain clever solutions to problems you haven’t encountered yet.
As you incorporate these quirky ls command tricks into your workflow, you’ll likely find that some solve problems you didn’t know you had, while others remain amusing curiosities. Either way, they offer a glimpse into the remarkable attention to detail that characterizes Linux tool design.
Which quirky ls option surprised you the most or seems most useful for your workflow?
Deepen your understanding in Comprehensive Guide to Linux ls Command: Options, Examples, and Best Practices
References and Further Reading
- Free Software Foundation. (2023). GNU Coreutils: ls. GNU Documentation.
- Newham, C. & Rosenblatt, B. (2005). Learning the bash Shell. O’Reilly Media.
- Cooper, M. (2021). Advanced Command Line Techniques. Ubuntu Blog.
- Robbins, A. (2010). Effective Unix Commands. Linux Journal.
- Peek, J., Powers, S., O’Reilly, T., & Loukides, M. (2002). Unix Power Tools. O’Reilly Media.
Similar Articles
Related Content
More from development
Learn essential Jenkins Versions strategies to optimize your CI/CD pipelines. This guide covers …
Explore the fascinating history of the ls command from its Unix origins to modern Linux …
You Might Also Like
Master the Linux ls command with this comprehensive guide covering basic and advanced options, …
Master the Linux ls command with our task-oriented approach covering everyday file management …
Knowledge Quiz
Test your general knowledge with this quick quiz!
The quiz consists of 5 multiple-choice questions.
Take as much time as you need.
Your score will be shown at the end.
Question 1 of 5
Quiz Complete!
Your score: 0 out of 5
Loading next question...
Contents
- Beyond Basic Listing: The Quirky Side of ’ls'
- 1. The Quote Everything Option (-Q)
- 2. Classify Files with Strange Symbols (-F)
- 3. Sort by Extension, Not Name (-X)
- 4. Hide Specific Patterns (–hide)
- 5. The Forgotten Access Time Listing (-u)
- 6. Context-Aware Security Listings (-Z)
- 7. Dereference Command Line Arguments Only (–dereference-command-line)
- 8. Show Entry Per Line with Commas (-m)
- 9. Almost No Output with -1 vs -l
- 10. Custom Block Sizes (–block-size)
- 11. Author Listing (–author)
- 12. Bizarre Time Styles (–time-style)
- 13. Version Sort (-v)
- Practical Applications: When Quirky Becomes Useful
- Best Practices for Using Quirky ls Options
- Conclusion: The Hidden Depths of Familiar Commands
- References and Further Reading