Sei sulla pagina 1di 100

UNIX and Shell Scripting

Module 4: UNIX Commands



2
Module 4 Objectives
Upon completing this module, you will be able to:
Describe how to execute the following UNIX commands
General Purpose
File Manipulation
Text Processing
Printing
Network and Communication
Compression/Decompression
Process Management


3
Module 4 Agenda
Topic Name Duration
General Purpose Commands
45 min
File Manipulation Commands
65 min
Text Processing Commands
75 min
Printing Commands
10 min
Network and Communication Commands
10 min
Compression/Decompression Commands
15 min
Process Management Commands
40 min

4
Demonstration Instructions
For slides 5-19

This topic comprises General Purpose Command sections.
These sections will be conducted in the following manner:
Instructions:
Explain the command.
Ask participants to do the same.
Discuss the related slide.

Note: The commands would be used by the faculty and participants
simultaneously.

5
Using UNIX Help (1 of 2)
The man command
Formats and displays online manual pages
Accepts the name which is normally the name of manual page,
which is typically the name of the command, function, or file




To search the specified string in all manual pages:

Command Function
$ man cat Displays the manual page for cat command
Command Function
$ man -K ln Searches the word ln in all manual pages

6
Using UNIX Help (2 of 2)
To force display all the manual pages:


Command Function
$ man a cat Displays all pages containing string cat

7
Print Working Directory
The pwd command
Stands for print working directory of the user


Command Function
$ pwd If user10 is working in directory TestD1, it will
display /home/user10/TestD1.

8
Display List of Files and Directories
The ls command
Gives the list of files and directories



To list all files and directories including hidden files and
directories:
Command Function
$ ls Lists all files and directories in present working directory
Command Function
$ ls -a TestD1 TestF1 TestF2 TestF3 .TestHidden1 .TestHidden2

Files or directories starting with .(dot) are hidden files or
directories in UNIX.

9
Display Long Listing in ASCII
To display long listing in ASCII collating sequence showing
seven attributes of a file:

$ ls l
Total 72
drw_r_xrwx 1 user1 user1 123 May 10 13:45 TestD1
_rw_r_xrwx 1 user1 user1 123 May 10 13:45 TestF1
_rw_r_xrwx 1 user1 user1 123 May 10 13:45 TestF2
_rw_r_xrwx 1 user1 user1 123 May 10 13:45 TestF3

Number of
links to the file
Size of the file in
terms of Bytes
Name of the
file or Directory
User who created
the file or directory
Last modification
date and time of
file and directory
Group which user
belongs to
Permissions of the
file or directory to
user, group, and
others

10
Display Sorted File Names by Last
Modification Time
$ ls -t












List of files and directories without t option
Shows most recently modified file first
TestF1 is most recently modified.
Create User Directories
The mkdir command
Allows to create directories

Command Function
$ mkdir TestD1 Creates the directory in present working
directory with the name TestD1
$ mkdir TestD2 TestD3 Creates the directory in present working
directory with the name TestD2,TestD3

11

12
Remove Directory
The rmdir command
Allows to delete one or more directories
Removes directory (the directory has to be empty)


Command Function
$ rmdir TestD1 Removes TestD1 directory present in current
directory
$ rmdir TestD2 TestD3 Removes TestD2 and TestD3 directories
present in current directory

13
See List of Users Currently Logged in (1
of 2)
The who command
Shows the name of the users who are currently logged in
Shows the terminal type and the time users logged in
$ who


user1 tty3a Jun 10 09:15
user2 tty3c Jun 10 09:25
Name of the users currently logged in
Name of the terminal user is using
Login date and time users logged in

14
See List of Users Currently Logged in (2
of 2)
To display the names and number of users currently logged in.






Command Function
$ who -q Displays only the names and number of users
currently logged in
When this option works all other options do not work
with who.
Showing two users currently logged
in, root and abhishek.x.sharma

15
Display Information about Current
Terminal





