In this article, we explain one of the basic Linux commands for beginners, i.e. the ls
command, with its most frequently used command options.
What is Linux?
Linux is a family of open-source operating systems based on the Linux kernel. The first Linux system kernel was released on September 17, 1991, by Linus Torvalds.
Read more …
Popular Linux distributions include Debian, Fedora, and Ubuntu, and the commercial distributions include Red Hat Enterprise Linux and SUSE Linux Enterprise Server.
There are also quite a number of customized Linux distributions, such as Kali Linux, REMnux etc. Kali Linux is a Debian-based distribution developed, funded and maintained by Offensive Security for ethical hackers for the purposes of Penetration Testing, Security Research & Assessment, and Computer Computer Forensics & Reverse Engineering. REMnux, on the other hand, is a Linux distro curated for reverse-engineering and malware analysis purposes.

I think Linux is a great thing, in the big picture. It’s a great hacker’s tool, and it has a lot of potential to become something more.
Jamie Zawinski
Read more educational and inspirational cyber quotes at our page 100+ Best Cyber Security & Hacker Quotes.
ls
Command – List Directory Contents
In Linux, ls
command is used to display a list of the files and directories within the file system or to view detailed information (metadata) on specified files and directories.
List information about the FILE(s) (the current directory by default). Basic usage:ls [OPTION] ... [FILE] ...
Use-a
to list all entries (including the hidden ones that start with.
) and-l
to list with more details, such as file permissions, file size etc.
Using the ls
Command
Simple Listing
To list just the files in a directory without any additional information, use ls
.
$ ls

ls
CommandListing Hidden Files
To list all the files in a directory, including the hidden files, without any additional information, use ls -a
. Hidden files begin with a period and not displayed by default.
$ ls -a

ls -a
CommandListing With Detailed Information
To list all the files in a directory, including the hidden files, with additional information (long listing), use ls -la
. Note that command options can be combined, thus ls -l -a
is the same with ls -la
.
$ ls -la

ls -la
CommandThe additional information (file permissions, file ownership etc.) displayed for the my-script.sh
file is described in more detail in Figure 4.

ls -la
Command OutputDenoting File Types
To denote files types with special characters, use ls -F
. The /
symbol denotes a directory, the @
symbol denotes a linked file, and the *
symbol represents an executable file.
$ ls -F

ls -F
Command to Display File TypesListing by File Date and Time
To list files by time, use ls -t
. To reverse the order of listing, -r
option could be combined with the -t
.
$ ls -t

ls -latr
CommandListing Recursively All Files in a Directory
To list files recursively in a directory, use ls -R
.
$ ls -R

ls -R
CommandListing Metadata for a Directory
To list metadata for a directory without listing the directory contents, use ls -ld
.
$ ls -ld

ls -ld
CommandTo explore more ls
command options, please visit the man pages by typing $ man ls
on the terminal.
To learn more on Linux, you could also visit our Linux Resources Page.