Wednesday, November 6, 2013

ls Command: List Contents of Directory

Summary
The ls command list all files in a directory. This command is used often when navigating through your file system through the terminal.

SYNOPSIS
ls [OPTION] [FILE]

When you invoke the command with no arguments, the files in the current directory is listed.

Options
Given here are common options used often. You can combine options together.
-a    List all entries. For example, files that begin with a period (.) are listed.

-l    List in long format.
      1st column: File Type and file permissions for users, group, and others.
      2nd column: Number of links
      3rd column: File owner
      4th column: Group owner
      5th column: File size
      6th column: Last modification date
      7th column: Name of file
      Example: -rw-rw-r--  1  oracle  oracle  6880  Oct 21 23:10  README

-h   Print file sizes in human readable format (e.g. 8.3M, 1.1K, etc)

-R   Recursively list sub-directories encountered.

-F   Appends a character  revealing the nature of a file.
      Regular files have no suffix. 
      *   executable file
      @  symbolic link
      /   directory
      =  sockets

-t   Sort by time modified. Latest first.

-i   Print the i-number

-u   Use time of last access instead of last modification.

-1   Force one-entry-per-line output format.

No comments:

Post a Comment