Ls command details

Source: Internet
Author: User

Ls command details
GuideOne common task for Linux users is to list the contents of directories on the command line. We already know that ls and dir are two Linux commands available to list the contents of directories, the former is more popular, and is the first choice for users in most cases. But how to sort in more detail will be discussed below.

When listing the contents of a directory, we can sort the contents according to different criteria, such as the file name, modification time, addition time, version, or file size. You can specify a special parameter to sort the attributes of these files. In this concise ls command guide, we will look at how to sort the output results of the ls command by the last modification time (date and hour/minute/second. Let's start by executing some basic ls commands.

Linux ls commands1. Running the ls command without any parameters will list the contents of the current working directory:

2. to list the contents of any directory, such as The/etc directory, run the following command:
$ ls /etc

3. a directory always contains some hidden files (at least two). Therefore, to display all the files in the directory, use the-a or-all flag:
$ ls  -a

4. You can also print the details of each output file, such as file permission, number of links, owner name and group owner, file size, last modification time, and file/directory name:

This is set by the-l option, which means a long list format like the following screen.

$ ls -l

Sort files by date and time1. To list files in the directory and sort the Last modified Date and time, use the-t option in the following command:
$ ls -lt 

2. If you want a reverse sorting file based on date and time, you can use the-r option to work like this:
$ ls -ltr

From: https://linux.cn/article-7984-1.html

Address: http://www.linuxprobe.com/ls-files.html


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.