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 [OPTIONS] [FILES]
In this tutorial article, we will show you how to use ls command by using these three basic examples:
- List all files in Linux
- List all files in a long listing format
- View hidden files using ls
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.
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
[email protected]:~$ 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 [email protected]:~$
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