ls command is a basic command in Linux used to list files and directories. This command comes with so many features like you can sort files and directories by Date, by Size, able to check hidden files and directories, permissions, inode information and so on.
To know how it works we need to know what the shell is.
The shell is an application that accepts commands through its command-line interface. The shell allows you to request actions of the kernel.
The kernel is a program that is really important to our operating system, controlling all other programs and allowing communication between the software and hardware.
Now im going to explain how the ls command works in Linux and what this command do when we use it with the “*.c”.
Without options, ls displays files in a bare format. This bare format however makes it difficult to establish the type, permissions, and size of the files. The most common options to reveal this information or change the list of files ar
-l Long format, displaying Unix file types, permissions, number of hard links, owner, group, size, last-modified date and filename.
-f do not sort. Useful for directories containing large numbers of files.
-F appends a character revealing the nature of a file, for example, * for an executable, or /for a directory. Regular files have no suffix.
-a lists all files in the given directory, including those whose names start with "." (which are hidden files in Unix). By default, these files are excluded from the list.
-R recursively lists subdirectories. The command ls -R/ would therefore list all files.
-d shows information about a symbolic link or directory, rather than about the link's target or listing the contents of a directory.
-t sort the list of files by modification time.
-h print sizes in human readable format.
-1 (the numeric digit one) force output to be one entry per line.
ls -lh It shows the same information that ls -l and and the size information. KB, MB, etc.
ls -S Order the files by sieze.
SO, WHAT HAPPENS WHEN YOU TYPE “ls *.c”?
The ls command lists all the files in the current directory with le “.c” extension.