Linux ls Command Tutorial With Examples

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-ls-command-tutorial-with-examples/
PINTEREST
PINTEREST
INSTAGRAM

Linux operating system provides a lot of different functionalities with different tools and commands. ls is the most used command in linux. ls is the arm and leg of Linux system administrator. ls provides a lot of different functionalities with different options.

Man ls

Man page of ls command can be retrieved like below.

List Files

We can list files and folders simple without providing any parameter. This will list all files except hidden files those names starts with .

List Files
List Files

List Files According To Modification Date

-t parameter make listing according to their modification date. REcently modified file will be listed in the upper side

List Files According To Modification Date
List Files According To Modification Date

Display One File Per Line

We can set 1 file will be listed in single line. This is generally useful for providing file list as an input into other commands or applications.

Display One File Per Line
Display One File Per Line

Show Detailed File Information

We can get more details about files and folders with -l option.

Show Detailed File Information
Show Detailed File Information
  • drwxr-xr-x is permission information
  • root root is user and group information. It is related with permission
  • 4096 is the size in byte . Folders have same size
  • Oct  6  12:08 is the modification date
  • Amsterdam is the file or folder name

Display Size Information Human Readable Format

We see that size is in byte format we can change is MB,GB format according to its size

Display Size Information Human Readable Format
Display Size Information Human Readable Format

Display Directory Information

We can list only directory with -d  option. It will not list files and directories under it.

LEARN MORE  How To Shutdown Linux At Specified Time?

Display Directory Information
Display Directory Information

Reverse Order List

We can list files and folders according to their names, modification date. But we can reverse order with -r parameter

Reverse Order List
Reverse Order List

Display Hidden Files

Linux world hidden files are prepended with a point before their name. By default ls do not list these files. We can list them too with -a 

Display Hidden Files
Display Hidden Files

Display Files Recursively

We can display files recursively  with -R parameter. Recursively means we will list folders and their contents and this goes to the deepest path.

Display Files Recursively
Display Files Recursively

Display Files Inode Numbers

Inode is file system related information about files and folders. Inodes generally do not needed daily usage but sometimes it can be important.

Display Files Inode Numbers
Display Files Inode Numbers

Display User Id (UID) and Group Id (GUID)

We can list user and group id of files according to their names

Display User Id (UID) and Group Id (GUID)
Display User Id (UID) and Group Id (GUID)
  • 0 0 are user and group id of root

Classification of Files with Colors

We can use colors to classify files and folders.

Classification of Files with Colors
Classification of Files with Colors

Alias for ls

We can make providing parameters more practical. We can define alias for ls commands with parameters.

Alias for ls
Alias for ls
  • alias create ll command
  • ls -lh is the actual command where it will be called ll is issued

List Files and Directories with / At The End

To in scripts or other types directories and files can be listed with at the end with -F

List Files and Directories with / At The End
List Files and Directories with / At The End

Sort Files By Size

One of the most useful option of ls command is sorting files according to their sizes.

LEARN MORE  How To Get Docker Container Ip and Mac Address

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-ls-command-tutorial-with-examples/
PINTEREST
PINTEREST
INSTAGRAM

One Reply to “Linux ls Command Tutorial With Examples”

Leave a Reply

Your email address will not be published.