We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 5
Note: If the number of files are very huge, then we can use less and more commands
with Is to display page by page.
$s /dev | less
$s /dev | more
If we want only fixed number of files either from top or from bottom we have to use head
and tall commands with Is commands.
$s /dev | head -5 > disply only top 5 lines
$s /dev | tail -5 > display only bottom 5 lines
Note: We can use these options simultaneously. When ever using options simultaneosuly
then the order is not important.
Ex: All the following commands are equal
Sist-t-r
Sis-t-rl
Sis-lrt
$is-ttr
$is-tr
Q1) Write the Command to display al Files including Hidden Files in Last Modifiction Time
‘Order. Oldest should be First and recent should be Last. It should include Inode
‘Number and the Number of Blocks used by that File, The Output should be in Long,
listing Form?
$ls -atrist
131279 4 -rw-r-r~ 1 durga durga 807 Jan 3 12:57 .profile
131277 4 -rw-r~-r~ 1 durga durga 3771 Jan 3 12:57 .bashre
162011 4 -rw-r--r~ 1 durga durga 220 Jan 3 12:57 .bash_logout
3 durga durga 4096 Jan 3 13:03 .gnupg
3 durga durga 4096 Jan 3 13:03 .local
404481 4 drwxr-xr-x 2 durga durga 4096 Jan 3 13:03 Templates
Q2) Which Command will Lists all Files including Hidden Files along with their Inode
Numbers?
Is
Q3) Which Command will make a Long listing of all the Files in our System including
Hidden Files, sorted by Modification Date (Oldest First)?
Is-latr
DURGASOFT, # 202, 2” Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
83 85 25 26 27, 72.07 21 24 27/28 | www.durgasottonline.com
[email protected]a)
False.
It lists the files based on reverse of alphabetical order of names.
srt > It ill list the files sorted by modification date (Oldest first)
Q5) [sla wil
False
2)date Command:
We can use date command to display date and time of system.
Various Options:
1) date +2%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 valueUNIX/LINUX
£g.1; To display current system date in dd-mm-yyyy format.
default format: mm/dd/yy
date +%d-%m-%Y
£g2; Create an empty file where file name contains current system date.
touch "durgajobsS(date +%d%m%Y).log”
durgajobs31102019.log
durgajobs01112019.10g
durgajobs02112019.log
durgajobs03112019.log
durgajobs04112019.log
Eg 3: Create an empty file where file name contains current system date and time
touch “durgajobs$(date +3%dxmV%HSKMM%S) log"
durgajobs31102019205834.log
Note:
If the file name contains date and time then that file is said to be timestamped file file
with timestamp)
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 999th 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,
ivanam, Ameerpet, Hyder
7/28 | wwew.durgasoftonline.com
[email protected]Topic-5: Working with
1) Creation of Directories:
‘We can create directories by using mkdir command.
1) mkdir dirt
To create a directory
2) mkdir dirt dir2 dir3
3)
To create dir3, But make sure dir1 and in that dir2 should be available already.
mkdir -p dir1/dir2/dir3
-p means path of directories.
All directories in the specified path will be created.
First dirt will be created and in that dir2 will be created and within that dir3 will be
created.
Case Study-1; Film Heroine's Manager
heroines
sunny
jan2020, feb2020,mar2020, -dec2022
katrina
jan2020, feb2020,mar2020, ......dec2022
kareena
jan2@2e, feb2020,mar2e20,......dec2022
jan2020
schedule_1.txt
schedule_2.txt
schedule_31.txt
$ mkdir heroines
$d heroinesUNIX/LINUX
$ mkdir sunny katrina kareena
$ mkdir
{sunny,katrina,kareena}/{ian,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec}_{2020,2021,20
22}
$ touch
{sunny katrina kareena}/{jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec}_{2020,2021,20
22)/schedule_{1..31}.txt
Case Study.
Create 5 directories named with dir6,dir7,dir8,dir9 and dir10. In these directories create
empty files with a.txt,b.txt,c.txt and d.txt
$ mkdir dir{6..10}
$ touch dir(6..10}/{a..d}-txt
Note: *,[],{ } ete are called wild characters. We can use wild card characters in every
command.
2) How to remove Directories:
We can remove directories by using rmdir command.
1) $emdir dirt,
To remove empty directory dirt
2) 2.$ rmdir dirt dir2 dir3
To remove multiple empty directories
‘Note: rmdir command will work only for empty directories. If the directory is not empty
then we will get error. We cannot use rmdir for files. Hence the most useless (waste)
command in linux is rmdir.
durga@durga-VirtualBox:~$ rmdir heroines/
rmdir: failed to remove ‘heroines/': Directory not empty
If the directory is not empty then to remove that directory we should use rm command.
All internal content also will be removed. rm command can work for files also. Hence rm is.
recommended to use than rmdir.
durga@durga-VirtualBox:~$ rm heroines
rm: cannot remove ‘heroines': Is a directory
‘Whenever we are using rm command for directories, we should use -r or -R option. Here
case is not important.
ivanam, Ameerpet, Hyder
7/28 | wwew.durgasoftonline.com
[email protected]