Command Function
$ who -m Displays information about the current terminal
Showing abhishek has logged in from terminal
pts/2 on date and time Dec 11 10:22
Locate Specific Programs on Prompt
The which command
Locates a command
$ which ls


16
Showing ls command file is located in the
directory path /bin/ls

17
Change Password
The passwd command
Allows to change the password

$ passwd
(after pressing enter key you will receive following three prompts.)
Current passwd :
New passwd :
Confirm new passwd :


18
Move Around in File System (1 of 2)
The cd command
Stands for change directory
Acts as primary command for moving around the file system






Command Function
$ cd TestD1 Moves to child directory TestD1. from current directory
$ cd .. Moves to the parent directory from TestD1 if you are in
TestD1
Move Around in File System (2 of 2)

19





Command Function
$ cd ~ Moves to the HOME directory
Present Working Directory
Command cd ~ will take you to home directory of the user.

20
Module 4 Agenda
Topic Name Duration
General Purpose Commands
45 min
File Manipulation Commands
65 min
Text Processing Commands
75 min
Printing Commands
10 min
Network and Communication Commands
10 min
Compression/Decompression Commands
15 min
Process Management Commands
40 min

21
Demonstration Instructions
For slides 22-36

This topic comprises command sections. These sections will be
conducted in the following manner:
Instructions:
Explain the command.
Ask participants to do the same.
Discuss the related slide.

Note: The commands would be used by the faculty and participants
simultaneously.

22
Display Contents of File on Screen
(1 of 2)
The cat command
Is most frequently used command
Has three related functions with regard to the text files



To concatenate contents of a files on the screen.



Command Function
$ cat TestF1 Displays the contents of file TestF1 on the screen
Command Function
$ cat TestF1 TestF2 TestF3 Note: Another role of cat is concatenation.
Displays the concatenated contents of
three files TestF1 TestF2 TestF3

23
Display Contents of File on Screen
(2 of 2)
To display numbers to the lines while displaying


Command Function
$ cat -n TestF4 Lists line numbers while displaying contents of
TestF4

24
Create New File on Screen







Command Function
$ cat > TestF4 Creates a new file with the name TestF4. Press
ctl+d after enter key

25
Copy Files or Directories
The cp command

Command Function
$ cp TestF1 TestF5 Copies contents of the file TestF1 to TestF5.
If file TestF5 doesnt exist it will get created
$ cp -i TestF1 TestF2 As an interactive option, prompts the user
before overwriting the destination file
$ cp
/home/user10/TestF2
/home/user10/TestD1
Copies contents of TestF2 to the destination
directory TestD1 with the same file name
$ cp -r
/home/user10/TestD1
/home/user10/TestD2
Copies contents of TestD1 and its
subsequent directories to the destination
directory TestD2 with the same names

26
Rename File or Directory
The mv command
Renames file or directory
Moves a group of files to different directory





To confirm before renaming file or directory
Command Function
$ mv TestF1 TestFNew Renames the file TestF1 with TestFNew
$ mv TestFNew TestF2
TestF3 TestD1
Moves the files TestFNew TestF2 TestF3 to
directory TestD1
Command Function
$ mv -i TestT2 TestFNew Prompts the user before overwriting the file
TestFNew

27
Delete File
The rm command
Allows us to delete one or more files




To confirm from user to delete one or more file(s)
Command Function
$ rm TestFNew Removes the file TestFNew
Command Function
$ rm -i TestF2 TestF3 Prompts the user for confirmation before
removing each file
$ rm -r TestF4 Performs a recursive search for all
subdirectories and files within these
subdirectories and removes all of them

28
Locate File Based on Search Criteria
The find command
Locates files which meet the search criteria



Command Function
$ find . -name TestF1 Searches file TestF1 from current directory
onwards and prints its path

29
Compare Two Files
The cmp command
Compares two files byte by byte
Displays the location of the first mismatch

