In this tutorial, we will learn ls Linux command. This command is very useful when working with the command line on Linux systems.
ls Linux command
ls command is used for listing directory contents. The ls utility displays information about directories and files.
This command is like the dir command on Windows operating system. The simplest form of this command is without any switches:
$ ls [flags] file_list
Open Terminal, type this command, and check out the results.
#Display directory contents
Bob is a tester and wants to start an application server from the Terminal. However, he wants to know the filename of the server start script under the bin directory. He knows that the environment variable of the server $JBOSS_HOME is set on the machine. He uses the ls command to know the start-up script in the directory.
To know the directory contents of the JBoss bindirectory in the Terminal.
$ cd $JBOSS_HOME/bin
$ ls -l
-l is for the long format.
Understanding the results
The entries that start with the ‘d’ are the subdirectories in the list of results. For example, in the below command ‘client’ is a subdirectory under the Wildfly/JBoss bin directory.
The absolute path for the directory on the system is: /opt/wildfly/bin/client
The entries that do not start with the ‘d’ are the files under the given directory. These files could be executable files, properties files, configuration files, shell scripts, etc.
Shell scripts are used to perform some tasks related to the Application server. For example, to start the server. Configuration and properties files contain important parameters that are picked up by the server.
-rw-r–r– strings in the command results are the ACLs for users, groups, others on the files and directories.
r stands for read permission
w stands for write permission
x stands for execute permission
– in the first place means not a directory. In other respective places means no permission.
#To display inode numbers
We can use the command ls -i switch to display the inode numbers.
The command displays the inode number of all the files and directories under the eclipse directory.
# To know about the command
The command supports several command-line switches. To know the full list of switches, visit the man page of the command.
$ man ls
# To view hidden files and directories
Linux Basic Commands Tutorial page:
More Information on Ubuntu Linux: