Skip to content

Both.org

News, Opinion, Tutorials, and Community for Linux Users and SysAdmins

Primary Menu
  • About Us
  • Computers 101
    • Hardware 101
    • Operating Systems 101
  • End of 10 Events
    • Wake Forest, NC, — 2025-09-20
  • Linux
    • Why I use Linux
    • The real reason we use Linux
  • My Linux Books
    • systemd for Linux SysAdmins
    • Using and Administering Linux – Zero to SysAdmin: 2nd Edition
    • The Linux Philosophy for SysAdmins
    • Linux for Small Business Owners
    • Errata
      • Errata for The Linux Philosophy for SysAdmins
      • Errata for Using and Administering Linux — 1st Edition
      • Errata for Using and Administering Linux — 2nd Edition
  • Open Source Resources
    • What is Open Source?
    • What is Linux?
    • What is Open Source Software?
    • The Open Source Way
  • Write for us
    • Submission and Style guide
    • Advertising statement
  • Downloads
  • Home
  • Tips for using the ‘ls’ command in Linux
  • Command Line
  • Linux

Tips for using the ‘ls’ command in Linux

Don Watkins July 8, 2024 3 minutes read
linux_keyboard_desktop

One of the first commands I learned in Linux was ls. Knowing what’s in a directory where a file on your system resides is important. Being able to see and modify not just some but all of the files is also important.

My first Linux cheat sheet was the One Page Linux Manual, released in 1999 and it became my go-to reference. I taped it over my desk and referred to it often as I explored Linux. Listing files with ls -l is introduced on the first page, at the bottom of the first column.

Later, I would learn other iterations of this most basic command. Through the ls command, I began to learn about the complexity of the Linux file permissions and what was mine and what required root or sudo permission to change. I became very comfortable on the command line over time, and while I still use ls -l to find files in the directory, I frequently use ls -al so I can see hidden files that might need to be changed, like configuration files.

According to an article by Eric Fischer about the ls command in the Linux Documentation Project, the command’s roots go back to the listf command on MIT’s Compatible Time Sharing System in 1961. When CTSS was replaced by Multics, the command became list, with switches like list -all. According to Wikipedia, ls appeared in the original version of AT&T Unix. The ls command we use today on Linux systems comes from the GNU Core Utilities.

Most of the time, I use only a couple of iterations of the command. Looking inside a directory with ls or ls -al is how I generally use the command, but there are many other options that you should be familiar with.

$ ls -l provides a simple list of the directory:

Using the man pages of my Linux Mint system, I find that there are many other options to ls, all of which provide interesting and useful information about the Linux file system. By entering man ls at the command prompt, we can begin to explore some of the other options:

To sort the directory by file sizes, use ls -lS:

To list the contents in reverse order, use ls -lr:

List the contents in reverse order with $ ls -lr:

To list contents by columns, use ls -c:

ls -al provides a list of all the files in the same directory:

Here are some additional options that I find useful and interesting:

  • List only the .txt files in the directory: ls *.txt
  • List by file size: ls -s
  • Sort by time and date: ls -d
  • Sort by extension: ls -X
  • Sort by file size: ls -S
  • Long format with file size: ls -ls
  • List only the .txt files in a directory: ls *.txt

To generate a directory list in the specified format and send it to a file for later viewing, enter ls -al > mydirectorylist. Finally, one of the more exotic commands I found is ls -R, which provides a recursive list of all the directories on your computer and their contents.

For a complete list of the all the iterations of the ls command, refer to the GNU Core Utilities.

This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.

Tags: Linux Commands

Post navigation

Previous: Linux Malware scanning using ClamAV
Next: How to do fast, repeatable Linux installations #2 — Bash scripts + RPM

Related Stories

connections_wires_sysadmin_cable
  • Linux
  • Networking
  • Router

How to Make your Linux Box Into a Router

David Both April 29, 2026
f44-01-day-cropped
  • Fedora
  • Linux
  • Upgrades

Fedora 44 Released

David Both April 28, 2026
command_line_prompt
  • Command Line
  • Linux
  • Programming

Writing a replacement seq command

Jim Hall April 27, 2026

System upgrades this Sunday, May 3

Tools illustrationFedora 44 was released this week and I’ve upgraded all my systems except for the two that directly affect Both.org. I’ll be upgrading the hosts for my server and firewall to Fedora 44 this Sunday afternoon, May 3.

Both.org will be down for most of the afternoon for these upgrades.

Thanks for your patience.

Random Quote

Computers are easy; People are hard.

— Bridget Kromhout

Why I’ve Never Used Windows

On February 12 I gave a presentation at the Triangle Linux Users Group (TriLUG) about why I use Linux and why I’ve never used Windows.

Here’s the link to the video: https://www.youtube.com/live/uCK_haOXPFM 

Why there’s no such thing as AI

Last October at All Things Open (ATO) I was interviewed by Jason Hibbits of We Love Open Source. It’s posted in the article “Why today’s AI isn’t intelligent (yet)“.

Technically We Write — Our Partner Site

Our partner site, Technically We Write, has published a number of articles from several contributors to Both.org. Check them out.

Technically We Write is a community of technical writers, technical editors, copyeditors, web content writers, and all other roles in technical communication.

Subscribe to Both.org

To comment on articles, you must have an account.

Send your desired user ID, first and last name, and an email address for login (this must be the same email address used to register) to subscribe@both.org with “Subscribe” as the subject line.

You’ll receive a confirmation of your subscription with your initial password as soon as we are able to process it.

Administration

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

License and AI Statements

Both.org aims to publish everything under a Creative Commons Attribution ShareAlike license. Some items may be published under a different license. You are responsible to verify permissions before reusing content from this website.

The opinions expressed are those of the individual authors, not Both.org.

You may not use this content to train AI.

 

Advertising Statement

Both.org does not sell advertising on this website.


Advertising may keep most websites running—but at Both.org, we’re committed to keeping our corner of the web ad-free. Both.org does not sell advertising on the website. Nor do we offer sponsored articles at this time. We’ll update this page if our position on sponsorships changes.

We want to be open about how the website is funded. Both.org is supported entirely by David Both and a few other dedicated individuals.

 

 

Copyright © All rights reserved. | MoreNews by AF themes.