Command Function
$ cmp TestF1 TestF1 Compares TestF2 and TestF3
Will get result like TestF1 TestF2 differ : char
27, line 1
$ cmp TestFNew TestF2 Compares TestFNew and TestF2
Will not display any message, simply return
prompt if two files are identical

30
Associate One File with Another
The ln s command
Creates symbolic link between files
Soft link is a synonym to symbolic link


Command Function
$ ln s TestF2 TestFln Creates a soft link TestFln to file TestF2

31
Page Through File
The less command
Does not read the entire file



To scroll forward in the file
^D option of less command
Scrolls forward (Default one half of the screen)

To scroll backward in the file
^B option of less command
Scrolls backward (Default one half of the screen)
Command Function
$ less TestLess Displays contents of file TestLess in pagewise manner

32
Display First Few Lines of File
The head command
Displays first few lines of the file

Command Function
$ head TestF1 Displays the first 10 lines of the file TestF1, if TestF1
has more then 10 lines; otherwise all lines
$ head -2 TestF1 Displays the first two lines of the file TestF1, where -
2 represents any positive number n

33
Display Last Few Lines of File
The tail command
Reads last few lines of any text given and writes them on the screen



Command Function
$ tail TestF1 Displays the last 10 lines of the file TestF1, if TestF1
has more then 10 lines otherwise all lines
$ tail -2 TestF1 Displays the last two lines of the file TestF1, where -
2 represents any number n and can be negative or
positive

34
Change Mode (Permission) of File or
Directory (1 of 3)
The chmod command
Allows to change the mode (permission) of files and directories

There are three permissions to a file
r read (octal equivalent 4)
w write (octal equivalent 2)
x execute (octal equivalent 1)

There are three entities to which any combination of these
permissions are assigned:
User (owner)
Group
Others

35
Change Mode (Permissions) of File or
Directory (2 of 3)
The chmod command
Assuming _rw_r_ _r_ _ are the permissions for the file TestF1 from
the long listing, they signify that:
Owner can read and write the file but cant execute the file TestF1
Members of the group can read the file, but cannot write into the file or
execute the file TestF1
All others can only read the file TestF1

36
Change Mode (Permissions) of File or
Directory (3 of 3)



Command Function
$ chmod 700 TestF1 Changes the existing permission of file
TestF1 to rwx for user and removes all
permissions for group and others
$ chmod go+r TestF1 Assigns permission r to group and others
$ chmod go+w,go-r TestF1

Assigns permission w to group and others
and removes r permission for group and
others for file TestF1
$ chmod -R go+rwx TestD1

Assigns permission r, w, and x to group
and others for directory TestD1 as well as
all files and subdirectories within it

37
Knowledge Check (1 of 3)
If f1 and f2 are directories, explain how the command mv f1 f2
behaves when:

1. f2 exists
2. f2 does not exist


38
Knowledge Check (2 of 3)
Assuming that you are positioned in the directory /home/user1,
what are the following commands presumed to do?
Additionally, explain whether they will work at all.

1. cd ../..
2. mkdir ../bin
3. rmdir ..
4. ls ..

39
Knowledge Check (3 of 3)
Find all files in the present directory onwards, starting with the
name T.


40
Activity 1: General Purpose and File
Manipulation Commands
Activity time: 10 minutes
Use General Purpose and File Manipulation Commands

Instructions:
Create a file named TestFileCommand with at least ten lines and
perform the following tasks on the file:
Rename the file TestFileCommand to cmdTest.
Change the permissions of the file for following:
User read, write, and execute
Group read
Others read and execute
List the first three lines of the file.
List all the lines after line four.
Create a soft link to the file cmdTest with name cmdTestLn.

41
Module 4 Agenda
Topic Name Duration
General Purpose Commands
45 min
File Manipulation Commands
65 min
Text Processing Commands
75 min
Printing Commands
10 min
Network and Communication Commands
10 min
Compression/Decompression Commands
15 min
Process Management Commands
40 min

42
Demonstration Instructions
For slides 43-65

