Escolar Documentos
Profissional Documentos
Cultura Documentos
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 11
08/02/2010
About Copyright
01:03:16PM
01:03:16
01:03:16 PM
PM
info@ackabs.net +91.9911064207 11/04/2014
Module
Module -- 22
In this module...
Concepts
Navigation
* Create/Modify/Delete
* File Contents Manipulation
* Printing
* Communication
* Tools & Utilities
* Maintenance
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 33
08/02/2010
Introduction
Basic Unix commands to get familiar with Unix in general and Solaris
in particular
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 44
08/02/2010
Logging In
First of all you should be logged on to the Operating System. Let's see how
to do this --
The system will generally present a login screen. The actual appearance will
vary from system to system but will contain the following two items -
Login
Password
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 55
08/02/2010
Getting Help/On-line manual
man
The operating system comes with an on-line reference manual. You can refer
to this manual using the "man" command.
man ls
would display the "ls" manual pages from the on-line reference manual.
This on-line manual is also called the "man pages".
This
This works
works perfectly
perfectly ifif you
you know
know the
the command.
command. But
But what
what ifif you
you do
do
NOT
NOT know
know the
the command???
command???
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 66
08/02/2010
Getting Help/On-line manual
apropos
You can use the "apropos" command to find other commands based on
keywords. For instance you want search for command(s) related to
networking then
apropos network
would display a list of all the commands/files which are related to the
keyword
"network".
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 77
08/02/2010
Getting Help/On-line manual
man -k keyword
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 88
08/02/2010
Flags or Switches
Flags
The commands may accept various flags or switches. These flags change the
behavior of the command. Usually the flags are preceeded by a "-" character
(unlike the "/" character used in DOS commands).
Example:
ls -al the "-al" are the flags.
The flags can be given in any order and can be combined in groups,
example,
"ls -a -l" is same as "ls -al".
TIP
Most
Most of
of the
the commands
commands support
support aa "-h"
"-h" oror "-?"
"-?" flag.
flag. This
This flag
flag usually
usually
displays
displays aa brief
brief help
help text
text describing
describing the
the command.
command.
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 99
08/02/2010
Piping - |
ls | more
|
| P
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 10
10
08/02/2010
Redirection - >
Redirect Standard OUTPUT to file (overwrite mode)
ls > file
> F
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 11
11
08/02/2010
Redirection - >>
ls >> file
>>
P
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 12
12
08/02/2010
Background & Foreground
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 13
13
08/02/2010
Navigation
/ (root)
(S) | (HP)(L)
|
+----+---+----+---+----+----+---+---+---+---+---+---+---+--+
| | | | | | | | | | | | | | |
| sbin | mnt | devices | proc | lib | | boot | |
bin etc dev usr tmp opt | var |
| | | |
| | stand home
default +-----+--+--+-----+
| | | |
| | | |
bin lib adm local
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 14
14
08/02/2010
Navigation
Absolute Path
The files and directories can be located anywhere in the filesystem. A user can
reach any given file by following or specifying a "path". Every item in the
filesystem has a unique path with reference to the "root". This unique path is
known as "absolute path".
The absolute path of any file is nothing but the path (starting for the root) which
a user would have to take to reach the given file. In computer terms, this is the
sequence of sub-directories which must be traversed (using the "cd" command)
for reaching a file.
/usr/bin/test.txt
^
|
The leading "/" indicates the main root of the filesystem.
Thus in the above example to reach "test.txt" we have to start from "/" then go to
"usr", followed by "bin".
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 15
15
08/02/2010
Navigation
Relative Path
Absolute path is always set with reference to the root whereas the relative
pathis set with respect to the user's current location in the filesystem. The
current location can be found by using the "pwd" command.
Thus an absolute path will always start with a leading "/" while the relative path
will not.
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 16
16
08/02/2010
Navigation
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 17
17
08/02/2010
Navigation
ls -- list
List the contents of directory
Syntax: ls [-options] [ directory | file... ]
Wildcards (*,?) are acceptable directory/file arguments.
What is a wildcard?
Wildcards are special characters which can expand or replace other
regular characters. Unix has two wildcards with respect to filenames; the
asterisk (*) and the question mark (?).
others
- : regular file group
d : directory group name
c : char dev owner
b : block dev
l : link
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 19
19
08/02/2010
Navigation: dot file
others
- : regular file group
d : directory group name
c : What
char
What devdoes
does the '' .'.' (dot)
owner
the (dot) in
in front
front of
of aa filename
filename mean?
mean?
b : block dev
l : link
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 20
20
08/02/2010
Navigation
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 21
21
08/02/2010
Navigation
find -- Find files matching a given selection criteria
Syntax: find <start search directory> -name
<filename> -print -exec <command>
Example: Suppose we want to search for a file name "abc.txt" and we
would like "find" to start searching from the "/usr"
directory, then we will use "find" in the following manner -
find /usr -name "abc.txt" -print
You
Note
Notecan
You Text
can use
use wildcards
Text wildcards with
with the -name option
the -name option
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 22
22
08/02/2010
Navigation
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 23
23
08/02/2010
A Titillating taste of Regular Expression
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 24
24
08/02/2010
Navigation
head -- Display the starting few lines of the file (usually the first 10
lines by default).
tail -- Display the last portion of a file (usually the last 10 lines
by default).
Quite frequently you will find that more than one screen full of data being
flashed on your display and that too very fast. Some people might suggest scroll
lock and some might talk about CTRL-S & CTRL+Q sequence. These methods
are just sufficient if you have a pre-historic machine. A better way is to use the
"more" command.
Note: Lot of newer operating systems have other commands which give you
similar functionality with additional features like SCO Unix has the "pg"
command and the tongue-in-cheek "less" command in Linux.
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 26
26
08/02/2010
Navigation
$ which ls
/bin/ls
whereis locate the binary, source, and manual page files for a command
$ whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 27
27
08/02/2010
Create/Modify/Delete
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 28
28
08/02/2010
Create/Modify/Delete
cp -- Copy files
ln -- link files
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 30
30
08/02/2010
Create/Modify/Delete
Example: rm filename
rm -r dirname
recursively remove all files and sub-directories in the
directory "dirname" and then remove the directory itself.
rm -i *
display all the files in the current directory, ask
confirmation and then remove the confirmed files one-by-one.
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 31
31
08/02/2010
Create/Modify/Delete
view -- Screen oriented text viewer. It is same as "vi" except that the
target file is opened in read-only mode.
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 33
33
08/02/2010
File Contents Manipulation
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 34
34
08/02/2010
File Contents Manipulation
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 35
35
08/02/2010
Create/Modify/Delete
od -a <filename>
od -c <filename>
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 36
36
08/02/2010
File Contents Manipulation
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 37
37
08/02/2010
File Contents Manipulation
ADV
cmp -- Compare two files byte-by-byte. cmp will write no output if the
files are the same. Under default options, if they differ, it writes to standard
output the byte and line numbers at which the first difference occurred.
Bytes and lines are numbered beginning with 1.
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 38
38
08/02/2010
File Contents Manipulation
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 39
39
08/02/2010
File Contents Manipulation
ADV
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 40
40
08/02/2010
File Contents Manipulation
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 41
41
08/02/2010
File Contents Manipulation
ADV
split -- Split a file into as many required pieces with each piece
containing n number of lines.
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 42
42
08/02/2010
File Contents Manipulation
sort -- Sorts and merges lines of all the named files together.
Syntax: sort file(s)...
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 43
43
08/02/2010
File Contents Manipulation
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 44
44
08/02/2010
File Contents Manipulation
Translate each digit in file1 to a X (number sign), and write the result to
file2.
tr "0-9" "[X*]" <file1 >file2
Translate all lower case characters in file1 to upper case and write the result
to standard output.
tr "[:lower:]" "[:upper:]" <file1
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 45
45
08/02/2010
File Contents Manipulation
compress -- Compress data for storage using adaptive Lempel-Ziv
alogorithm.
compress file
uncompress file.Z
zcat file.Z
Original
Original file
file replaced
replaced by
by aa file
file with .Z extension
with .Z extension
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 46
46
08/02/2010
File Contents Manipulation
pack -- Compresses files using Huffman (minimum redundancy)
codes on a byte-by-byte basis.
pack file
unpack file.z
pcat file.z
Original
Original file
file replaced
replaced by
by aa file
file with .z extension
with .z extension
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 47
47
08/02/2010
File Contents Manipulation
-b : British Spelling
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 48
48
08/02/2010
File Contents Manipulation
-b : British Spelling
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 49
49
08/02/2010
File Contents Manipulation
file file...
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 50
50
08/02/2010
Communication
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 51
51
08/02/2010
Communication
wall write
wall write to
to all
all users
users SU
SU command
command
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 52
52
08/02/2010
Communication
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 53
53
08/02/2010
Communication
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 54
54
08/02/2010
Communication
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 55
55
08/02/2010
Communication
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 56
56
08/02/2010
Communication
How
How do
do you
you login
login to
to aa remote
remote Unix/Linux
Unix/Linux server
server securely?
securely?
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 57
57
08/02/2010
Tools & Utilities
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 58
58
08/02/2010
Tools & Utilities
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 60
60
08/02/2010
Tools & Utilities
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 61
61
08/02/2010
Maintenance & Control
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 62
62
08/02/2010
Maintenance & Control
su -- Switch User
su
su -
su <username>
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 63
63
08/02/2010
Maintenance & Control
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 64
64
08/02/2010
Maintenance & Control
How
How will
will demonstrate
demonstrate the
the difference
difference between
between the
the above
above two
two
commands?
commands?
HINT:
HINT: Switch
Switch User
User
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 65
65
08/02/2010
Maintenance & Control
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 66
66
08/02/2010
Maintenance & Control
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 67
67
08/02/2010
Maintenance & Control
How
How do
do you
you choose
choose aa good
good password?
password?
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 68
68
08/02/2010
Maintenance & Control
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 69
69
08/02/2010
Maintenance & Control
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 70
70
08/02/2010
Maintenance & Control
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 71
71
08/02/2010
Maintenance & Control
uname -a
id <username>
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 72
72
08/02/2010
Maintenance & Control
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 73
73
08/02/2010
References
01:03:16PM
01:03:16
01:03:16 PM
PM
info@ackabs.net +91.9911064207 11/04/2014
Module
Module -- 74
74
That's all, folks!!
...till we meet again...
01:03:16 PM
+91.9911064207 Unix
Unix -- User
User -- 75
75
08/02/2010
Acknowledgements
01:03:16PM
01:03:16
01:03:16 PM
PM
info@ackabs.net +91.9911064207 11/04/2014
Module
Module -- 76
76
Copyright
01:03:16PM
01:03:16
01:03:16 PM
PM
info@ackabs.net +91.9911064207 11/04/2014
Module
Module -- 77
77
Versions
01:03:16PM
01:03:16
01:03:16 PM
PM
info@ackabs.net +91.9911064207 11/04/2014
Module
Module -- 78
78