In computing, ls is a command-line tool to list computer files in Unix and Unix-like operating systems. compared to Windows, a very similar command-line tool is dir
How to use ls
# syntax : "options" and "directory" is optionalls<OPTIONS><DIRECTORY>##### basic example of listing filesls# lists all files/directories of the current directory your in ls/etc# list all files of the directory /etcls/root/Downloads# list all files of the directory /root/Downloads##### examples with parametersls-a/root# show hidden files (.bashrc for example) of the root - home directoryls -l /root # show all files/directories (not the hidden ones) in the directory /root with the permissions, root owner, and group owner
ls-i/root# shows the inode (index number) of the file/directoryls-r/root# reverse sort the files/directories in the directory rootls-R/root# list the files recursive (note that the use of tree is better to create a good overview)##### how to combine ls with "pipe"ls /root | grep -i doc* # list all directories/files in the root directory that start with "doc" (Capital letters don't matter now) and end on anything
ls/etc|grep-i-esql-eapache*# list all files/directories that have the name sql or apache in them.