This topic comprises command sections. These sections will be
conducted in the following manner:
Instructions:
Explain the command.
Ask participants to do the same.
Discuss the related slide.

Note: The commands would be used by the faculty and participants
simultaneously.

43
Using Pipe (1 of 2)
Accomplishes complex tasks with ease by combining UNIX
commands

Combines UNIX commands through pipes and filters

Using pipe
The symbol | is the UNIX pipe symbol.
Is used on the command line
Means that the standard output of the command to the left of the pipe
gets sent as standard input of the command to the right of the pipe

44
Using Pipe (2 of 2)
Using pipe
Example
$ who | sort | lpr

who | sort | lpr

who command process writes to pipe1
sort command process reads from pipe1, writes to pipe2
lpr command process reads from pipe2
writefd
readfd
writefd
readfd
pipe1 pipe2
Data flow
Kernel
who Process sort Process lpr Process

45
Using Filter
A filter:
Is a UNIX command that does some manipulation of the text of a file





Transforms or filters the data it receives via the pipes with which it is
connected

Can have any number of input and output pipes
pump sink filter
filter
pipe pipe pipe

46
Search for Specific Pattern in Files
(1 of 2)
The grep command
Stands for global search for regular expression and print
Functions as standard file searching and selection utility

Command Function
$ grep Accenture TestF1 Searches string Accenture in file
TestF1 and displays those lines
$ grep Accenture TestF1 TestF2 Searches string Accenture in file
TestF1 and TestF2 and displays
those lines
Displays the name of the file as well
$ grep Accenture is a TestF1 Searches pattern comprising more
than a single word
Note: Double quotes can be used to
enclose the same.

47
Search for Specific Pattern in Files
(2 of 2)
To search for the specific pattern in one or more files without
heeding the case




Command Function
$ grep Accenture -i TestF1 Searches for the pattern without
heeding the case.
Note: i option makes it case
insensitive.

48
Usages of grep Filter


Command Function
$ cat TestF1 | grep Accenture Sends the contents of file TestF1 to
standard input using pipe. grep takes
input from standard input in place of
file, searches Accenture, and
displays the lines which contain it.
$ ls -l /tmp | grep 'root' Shows all processes with the word
"root" somewhere in the line. That
doesn't mean that all the process
would be owned by root. However,
by using grep filter we can cut down
the number of processes we need to
look at.

49
Get the Difference Between Two Files
(1 of 2)
The diff command
Displays file differences
$ diff TestDiff1 TestDiff2
$ diff TestDiff1 TestDiff2

50
Get the Difference Between Two Files
(2 of 2)
Represents appended line> 101 Haleem ASE
Represents changed lines 8-11 of TestDiff1 with 9,10 of file TestDiff2
Represents deleted line< 101 Abhishek SSE

51
Ignore Case
To ignore case while getting difference between two files
$ diff -i TestDiff1 TestDiff2

Due to the use of i option, case of
the letters Rachit is ignored.
Represents the difference due to
the case of the letters rachit

52
Ignore Trailing Blanks
To ignore the trailing blanks while getting difference between
two files
$ diff -b TestDiff3 TestDiff4

Without b option diff identifies blank
spaces or tabs as difference.
Causes blanks (spaces and tabs) to
compare equally even if an unequal
number of blanks exist.

53
Sort Contents of File
The sort command
Sorts ASCII (Text) files
Sorts according to the ASCII collating sequence, i.e. sorts the
spaces and the tabs first, then the punctuation marks followed by
numbers, uppercase letters, and lower case letters

Command Function
$ sort TestF1 Sorts the contents of TestF1 and
displays the sorted output on screen
$ sort TestF1 TestF2 Sorts the contents of TestF1 and
TestF2 respectively and displays the
result on screen

54
Sort File Numerically




Sort without n Option Sort with n Option
Command Function
$ sort -n TestNSort Sorts file TestNSort on numbers in place of ASCII
values

