Premium lesson

Listing Files & Directories

Shell·2 min read·Jan 1, 2025

To output the list of files and directories contained in the current working directory, you can use the ls command — which stands for list:

$ ls

Example

Let's consider this filesystem representation, in which the current working directory is the home directory:

/├── home│   └── johndoe         ← Current working directory│   │   ├── Documents│   │   └── Downloads

Executing this command will list the content of the /home/johndoe directory in the form of columns:

$ lsDocuments     Downloads

Listing the content of directories

To list the content of one or more directories, you can use the ls command as follows:

$ ls [path ...]
icon light bulb key

Unlock the CLI & Scripting with Bash module

Learn how to gain advanced control over the OS and automate complex routine tasks prone to manual errors with the CLI and Bash scripting.

You get immediate access to:

  • 34 focused lessons across the CLI and Bash
  • 4 real-world projects with commented solutions
  • Ongoing updates to this bundle
  • Lifetime access to this bundle
Unlock this module