
Part one in the Linux Command Series
Published on May 23, 2026 by Mike Chilson
Commands Bash Linux Tutorial
3 min READ
The ls command is one of the most fundamental and frequently used commands in Linux and Unix-like operating systems. It stands for “list” and is used to display the contents of a directory. This tutorial covers basic usage, advanced options, and professional tips for mastering ls.
Listing Files and Directories
lsListing with Details
-l option for a long listing format that includes permissions, owner, size, and modification time: ls -lListing Hidden Files
.). Use the -a option to show them: ls -als -la or ls -alListing Specific Directory
ls /path/to/directoryls /home/user/DocumentsHuman-Readable Sizes
-h with -l to show file sizes in human-readable format (KB, MB, etc.): ls -lhSorting Options
ls -lSls -lt-r, e.g., `ls -ltr (oldest first)Recursive Listing
ls -RFile Type Indicators
ls -FColorized Output
ls --color=autols to ls --color=autoIgnoring Patterns
ls --ignore=\*.tmpCombining Options
ls -lathr This shows all files (-a), long format (-l), human-readable sizes (-h), sorted by time (-t), reversed (-r)Setting Default ls Behavior in Login Scripts
alias ls='ls --color=auto -h' (can be ls with any parameters)alias ll='ls -lh' or alias la='ls -lah'source ~/.bashrcPiping ls Output to Other Commands
| The pipe operator (** | **) allows you to send the output of one command as input to another. |
| symbol connects the standard output (stdout) of the left command to the standard input (stdin) of the right command. This enables powerful command chaining without saving intermediate results to files.Examples with grep
ls | grep reportls | grep -i reportls -l | grep '\.txt$'ls | wc -lls -lS | head -n 10ls -l | lessAdditional Pro Tips
ls -1 to list one file per line (useful for scripting).ls -ils -d $PWD/\*ls "$DIR"find instead of ls -RMastering the ls command significantly improves your efficiency on the Linux command line. Practice these options in your terminal to become comfortable with them. Combine ls with other commands using pipes for even more powerful workflows. Don’t forget, all this information can be found in the ls man page man ls.
Stay tuned for more tutorials.