How to use the ls command? Linux command infrastructure

No matter what the command is and what it is used for, in Linux, the command has its general format:

 
 
 
 

command [-options] [parameter]

command: The command itself.

-options: [Optional, not required] Some options of the command, the details of the behavior of the command can be controlled through the option.

parameter: [Optional, not required] The parameters of the command, most of which are used to point to the target of the command.

The [] in the grammar means optional.

ls command

Next, let us learn the first Linux command: ls command, and use it to understand the basic format of the command.

The function of the ls command is to list the contents of the directory. The syntax details are as follows:

 
 
 
 

1s [-a-1 -h] [Linux path]

-a -l -h are optional options, and the Linux path is an optional parameter of this command. When no options and parameters are used, the 1s command body is used directly, which means: list the contents of the current working directory in a tiled form :

Edit toggle to center

Add picture annotations, no more than 140 words (optional)

HOME directory and working directory

The command line terminal of the Linux system will load by default when it starts:

The HOME directory of the currently logged in user is used as the current working directory, so the ls command lists the contents of the HOME directory

HOME directory: the personal account directory of each Linux operating user in the Linux system, the path is: /home/username, for example, the Linux user in the figure is itheima, and its HOME directory is: /home/itheima Windows system and Linux system, both There is a user's HOME directory, as shown in the figure:

Edit toggle to center

Add picture annotations, no more than 140 words (optional)

Parameters of the ls command

It has just been shown that the ls command is used directly without options and parameters.

 
 
 
 

1s [-a-1-h] [Linux path]

So what are the options and parameters of ls? First, let's look at the parameters.

When ls does not use parameters, it means to list: the content of the current working directory, that is, the user's HOME directory. When using parameters, the parameters of the ls command means: specify a Linux path, and list the contents of the specified path, such as

Edit toggle to center

Add picture annotations, no more than 140 words (optional)

List the contents of the root directory through ls /, we can open VMware, and compare the results of the command line and the results of the graphical view in the Linux graphics.

-a option of ls command

 
 
 
 

1s [-a-1-h] [Linux path]

The -a option means: all means, that is, list all files (including hidden files/folders)

As you can see, ls -a lists more content than ls. The ones starting with . in the figure represent hidden files/folders of the Linux system (as long as they start with ., they can be hidden automatically). Only through the -a option can these hidden files/folders be seen.

-l option of ls command

The -l option means: display the content in the form of a list (vertical arrangement), and display more information.

The -l option actually means that folders are arranged in a list in graphical form.

The options in the grammar can be used in combination, for example, the learned -a and -l can be applied in combination. Writing method: ls -l -a, ls -la, ls -al, the above three writing methods are the same, indicating that the functions of -l and -a are applied at the same time.

In addition to options themselves being combinable, options and arguments can also be used together.

The -h option of the ls command

1s [-a-1-h] [Linux path]

-h means to list the file size in an easy-to-read form, such as K, M, G, the -h option must be used with -l.

1692589038225_hoptions.png

Guess you like

Origin blog.csdn.net/Blue92120/article/details/132405444