AMZ DIGICOM

Digital Communication

AMZ DIGICOM

Digital Communication

Linux ls command: display the contents of a directory

PARTAGEZ

The ls command for Linux displays the contents of a directory or folder. This command can be refined with many options.

Linux ls command: what is it?

The ls command is one of the most important and widely used Linux commands. This command is essential if you want show all contents of a folder or directory on the command line. The content is then displayed by default in alphabetical order. The ls command is among the standard elements of most Linux distributions, such as Ubuntu. Thanks to the various options that accompany it, it can provide various very specific functions. The term “ls” is a contradiction of the English word “List”.

How does the ls command work?

If you decide to type and run the ls command on your command line, it takes care of retrieving all available information about a given folder or directory and displays it according to thealphabetical order file names. So you no longer need to use the Linux cd command to move to another directory to view its contents. The ls command is therefore a valuable tool, which can considerably facilitate your work. If you do not specify any particular directory, then the system displays available information about the directory in use.

What does the ls command syntax look like?

The Linux ls command syntax is relatively simple. It looks like this:

$ ls [Options] [Répertoire]

shell

You can refine the ls command itself using various options. Warning: correctly indicate the directory (“ [Répertoire] ”) to retrieve the information you are interested in.

What are the ls command options?

If you decide to run the ls command without any options, then all available information is displayed in alphabetical order, by file name. However, if you want to refine it, you can choose from the following options:

  • -A or –almost-all: it allows you to include hidden files in the list.
  • -a or –all: it allows you to include hidden files in the list, but also directories such as “. ” And ” .. “.
  • -VS : it allows you to display the names of the files next to each other. This is the default setting.
  • -vs : it allows you to sort the information according to the date of its last modification. The resulting list of the command then starts with the most recent items.
  • -d or –directory: it only lists directory names, ignoring their contents.
  • -h or –human readable: it displays the size in a more easily readable format. It is used in combination with the “-l” option.
  • -i: it allows you to specify the inode number before the file name.
  • -L : it makes it possible to obtain information in its long form.
  • -m: it allows the names to appear on a single line.
  • -R or –recursive: it allows information to be displayed recursively and therefore also takes subdirectories into account.

ls Command: Examples

Below are two practical examples to help you understand how to use the ls command:

This command allows you to display all the information relating to the “EXAMPLE” directory in its long form. Thanks to the -a option, hidden files are also included in the list.

This command allows you to retrieve all available information about the directory in use, as well as its subdirectories.

Télécharger notre livre blanc

Comment construire une stratégie de marketing digital ?

Le guide indispensable pour promouvoir votre marque en ligne

En savoir plus

Souhaitez vous Booster votre Business?

écrivez-nous et restez en contact