55
Usages of Sort Filter

Command Function
$ ls | sort Gets the input from the input stream and displays
list of files in sorted order
$ cat TestF1 | sort Pipes the contents of TestF1 to sort

56
Remove Duplicate Contents from File
The uniq command
Simply fetches one copy of each line and writes it to the standard
output
Requires a sorted file as input




To select non-repeated lines from a file


Command Function
$ uniq result Fetches one copy of each line and writes it on
screen
Command Function
$ uniq -u result Fetches unique line from result

57
Usages of uniq Filter
Command Function
$ sort TestF1 | uniq Sort pipes the output to uniq which fetches one
copy of each line and writes to standard output
$ cat result | uniq -u Cat pipes the sorted output to uniq which selects
the lines which are non repeated

58
Find Number of Words in File
The wc command
Stands for word count
Displays count of words, lines, and characters


Command Function
$ wc TestF1
5 13 57 TestF1
Displays number of lines, words, and
characters in the file TestF1. This is the
standard representation
$ wc -w TestF1
13 TestF1
Displays number of words in the file
TestF1

59
Find only the Number of Lines in File


Command Function
$ wc -l TestF1
5 TestF1
Displays Number of lines in the file TestF1

60
Usages of wc Filter
Command Function
$ who | wc l Counts the number of users logged into your
computer system
The output of the who command is piped into wc
command, which counts the number of lines in the
output of who
$ ls -l | wc -l

Counts the number of files and directories
present in your current working directory

61
Remove Sections from File on Prompt
The cut command
From each line of file displays selected
Columns
Fields



Command Function
$ cut -c 3-10,15-20 TestF1 Cuts characters 3 to 10 and 15 to 20, and
displays that on standard output

62
Remove Selected Fields from File on
Prompt
Default field delimiter (Tabs and Spaces)
Different delimiter (can also be used)
Two options need to be used
-d for the field delimiter
-f for the field lists
Command Function
$ cut -d -f 2,4 TestF1 Extracts 2nd and 4th the fields from the file
TestF1 and displays them on standard
output

63
Usages of cut Filter
Command Function
$ who | cut -d -f 1 Extracts the users list logged into your
computer system
Output of who command is piped to cut
command, which extracts the first field i.e.
user name.
$ ls | cut -d -f 1,3,5,7 Extracts the file permissions, user name,
file size, and name
Output of ls command is piped to cut
command, which extracts fields 1,3,5,7
from the output of ls command.

64
Paste Sections from Two Files on
Prompt
The paste command
Pastes vertically rather than horizontally
Displays two or more files adjacently by pasting them


Command Function
$ cut -d -f 2,5 TestF1 > cutList1 Extracts fields 2 and 5 from file
TestF1 and sends to cutList1
$ cut -d -f 3,6 TestF2 > cutList2 Extracts fields 3 and 6 from file
TestF2 and sends to cutList2
$ paste cutLsit1 cutList2 Pastes two files cutList1, cutList2
vertically
In the output original lines are
separated by TABs by default.
$ paste -d | cutList1 cutList2 Paste uses the tab as the default
delimiter, we can specify one or
more delimiter with d option.

65
Merge Two Files on Prompt
The join command
A join of the two relations specified by the lines of file1 and file2
Files are joined on a common key field (column) that should exist in
both files.
Both files must be sorted on the key field in the same order.






$ join -t"\t" file1 file2
01123 HP 9000/825 Hewlett Packard
02213 Sun3/110 Sun Microsystems
08412 HP 9000/835 Hewlett Packard
file1 file2
01123 HP 9000/825
02213 Sun 3/110
03320 Sun 4/110
08412 HP 9000/835
01123 Hewlett Packard
02213 Sun Microsystems
03321 Sun Microsystems
08412 Hewlett Packard

66
Knowledge Check (1 of 2)
What is the function of the following commands?

1. grep a b c
2. grep <Test> TestFile


67
Knowledge Check (2 of 2)
Show the octal representation of the following permissions:

