Technology computers-hardware

An Explanation of the LS Output in Linux

    Long Listing

    • Use the "-l" option to view the file type, permissions, number of files and subdirectories, owner, group, size and the date the files were last modified. This is called the long listing. The syntax is "ls -l". The following is an example of the output:

      drwxr-xr-x 2 owner group 4096 2011-08-12 22:50 dir_name

      The first letter of the first column indicates whether it is a directory or file. The "d" stands for directory. If it was a regular file, the "d" would be replaced with the "-" character. The rest of the letters in the first column represent the file permissions. The "2" in the second column indicates the number of files or subdirectories contained in the directory. The third column contains the name of the owner. The fourth column contains the name of the primary group for the directory. The fifth column shows the size of the file in bytes. The sixth column shows the date and time the file was last modified. The last column is the name of the file or directory.

    Hidden Files

    • The Linux operating system hides files and directories by placing a "." in front of the file name. The "-a" option shows the hidden files. The hidden files are listed in alphabetically order by the first name of the file, omitting the leading "." character. You can combine the "-a" option with the "-l" option to view the long listing of all of the files and subdirectories.

    File Size

    • The long listing shows the size of the file or directory in bytes. The "-h" option shows the size in human readable form. The size is followed by a "K" for kilobytes, "M" for megabytes or "G" for gigabytes. The "-h" option must be combined with the "-l" option. If it is used with the "ls" command alone, no size is shown.

    List Subdirectory Contents

    • The "ls" command only shows the names of any subdirectories contained within the directory, but it does not print the contents of the subdirectory by default. The "-R" option recursively shows the contents of the subdirectories. The option can be used alone or with the other options. The output can be quite extensive. Type the command "ls -R | less" to pipe the output through the "less" command. The output will stop regularly. Pressing the spacebar will advance the output.

    Sorting

    • You can change the way the command sorts the output. The "-S" option sorts the output by file size, with the largest files at the top of the list. The "-t" option sorts the output by the modification date, with the most recently modified files at the top of the list.

      The "-r" option sorts the output in reverse order. Used alone, it sorts the output in reverse alphabetical order. Used with the "-S" option, it sorts the output with the smallest files at the top of the list. Used with the "-t" option, the output is sorted with the most recently modified files at the end of the list.

Related posts "Technology : computers-hardware"

Is There a Way to Recover Data From an S RAM Card?

Hardware

How to Create a DVD With More Than One Video File Separated Into Titles

Hardware

How to Troubleshoot Your Dell Notebook With a Projector

Hardware

Printing On A Constant Progression

Hardware

Tips on Using a Digital Pen Efficiently

Hardware

How to Fix a Master Boot Record in Vista Ultimate

Hardware

Setting Up a PC as a Wireless Router

Hardware

How to Upgrade a MacBook

Hardware

How to Disable the Touch Pad on a Dell Precision M90 Laptop

Hardware

Leave a Comment