linux ls and ll commands

The information listed by the ll command is more detailed, with information such as time, whether it can be read or written, etc. 

The difference between the results of the ll command and the ls -l command:

The above results show that:

The meaning of each field:

File attributes File number The group the owner belongs to File size File date File name  
drwx------ 2 Guest users 1024 Nov 21 21:05 Mail  
-rwx--x--x 1 root root 89080 Nov 7 22:41 tar*  
-rwxr-xr-x 1 root bin 5013 Aug 15 9:32 uname*  
lrwxrwxrwx 1 root root 4 Nov 24 19:30 zcat->gzip  
-rwxr-xr-x 1 root bin 308364 Nov 29 7:43 zsh*  
-rwsr-x--- 1 root bin 9853 Aug 15 5:46 su*

significance:

The first field indicates the properties of the document. Linux files are basically divided into three attributes: readable (r), writable (w), executable (x). But there are ten grids that can be added (when the specific program is implemented, it is actually ten bits). The first small cell is a special representation cell, which represents a directory or a linked file, etc., d represents a directory, such as drwx------; l represents a linked file, such as lrwxrwxrwx; if it is represented by a horizontal "-", then Indicates that this is a file. The rest of the remaining grids are taken as a unit every 3 grids. Because Linux is a multi-user and multi-tasking system, a file may be used by many people at the same time, so we must set the permissions of each file. The order of the file's permission positions is (take -rwxr-xr-x as an example) :  
    rwx(Owner)rx(Group)rx(Other)  
    This example indicates that the permissions are: readable, writable, and executable by the user; readable, non-writable, and executable by users in the same group; readable by other users, Not writable, executable. In addition, the execution part of some program attributes is not X, but S, which means that the user who executes the program can temporarily have the same power as the owner to execute the program. It generally appears in the system management and other commands or programs, and when the user executes it, it has the root identity. 
   The second column indicates the number of files. If it is a file, then the number is naturally 1. If it is a directory, then its number is the number of files in the directory.  
    The third field indicates the owner of the file or directory. If the user is currently in his own Home, then this column is probably its account name.  
    The fourth column indicates the group to which it belongs. Each user can have more than one group, but most users should belong to only one group. Only when the system administrator wants to give a user special permissions, he may give him another group.  
    The fifth column indicates the file size. The file size is represented by bytes, and the empty directory is generally 1024 bytes. Of course, you can use other parameters to make the file display unit different. For example, using ls -k is to display the size unit of a file in kb, but generally we still use byte. main.  
    The sixth field indicates the creation date. It is expressed in the format of "month, day, time", such as Aug 15 5:46 means 5:46 am on August 15th.  
    The seventh column indicates the file name. We can display hidden filenames with ls -a. 

 

ll will list all file information under the file, including hidden files, while ls -l only lists explicit files, indicating that these two commands are not equivalent!

ls only lists file or directory names

List
ll-t is descending, ll-t | tac is ascending
ll is not a command, it's an alias for ls -l



The ls command can be said to be one of the most commonly used commands under Linux.

-a List all files in the directory, including implicit files starting with .

-b List unprintable characters in filenames with a backslash followed by a character number (as in C).

-c Print the modification times of the file's inodes, sorted by this.

-d Display the directory as a file instead of the files under it.

-i Output file's inode index information.
-l List file details.

-m Output filenames horizontally with "," as the space character.

-n Substitute numeric UID, GID for names.

-o Display detailed information about the file except group information.

-p -F Append a character to each file name to indicate the type of the file, "*" for executable plain

file; "/" indicates a directory; "@" indicates a symbolic link; "|" indicates FIFOs; "=" indicates a set

Sockets.

-q Replace non-printable characters with ?.

-r Reverse directory sorting.

-s Print the size of the file after each file name.

-t Sort by time.

Descriptions are sorted by date most recently modified!

 -u Sort by the time the files were last accessed.

-A Display all files except "." and "..".

-B Do not output backup files ending with "~".

-L List linked file names instead of linked files.

-N does not limit file length.

-Q Enclose the output filename in double quotes.

-R List files in all subdirectories.

-S Sort by file size.

-X Sort by file extension (character after the last .).

-1 Output only one file per line.

--color=no do not display color filenames

--help Display help information on standard output.

--version Print version information on standard output and exit.

List only subdirectories

1. ls -F | grep /$ or alias sub = "ls -F | grep /$" (linux)

2. ls -l | grep "^d" 或者 ls -lL | grep "^d" (Solaris)

Calculate the number of files and directories in the current directory

The following commands can calculate the number of files and directories in the current directory respectively:

# ls -l * |grep "^-"|wc -l ---- to count files

# ls -l * |grep "^d"|wc -l ----- to count dir

Display colored directory listings

Open /etc/bashrc and add the following line:

alias ls="ls --color"

The next time you start bash, you can display a colored directory listing like in Slackware, where the colors mean the following:

1. Blue --> Catalog

2. Green --> Executable

3. Red --> Compressed file

4. Light blue --> link file

5. Gray --> Other files

ls -tl --time-style=full-iso sshd

ls -ctl --time-style=long-iso

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325127695&siteId=291194637