Unix

Unix Command Details

Cat

Syntax:

cat [options] [files]

Examples:

cat file1
cat file1 file2 > all
cat file1 >> file2

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

Cd

Syntax:

cd file location

Example:

To switch to a subdirectory (of the current directory) named mytest:

To move to the parent directory of the current directory:

To move to the root directory:

To return to your home directory, enter:

Chgrp

Syntax:

chgrp [OPTION]… GROUP FILE…
chgrp [OPTION]… –reference=RFILE FILE…

Chmod

Syntax:

chmod [option] mode files

Option:

Option Description
-R Descend directory arguments recursively while setting modes.
-f Suppress error messages if command fails.

 

Mode Description
Who u=user, g=group, o=other, a=all (default)
Opcode + means add permission
– means remove permission
= means assign permission and remove the permission of unspecified fields
Permission r=Read, w=write, x=Execute, s=set uid bit, t=sticky bit
u=user, g=group, o=other, l=mandatory locking

Example:

chmod 751 emp

Cp

Syntax:

cp file1 file2

Example:

cp /home/test/pictures/picture.jpg /home/test/new pictures/picture.jpg

File

Syntax:

file [-bchiklLNnprsvz0] [–apple] [–mime-encoding] [–mime-type]
[-e testname] [-F separator] [-f namefile]
[-m magicfiles] file

Example:

file *.txt

Find

Syntax:

find [path…] [expression]

Grep

Syntax:

grep [OPTIONS] PATTERN [FILE…]

Head

Syntax:

ln

ln [OPTION]… TARGET [LINK_NAME]
ln [OPTION]… TARGETDIRECTORY
ln [OPTION]… –target-directory=DIRECTORY TARGET

ls

ls [OPTION]… [FILE]…

mkdir


mv

Syntax:
mv myfile mynewfilename
Syntax:
pwd

rm

Syntax:

rm filename

rmdir

Syntax:

rmdir directory name

tail

Syntax:

© 2015, www.techkatak.com. All rights reserved.

2 thoughts on “Unix Command Details

Comments are closed.