Lab02: Linux Commands Objectives: 1. To Learn The Basic Commands of Linux 2. To Get The Help From The System
Lab02: Linux Commands Objectives: 1. To Learn The Basic Commands of Linux 2. To Get The Help From The System
Objectives
1. To learn the basic commands of linux
2. To get the help from the system
Shell commands
Ls
Date
Man
Hostname
ls command :
It is used to list all the contents in the current working directory.
Syntax : $ ls – options <arguments>
If the command does not contain any argument means it is working in the Current directory.
Options :
a– used to list all the files including the hidden files.
c– list all the files columnwise.
d- list all the directories.
m- list the files separated by commas.
p- list files include „/‟ to all the directories.
r- list the files in reverse alphabetical order.
f- list the files based on the list modification date.
x-list in column wise sorted order.
Examples:
$ ls // Show list of all files and directories
$ ls *.txt // list all .txt files
$ ls –R *.jpg // list all jpg files in the current directory and all associated subdirectories
$ ls –Sl // list all files sorted by size
date Command :
This command is used to display the current data and time.
Syntax :
$date
$date +%ch
Options : -
a = Abbrevated weekday.
A = Full weekday.
b = Abbrevated month.
B = Full month.
c = Current day and time.
C = Display the century as a decimal number.
d = Day of the month.
D = Day in „mm/dd/yy‟ format
h = Abbrevated month day.
H = Display the hour.
L = Day of the year.
m = Month of the year.
M = Minute.
P = Display AM or PM
S = Seconds
BU,CS DEPARTMENT LAB-02
T = HH:MM:SS format
u = Week of the year.
y = Display the year in 2 digit.
Y = Display the full year.
Z = Time zone .
Examples:
$ date // Show the system date
$ date -u // utc time
$ date -r file.txt //shows the last modified date
man Command :
This command is used to display text-only manual pages.
Syntax :
$man –<options>
Options : -
a = List all the manual pages.
d = Display debugging info.
h = list all options.
K string = Find and display all pages containing the specified string.
Exapmles
$ man -du // Show disk usage page
$ man –a less // all pages that match the tile less
$ man 1 –l fil1.txt // show pages from section 1
hostname Command :
This command is used to get information about the hostname.
Syntax :
$hostname –<options><host name>
Options : -
a = Displays the hostname alias.
d = Displays the domain of the host.
h = help.
i = Displays the ip address.
Examples :
$ hostname –i
$ hostname -a
BU,CS DEPARTMENT LAB-02
Exercises
Exercises
1. Run and execute following linux commands and observe the output.