View
247
Download
0
Category
Preview:
Citation preview
7/26/2019 Unix Commands 1
1/31
UNIX BASIC COMMANDS:LS
Thelscommand lists all files in the directory that match thename. If name is left blank, it will list all
of the files in the directory.
SYNTAX
The syntax for thelscommand is:
ls [options] [names]
OPTIONS
Option Description
-a Displays all files.
-b Displays nonprinting characters in octal.
-c Displays files by file timestamp.
-C Displays files in a columnar format (default)
-d Displays only directories.
-f Interprets eachnameas a directory, not a file.
-F Flags filenames.
-g Displays the long format listing, but exclude the owner name.
-i Displays the inode for each file.
-l Displays the long format listing.
7/26/2019 Unix Commands 1
2/31
7/26/2019 Unix Commands 1
3/31
The syntax for thecatcommand is:
cat [options] [fles]
OPTIONS
Option Description
-e $ is printed at the end of each line. This option must be used with -v.
-s Suppress messages pertaining to files that do not exist.
-t
Each tab will display as I and each form feed will display as L. This option must be used
with -v.
-u Output is printed as unbuffered.
-v Display control characters and nonprinting characters
EXAMPLE
cat fle1
cat fle1 fle2 > all
cat fle1 >> fle2
UNIX BASIC COMMANDS:CD
Thecdcommand changes directory.
SYNTAX
The syntax for thecdcommand is:
cd [dir]
7/26/2019 Unix Commands 1
4/31
EXAMPLE
cd tech
cd /tech
UNIX BASIC COMMANDS:MKDIR
Themkdircommand creates a single directories or multiple directories.
SYNTAX
The syntax for themkdircommand is:
mkdir [options] directories
OPTIONS
Option Description
-m mode Sets the access mode for the new directory.
-p If the parent directories don't exist, this command creates them.
EXAMPLE
mkdir -m 444 tech
mkdir -p tech/net/aqs
UNIX BASIC COMMANDS:MVThemvcommand allows you to move and rename files.
SYNTAX
The syntax for themvcommand is:
7/26/2019 Unix Commands 1
5/31
mv [options] sources target
OPTIONS
Option Description
-f Forces the move.
-i Prompt for a confirmation before overwriting any files.
EXAMPLE
mv - tech /usr
UNIX BASIC COMMANDS:TELNET
Thetelnetcommand allows you to communicate to another host using the TELNET protocol.
SYNTAX
The syntax for thetelnetcommand is:
telnet [host [port]]
UNIX BASIC COMMANDS:FTP
Theftpcommand allows you to transfer files to and from a remote server.
SYNTAXThe syntax for theftpcommand is:
tp [options] [hostname]
OPTIONS
7/26/2019 Unix Commands 1
6/31
Option Description
-d Debugging is enabled.
-g Filename globbing is disabled.
-i Interactive prompting is disabled.
-n When you are initially connecting, auto-login is disabled.
-v Display all responses from the server.
EXAMPLE
tp tech
tp -v tech
UNIX BASIC COMMANDS:KILL
Thekillcommand allows you to kill one process ID or multiple process IDs.
SYNTAX
The syntax for thekillcommand is:
kill [options] Is
OPTIONS
Option Description
-l Lists the signal names.
-signal The signal number of name. Using the signal number of 9, means that the kill is absolute.
7/26/2019 Unix Commands 1
7/31
EXAMPLE
kill -! "#$#!
UNIX BASIC COMMANDS:PS
Thepscommand displays active processes.
SYNTAX
The syntax for thepscommand is:
ps [options]
OPTIONS
Option Description
-a Displays all processes on a terminal, with the exception of group leaders.
-c Displays scheduler data.
-d Displays all processes with the exception of session leaders.
-e Displays all processes.
-f Displays a full listing.
-glist Displays data for thelistof group leader IDs.
-j Displays the process group ID and session ID.
-l Displays a long listing
-plist Displays data for thelistof process IDs.
7/26/2019 Unix Commands 1
8/31
-slist Displays data for thelistof session leader IDs.
-tlist Displays data for thelistof terminals.
-ulist Displays data for thelistof usernames.
EXAMPLE
ps -e
ps -au%
UNIX BASIC COMMANDS:GREP
Thegrepcommand allows you to search one file or multiple files for lines that contain a pattern. Exit
status is 0 if matches were found, 1 if no matches were found, and 2 if errors occurred.
SYNTAX
The syntax for thegrepcommand is:
grep [options] pattern [fles]
OPTIONS
Option Description
-b Display the block number at the beginning of each line.
-c Display the number of matched lines.
-h Display the matched lines, but do not display the filenames.
-i Ignore case sensitivity.
-l Display the filenames, but do not display the matched lines.
7/26/2019 Unix Commands 1
9/31
-n Display the matched lines and their line numbers.
-s Silent mode.
-v Display all lines that do NOT match.
-w Match whole word.
EXAMPLE
grep -c tech fle1
dd commands:
he ddcommand copies a file, convertingthe format of the data in the
process, according to the operandsspecified.
Syntax
dd [OPERAND]...
dd OPTION
Operands
bs=BYTES readand &riteBYTES'(tesat a time )also see ibs=*obs=+
cbs=BYTES convert BYTES'(tes at a time
conv=CONV
S
convert the fle as per the comma separated s(m'ol list, ach s(m'o
ollo&ing* and represents a specifc t(pe o conversion.
ascii
rom 0I0to 0II
ebcdic
rom 0II to 0I0
http://www.computerhope.com/jargon/c/conversi.htmhttp://www.computerhope.com/jargon/o/operand.htmhttp://www.computerhope.com/jargon/r/read.htmhttp://www.computerhope.com/jargon/w/write.htmhttp://www.computerhope.com/jargon/b/byte.htmhttp://www.computerhope.com/jargon/e/ebcdic.htmhttp://www.computerhope.com/jargon/a/ascii.htmhttp://www.computerhope.com/jargon/o/operand.htmhttp://www.computerhope.com/jargon/r/read.htmhttp://www.computerhope.com/jargon/w/write.htmhttp://www.computerhope.com/jargon/b/byte.htmhttp://www.computerhope.com/jargon/e/ebcdic.htmhttp://www.computerhope.com/jargon/a/ascii.htmhttp://www.computerhope.com/jargon/c/conversi.htm7/26/2019 Unix Commands 1
10/31
ibm
rom 0II to alternate 0I0
block
pad ne&line-terminatedrecords &ith spaces to cbs-si3eunblock
replace trailing spaces in cbs-si3e records &ith ne&line
lcase
change upper caseto lo&er case
nocreat
do not create the outputfle
excl
ail i the output fle alread( e%ists
notrunc
do not truncatethe output fle
ucase
change lo&er case to upper case
swab
s&ap ever( pair o input '(tes
noerrorcontinue ater read errors
sync
pad ever( input'lock&ith 56sto ibs-si3e7 &hen used &ith 'lock or
spaces rather than 56s
fdatasync
ph(sicall( &rite output fle data 'eore fnishing
fsync
like&ise* 'ut also &rite metadata,
count=BLOC
KS
cop( onl( BLOCKSinput 'locks
ibs=BYTES read BYTES'(tes at a time )deault. 512+
if=FILE read rom FILEinstead o stdin
http://www.computerhope.com/jargon/n/newline.htmhttp://www.computerhope.com/jargon/t/terminat.htmhttp://www.computerhope.com/jargon/u/uppercase.htmhttp://www.computerhope.com/jargon/l/lowercas.htmhttp://www.computerhope.com/jargon/o/output.htmhttp://www.computerhope.com/jargon/t/truncate.htmhttp://www.computerhope.com/jargon/i/input.htmhttp://www.computerhope.com/jargon/b/block.htmhttp://www.computerhope.com/jargon/n/null.htmhttp://www.computerhope.com/jargon/m/metadata.htmhttp://www.computerhope.com/jargon/s/stdin.htmhttp://www.computerhope.com/jargon/n/newline.htmhttp://www.computerhope.com/jargon/t/terminat.htmhttp://www.computerhope.com/jargon/u/uppercase.htmhttp://www.computerhope.com/jargon/l/lowercas.htmhttp://www.computerhope.com/jargon/o/output.htmhttp://www.computerhope.com/jargon/t/truncate.htmhttp://www.computerhope.com/jargon/i/input.htmhttp://www.computerhope.com/jargon/b/block.htmhttp://www.computerhope.com/jargon/n/null.htmhttp://www.computerhope.com/jargon/m/metadata.htmhttp://www.computerhope.com/jargon/s/stdin.htm7/26/2019 Unix Commands 1
11/31
iag=FLAGS read as per the comma separated s(m'ol list, ach s(m'ol ma( 'e o
append
append mode )makes sense onl( or output7 conv=notruncsuggeste
directuse direct I/8or data
directory
ail unless a director(
dsync
use s(nchroni3ed I/8 or data
sync
like&ise* 'ut also or metadata
fullblock
accumulate ull 'locks o input )i9ag onl(+
nonblock
use non-'locking I/8
noatime
do not update access time
noctty
do not assign controlling terminal rom flenofollow
do not ollo& s(mlinks,
obs=BYTES &rite BYTES'(tes at a time )deault. 512+
of=FILE &rite to FILEinstead o stdout
oag=FLAG
S
&rite as per the comma separated s(m'ol list
seek=BLOC
KS
skip BLOCKSobs-si3ed 'locks at start o output
skip=BLOCK
S
skip BLOCKSibs-si3ed 'locks at start o input
status=no%
er
suppress transerstatistics
http://www.computerhope.com/jargon/i/io.htmhttp://www.computerhope.com/jargon/d/director.htmhttp://www.computerhope.com/jargon/s/symblink.htmhttp://www.computerhope.com/jargon/d/datatran.htmhttp://www.computerhope.com/jargon/i/io.htmhttp://www.computerhope.com/jargon/d/director.htmhttp://www.computerhope.com/jargon/s/symblink.htmhttp://www.computerhope.com/jargon/d/datatran.htm7/26/2019 Unix Commands 1
12/31
:lo& chart
A fowchart is a visual representation o the sequence o steps and decisions needed to
perorm a process. Each step in the sequence is noted within a diagram shape. Steps are
linked by connecting lines and directional arrows. This allows anyone to view the fowchart
and logically ollow the process rom beginning to end
7/26/2019 Unix Commands 1
13/31
7/26/2019 Unix Commands 1
14/31
7/26/2019 Unix Commands 1
15/31
7/26/2019 Unix Commands 1
16/31
Unix - The vi Editor
There are many ways to edit files in Unix and for me one of the best ways is
using screen-oriented text editor vi. This editor enable you to edit lines in
context with other lines in the file.
Now a days you would find an improved version of vi editor which is
called VIM. ere !"# stands for Vi IMproved.
The vi is generally considered the de facto standard in Unix editors because
$
"t%s usually available on all the flavors of Unix system.
"ts implementations are very similar across the board.
"t re&uires very few resources.
"t is more user friendly than any other editors li'e ed or ex.
(ou can use vieditor to edit an existing file or to create a new file from
scratch. (ou can also use this editor to )ust read a text file.
*tarting the vi Editor
There are following way you can start using vi editor $
Command Description
vi filename +reates a new file if it already does not exist, otherwise opens
existing file.
vi -R filename pens an existing file in read only mode.
view filename pens an existing file in read only mode.
7/26/2019 Unix Commands 1
17/31
ollowing is the example to create a new file testfileif it already does not
exist in the current wor'ing directory $
;vi testfle
s a result you would see a screen something li'e as follows $
Recommended