How to List Directory Contents in Ubuntu Linux Terminal Using the ls Command

When you open a terminal window in Ubuntu Linux, you are not presented with graphical folders or icons. Instead, you are looking at a text-based interface, and your first question is usually, “What files are actually in here?” The ls command (short for “list”) is arguably the most frequently used command in all of Linux, as it allows you to see the contents of any directory on your system.

The Basic ls Command

The simplest way to use the command is to type it by itself without any extra options.

Open your terminal and type:

ls

Press Enter. The terminal will output a simple, multi-column list containing the names of all visible files and folders in your current directory. In modern Ubuntu terminals, this output is usually color-coded (for example, directories might be blue, while executable files might be green).

Viewing Detailed File Information (The -l Flag)

While the basic command tells you what files exist, it doesn’t tell you how large they are, who owns them, or when they were created. To see this detailed metadata, you must use the “long format” flag (-l).

ls -l

This outputs a detailed vertical list. Reading from left to right, each line tells you:

  • Permissions: (e.g., -rw-r--r--) Shows who can read, write, or execute the file.
  • Links: The number of hard links pointing to the file.
  • Owner: The user account that owns the file.
  • Group: The user group that owns the file.
  • Size: The size of the file in bytes.
  • Date/Time: The last time the file was modified.
  • Name: The actual name of the file or folder.

Viewing Hidden Files (The -a Flag)

In Linux, any file or folder name that begins with a dot (e.g., .bashrc or .config) is considered a hidden file. These are usually configuration files that the system needs, but that you rarely need to see. The standard ls command ignores them entirely to keep your screen uncluttered.

To view absolutely everything, including hidden files, use the “all” flag (-a):

ls -a

Combining Flags for Maximum Utility (ls -la)

One of the great features of Linux command-line utilities is that you can stack flags together. If you want to see a detailed, long-format list that also includes hidden files, you simply combine the -l and -a flags.

ls -la

This specific combination is so useful that many system administrators type it entirely out of muscle memory every time they enter a new directory.

Making File Sizes Readable (The -h Flag)

By default, the ls -l command shows file sizes in raw bytes. This is fine for small text files, but figuring out how large “1543890” bytes actually is requires mental math. You can add the “human-readable” flag (-h) to tell the system to use Kilobytes (K), Megabytes (M), and Gigabytes (G) instead.

ls -lah

This command combines the long format (l), all hidden files (a), and human-readable sizes (h), providing the ultimate overview of your directory contents.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.