Home » Linux Command » Linux ls command Help and Examples

Linux ls command Help and Examples

Last updated Sep 4, 2021

Linux ls command is a basic command which is essential to know for all Linux users. It is used to list information of files and directories within a file system.

To use ls command, you don’t need to install any special package in your Linux machine. It is a part of the GNU core utility package, which comes with all distro of Linux.

The ls is a widespread utility, where you can’t imagine your work without using this utility. If you start working on the Linux machine, within 60 min, you will use this ls command uncountable numbers of time.

ls command syntax:
ls [OPTIONS] [FILES]

Suggested Reading: Linux sed command Structure

In this tutorial article, we will show you how to use ls command by using these three basic examples:

  1. List all files in Linux
  2. List all files in a long listing format
  3. View hidden files using ls

Examples:

List all files in Linux

The “ls” command is use to list all files and directory. You can use the “ls” command without any option to list all files and directories in the current location.

# ls

Output:

siteadmin@linuxconcept:~$ ls
linuxconcept.zip  tarexample.txt  test  test123.sh  zipcompare.sh
siteadmin@linuxconcept:~$

List all files in a long listing format

You can use the “-l” option with “ls” command to display file or directory, size, modified date and time, owner or files and permission on the file, as shown below:

# ls -l

Output:

siteadmin@linuxconcept:~$ ls -l
total 515340
-rw-r--r-- 1 siteadmin siteadmin 527705843 Jul 15 07:32 linuxconcept.zip
-rw-rw-r-- 1 siteadmin siteadmin         0 Dec  5 04:30 tarexample.txt
-rw-rw-r-- 1 siteadmin siteadmin         0 Dec  5 04:30 test
-rw-rw-r-- 1 siteadmin siteadmin         0 Dec  5 04:30 test123.sh
-rw-rw-r-- 1 siteadmin siteadmin         0 Dec  5 04:30 zipcompare.sh
siteadmin@linuxconcept:~$

View hidden files using ls

You can use the “ls” command to check hidden files or directories by using “-a” option, as shown below:

# ls -a

Output:

siteadmin@linuxconcept:~$ ls -a
.  ..  .bash_history  .bash_logout  .bashrc  .cache  .gnupg  linuxconcept.zip  .profile  .sudo_as_admin_successful  tarexample.txt  test  test123.sh  zipcompare.sh
siteadmin@linuxconcept:~$

Related Posts

The 30 most useful Linux commands

This article will introduce some practical and common Linux or Unix command , which is the Linux system administrators normally use the command . This article is not a complete list, but a brief list of commands that can be useful...

15 Practical examples of tcpdump command

15 Practical examples of tcpdump command

The tcpdump is the most essential and powerful command-line network packet sniffing tool. We use it to analyze network packets, capture or filter TCP/IP packets that transferred and received over the network on a specific network interface. It is available in almost...

15 Useful “df” Commands to Check Disk Space in Linux

15 Useful “df” Commands to Check Disk Space in Linux

There are several Linux tools available on the internet to check disk space utilization; we can use any of them. But, Linux has a best built-in command-line utility called “df”. The “df” is the short form of “disk filesystem”, we can get detailed information on used...

15 Practical examples of echo command

15 Practical examples of echo command

If you are writing a bash script, you know echo command very well. It is use to display text lines on an output screen or a file. The echo command is the most common command used by all Linux users, and it is built-in Linux command. echo command syntax: echo...

Follow Us

Our Communities

More on Linux Command

The Ultimate Managed Hosting Platform
Load WordPress Sites in as fast as 37ms!

0 Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

seventeen + five =

Shares