1. rwxr-xrw-
2. rw-r-----
3. --x-w-r--


68
Activity 2: Filter Command
Activity time: 10 minutes
Use appropriate filter command to accomplish the given task

Instructions:
Create a file named TestGrep1 and TestGrep2, add ten to fifteen
lines in each file with at least ten words separated by | (pipe sign) in
each line
Perform the following operations on the file:
Search for the string accenture or Accenture.
Cut the column 2-3 and 5-7 respectively from file TestGrep1.
Paste the deleted columns on the screen.
Find out the difference between both files and make changes to make
them identical.

69
Module 4 Agenda
Topic Name Duration
General Purpose Commands
45 min
File Manipulation Commands
65 min
Text Processing Commands
75 min
Printing Commands
10 min
Network and Communication Commands
10 min
Compression/Decompression Commands
15 min
Process Management Commands
40 min

70
Demonstration Instructions
For slides 71-73

This topic comprises command sections. These sections will be
conducted in the following manner:
Instructions:
Explain the command.
Ask participants to do the same.
Discuss the related slide.

Note: The commands would be used by the faculty and participants
simultaneously.

71
Print Contents of File
The lpr command
Prints files from the command prompts




Command Function
$ lpr TestF1 Sends the file TestF1 for printing

72
Cancel Jobs
To cancel the jobs that have been queued for printing

The lprm command

$ lprm
$ lprm 295
Removes the job with id 295

73
Check Print Queue on Prompt
The lpq command
Shows the current print queue status on the named printer
$ lpq


74
Module 4 Agenda
Topic Name Duration
General Purpose Commands
45 min
File Manipulation Commands
65 min
Text Processing Commands
75 min
Printing Commands
10 min
Network and Communication Commands
10 min
Compression/Decompression Commands
15 min
Process Management Commands
40 min

75
Demonstration Instructions
For slides 76-78

This topic comprises command sections. These sections will be
conducted in the following manner:
Instructions:
Explain the command.
Ask participants to do the same.
Discuss the related slide.

Note: The commands would be used by the faculty and participants
simultaneously.

76
Send Packets
To send packets to a machine known to be in the network
The ping command
On not receiving any reply packets, ping will exit with code 1
On error it exits with code 2
Otherwise it exits with code 0
Intended for use in network testing, measurement, and management
$ ping 10.116.69.12
Packet Received 0
indicates that there is no
connectivity between the
local and remote hosts.

77
Connect to Machine
To connect to a machine, if we have account on a host in the
local network
The telnet command
Used to communicate with another host using the telnet protocol
$ telnet 10.116.69.12





After supplying command trying to connect
If connects successfully, asks for Login:
If Host is not getting connected

78
Print Network Connections on Prompt
The netstat command
$ netstat



79
Module 4 Agenda
Topic Name Duration
General Purpose Commands
45 min
File Manipulation Commands
65 min
Text Processing Commands
75 min
Printing Commands
10 min
Network and Communication Commands
10 min
Compression/Decompression Commands
15 min
Process Management Commands
40 min

80
Demonstration Instructions
For slides 81-84

This topic comprises command sections. These sections will be
conducted in the following manner:
Instructions:
Explain the command.
Ask participants to do the same.
Discuss the related slide.

Note: The commands would be used by the faculty and participants
simultaneously.

81
Create New Archive
The tar command
Stands for tape archive
Writes archives directly to tape devices
Creates new archives
Lists files in existing archives
Extracts files from archives
Command Function
$ tar -cvf archive.tar TestF1 TestF2 Creates archive file archive. tar for files TestF1 and
TestF2
Additionally, use of v (verbose) option displays
the progress while tar works.
To create archive, we need to specify the name of
the archive (with f), the copy, or write operation (-
c), and the filenames.

82
Extract Archive File
Command Function
$ tar -xvf archive.tar tar uses x option to extract files from an archive

