Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
54 views3 pages

LS, Date, Cal Command

The document discusses three Linux commands: ls, date, and cal. The ls command lists files and directories. It has many options to customize the output like -l for a long listing, -t to sort by modification time, and -a to show hidden files. The date command displays or sets the system date and time. Common options include +%D to show date only and +%T to show time only. The cal command prints a calendar and can be used to view calendars for specific months and years, from year 1 up to 9999.

Uploaded by

rahul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views3 pages

LS, Date, Cal Command

The document discusses three Linux commands: ls, date, and cal. The ls command lists files and directories. It has many options to customize the output like -l for a long listing, -t to sort by modification time, and -a to show hidden files. The date command displays or sets the system date and time. Common options include +%D to show date only and +%T to show time only. The cal command prints a calendar and can be used to view calendars for specific months and years, from year 1 up to 9999.

Uploaded by

rahul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Command

Command: In Linux command is a instruction passed to the shell via terminal

Syntax: [ command] [option] [argument]

option - option is optional, we do use option in cmd to filter out put as per our requirement.

Argument – It generally contain the file/folder on which you want to perform the command.

In some command passing argument is mandatory.

If we don’t pass argument, then it will take default argument.

ls, date and cal Commands


1)ls Command:

We can use ls command to list out all files and directories present in the given directory. We can get
manual documentation for any command by using man.

man ls It provides complete information about ls command.

Various options of ls Command:

1) ls It will display all files and directories according to alphabetical order of names.

2) ls -r It will display all files and directories in reverse of alphabetical order.

3) ls | more to display content line by line (To come out we have to use q)

4) ls -l to display long listing of files

5) ls -t : To display all files based on last modified date and time. Most recent is at top and old are at
bottom.
6) ls -rt : to display all files based on reverse of last modified date and time. Old files are at top and
recent files are at bottom.

7) ls -a : means all To display all files including hidden files. Here . and .. also will be displayed.

8) ls -A : means almost all To display all files including hidden files except . and ..

9) ls -F : To display all files by type.

directory  /

executable file  *

link file  @

10) ls -i :

 To display all files including inode number.

 i-node is the address of location, where file attributes are stored.

 The following are various file attributes

1) The size of the file

2) The number of links

3) The owner

4) The group

5) The creation time

6) The last modified time

7) The last accessed time etc

11) ls -R

 R means Recursive.

 It will list all files and directories including sub directory contents also. By default, ls will display
only direct contents but not sub directory contents.

12) ls -s

The number of blocks used by file will be displayed. 1 Block = 1Kb

Note: In ubuntu each block is of 1KB but not 4KB.

13) ls -h display in human readable format

2]date Command:

We can use date command to display date and time of system.


Various Options:

1) date +%D To display only date in the form: mm/dd/yy

2) date +%T To display only time in the form: hh:mm:ss

3) date +%d To display only day value

4) date +%m To display only month value

5) date +%y To display only year value in yy form

6) date +%Y To display only year value in yyyy form.

7) date +%H To display only Hours value (in 24 hours scale format)

8) date +%M To display only Minutes value

9) date +%S To display only Seconds value

3]cal Command:

$ cal  To display current month calendar.

$ cal 2020  To display total year calendar.

$ cal 1  To display 1st year calendar.

$ cal 9999 To display 9999th year calendar.

$ cal 10000 cal: year '10000' not in range 1..9999

$ cal 08 2019 To display august 2019th calendar

Note: cal command can provide support only for the years 1 to 9999.

You might also like