ls command in linux with example

This is a follow-up to my previous 90 Linux Commands Frequently Used by Linux Sysadmins article. Every week, as time permits, I will publish articles on ~90 commands geared to Linux sysadmins and Linux power users. let’s start ls command,

ls (short for list) is used to list information about files on Linux and other Unix-like operating systems. When invoked without any arguments, ls will list the files in the current working directory. ls is one of the most commonly used commands.

The ls command is basically . appeared in the first edition of AT&T UnixThe name is inherited from a similar command mallets Also called ‘ls’. ls is part of X/Open Portability Guide Since 1987 issue 2. It was inherited in the first version of posix.1 And this single unix specification,


ls -laF = long format list of all files with type.

ls command example

To show a long format list of files (permissions, ownership, size, and modification date), use:

ls -l [path]

To list all files including important dotfiles (hidden files), use:

ls -a [path]

show file type(“/” = directory, “*” = executable), use:

ls -F [path]

To combine these arguments for a long format list of all files with types, use:

ls -laF [path]

To list files from multiple paths, use:

ls [path_1] [path_2]

To show a recurring list, use:

ls -R [path]

To show the listing in one loaded screen at a time, use:

ls [path] | less

To show long format list with size displayed using human-readable units (KB, MB, GB), use:

ls -lh [path]

To show a long format list sorted by size (descending), use:

ls -lS [path]

To show a long format list of all files sorted by modification date (oldest first):

ls -ltr [path]

Useful reading of the ls command:

ls command options and related commands:

  • To you – List directory contents.
  • Get – Recursively search for files or directories under the given directory tree.
  • echo – Print the given arguments.
  • printf – Format and print text.

Leave a Comment