83
Compress and Expand Compressed File
The gzip and gunzip command
gzip compresses the file
gunzip expands compressed file
$ gzip TestGipTry


Create file TestGipTry.gz

84
Compression/Decompression
Commands
$ gunzip TestGipTry.gz



85
Module 4 Agenda
Topic Name Duration
General Purpose Commands
45 min
File Manipulation Commands
65 min
Text Processing Commands
75 min
Printing Commands
10 min
Network and Communication Commands
10 min
Compression/Decompression Commands
15 min
Process Management Commands
40 min

86
Demonstration Instructions
For slides 87-93

This topic comprises command sections. These sections will be
conducted in the following manner:
Instructions:
Explain the command.
Ask participants to do the same.
Discuss the related slide.

Note: The commands would be used by the faculty and participants
simultaneously.

87
Print Processes (1 of 3)
To print currently active processes on prompt
The ps command
Stands for process statistics
Produces a report summarizing execution statistics for current processes






Command Function
$ ps By default displays all active processes

88
Print Processes (2 of 3)
$ ps






PID TTY TIME CMD
6874 pts/9 0:00 ksh
6877 pts/9 0:01 csh
418 pts/9 0:00 csh

Each process
assigned a unique
ID known as PID.
The terminal with which the
process is associated (the
controlling terminal).
The cumulative process
time (TIME) that has been
consumed since the
process has started.
CMD is the
process name.

89
Print Processes (3 of 3)
To print detail information of processes on the prompt

$ ps f





UID PID PPID C STIME TTY TIME CMD
root 0 0 0 09:36:35 ? 0:00 sched
root 1 0 0 09:36:35 ? 0:02 /etc/init


Owner ID of Process
Parent Process ID
Time the process started

90
Kill Process on Prompt
The kill command
The only way to abort a command or process while it is executing, is
to send it a certain kind of `signal, which can be sent in two ways:
A single keystroke
`kill' command




$ kill 2880

91
Run Processes in Background
The & option with commands
Multitasking system lets a user do more than one job a time
Only one job can run in the foreground
Rest all have to run in the background
& is the shell operator used to run a process in the background
$ sort -oresult TestDiff1 &

The PID of the invoked command
Status of the
background process
after completion

92
Execute Job (1 of 2)
To execute a job at a particular time on the prompt
The at command
Schedules a command to be run at a particular time
Takes time as an input argument upon which command to be executed
Sends all jobs go to the queue
Executes jobs only once


Job Submitted
Job Executed

93
Execute Job (2 of 2)
To execute a job repeatedly at particular time on the prompt
The crontab command
Runs job automatically at regular interval

Job Submitted
Job Executed

94
Knowledge Check (1 of 3)
Of the following options, specify the name of command for
running process at specified time:

1. ps
2. ls
3. at
4. Batch



95
Knowledge Check (2 of 3)
Which of the following options will you choose to send any
process to background?

1. ps
2. at
3. &
4. kill


96
Knowledge Check (3 of 3)
List all the processes currently running.

Identify the PPID of the background process created for sort
command.

97
Activity 3: Compression/Decompression
Commands
Activity time: 5 minutes
Identify and apply the compression/decompression commands to
perform given operation

Instructions:
Create a file TestCmdG1 and TestCmdG2 with at least ten lines in
both the files
Perform the following operations:
Compress both the files in current working directory.
Create archive file with the name TestCmdArc.tar containing both the
files.
Extract the zip files.
Extract the tar file TestCmdArc.tar.


98
Activity 4: Background Process
Activity time: 5 minutes
Execute the command required for sending sort operation to
background

Instructions:
Perform sort operation on file TestCmdG1 and send it to the
background.


99
Module Summary
Upon completing this module, you should now be able to:
Describe how to execute the following UNIX commands
General Purpose
File Manipulation
Text Processing
Printing
Network and Communication
Compression/Decompression
Process Management

100
Questions and Comments
What questions or comments
do you have?

Potrebbero piacerti anche