Daniel Lorenzo Scoccia
2 min readJun 9, 2020

What happens when you type ls *.c

What’s ls for?

The ls command is one of the basic commands that any Linux user should know. It is used to list information about files and directories within the file system. The ls utility is a part of the GNU core utilities package which is installed on all Linux distributions.

How to show the contents of a directory

To show the contents of a directory pass the directory name to the ls command. This will list the contents of the directory in alphabetical order. If your terminal supports colours you may see that file and directory listings are a different colour.

This command can be used with many options to filter the results, like:

To use options, you need to follow the rule ls [OPTION]… [FILE]…

Video thanks to GeekforGeeks

On the deeper level, this is what happens when you type “ls -l” and “enter” in the shell:

First and foremost, the shell prints the prompt, prompting the user to enter a command. The shell reads the command ls -l from the getline() function’s STDIN, parsing the command line into arguments that it is passing to the program it is executing.

The shell checks if ls is an alias. If it is, the alias replaces ls with its value.

Lastly,

After ls -l is executed, the shell executes shutdown commands, frees up memory, exits, and re-prompts the user for input.

If ls isn’t an alias, the shell checks if the word of a command is a built-in.

What’s *.c for?

In linux the * option is to browse an specific extension or part of the file, in this case *.c means that ls command will show only those files with .c on it.

One of the most useful commands!
Daniel Lorenzo Scoccia
Daniel Lorenzo Scoccia

Written by Daniel Lorenzo Scoccia

0 Followers

Full Stack Software Developer. Freelancer.

No responses yet