You are on page 1of 16

1 ..................................................................................................................

3
Linux & UNIX. ........................................................................ 3
................................................................... 3
.................................................................... 3
2 .................................................................................................................. 5
UNIX....................................................................... 5
DIRECTORIES................................................................................... 5
........................................................................ 6
3 .................................................................................................................. 7
FILE MANIPULATION.............................................. 7
ls l . ................................................................................ 7
........................................................................ 8
. .............................................................................................. 8
.............................................................................................. 9
................................................................................................ 9
4 ........................................................................................................... 10
............................................... 10
. ........................................... 10
UNIX & LINUX - PERMISSIONS. ............................ 11
................................................................. 13
. .......................................................................................... 13
. ......................................................................................... 13
5 ............................................................................................................. 14
.............................................. 14
INPUT AND OUTPUT REDIRECTION ............................................................ 14
> >> ....................................................................... 14
2> 2>>............................................................. 15
.................................................................................................................. 15
................................................................... 15

Linux & UNIX.


man ON-LINE MANUAL
bc (built-in calculator)
date .
cal .
hostname Host .
uptime .
who .
whoami - login name .
who am i - login name
.
clear .
passwd .
echo .
banner .

.
mail elm .
write .
mesg .

1. ;
.
$echo
$echo hello
$echohello
$banner
$banner hello
$BANNER hello
2. who whoami .
;

;
;
;

3. ;
;
4. .
.
5.
;
;
6. date
mm-dd-yy.
man .
7. anual cp.
;
8. ;
9. ;
10. processor load;

2
UNIX.
UNIX : (files) ,
(directories) (special files).
,
. ,
, ,
(file system).
()
(
),
. ,
,
.

(physical device). ,
, , disk drive
(device files).
: ,
,
.

DIRECTORIES
. : (current directory).
.. : (parent directory).
~ : home directory .
pwd : (present working directory)
cd : (Change Directory).
mkdir : ( ).
rmdir : .
mv : .
du : blocks (disk utilisation).
ls : directories files (List contents of a Directory).
find : .


1. Home directory .
2. ./MakeTree
Home directory .
3. Home directory
tree ls .
.
4. (full path) mustang
;
(relative path) Home directory ;
5. directory junk. directory
directory .
directory.
6. Home directory
. .
junk/dirA/dir1
junk/dirA
junk/dirA/dir2
junk/dirA/dir1/dirc
7. Home directory directory dirA
junk (full path)
(relative path). ;
8. Home Directory , rmdir
junk .
rmdir ;
9. Home Directory . (ls l)
cp ( /bin/cp).
.
10. Home Directory . find
banner .
11. Home Directory . find
.
type .
12. junk junk.new.

3
FILE MANIPULATION
ls : .
file : .. ASCII ,directory, executable,data ..
cat : .
more :
.
less :
.
head : n () .
tail : n () .
lpr : .
cp : .
mv : .
ln : .
rm : .

ls l .
$ ls l
total 4
-rw-r--r--rw-r--r--rw-r--r-drwxr-xr-x

1
1
1
2

larry
larry
larry
larry

system
system
system
system

Permissions
File
Owner
type
Links
Group

101 Jun 5 10:03 file1


75 Jun 5 10:03 file2
65 Jun 5 10:06 file3
32 Jun 5 10:07 project

Timestamp
Size

Name

.
total 4
Number of 512-byte blocks taken up by files in this directory.
drwxr-xr-x File type and permissions set for each file or directory. The
first character in this field indicates file type:
(dash) for ordinary files
b for block-special files
c for character-special files
d for directories
l for symbolic links
p for pipe-special files (first in, first out)
s for local sockets
The remaining characters indicate what read (r), write (w),
and execute (x) permissions are set for the owner, group, and
others. In addition, other permission information may also be
displayed.a
1
Number of links to each file.b
larry
Username of the files owner.
system
Group to which the file belongs.
101
Number of bytes in the file.
Jun 5 10:03 Date and time the file was created or last modified in the
format defined by your current locale.
file1
Name of the file or directory.


.
1. Home Directory cat
funfile. ;
(scrolling control)
;
2. more
tree. ;
. more
/bin/ls. ;
cat. ;
3. tail head
.bash_history Home directory ( ls l
) . history. ;
4. Home directory . names
names.cp.
.
5. names ()
names.cp; names
funfile names. T names names.cp.
6. names .
names.
7.
names.new. names.orig.

names

8. ( names.2 names.3)
names.
9. names
names.2 names.3. funfile names
names. names.orig,
names.2 names.3.
10. names. names.2 names.3;
11. names.2 names.3. i
rm. ;
12. names.orig names.

.
1. ../CreateFruits.
.

2. fruit Home directory .



Home directory :
lime
grape
orange
3. Home directory
fruit. :
Source
Destination
apple
APPLE
peach
PeacH

.
1. .
2. . ID
.
3. .
4. ;
.
5.
. .

4


.
. :
* .
? .
[] .
.. ls l [afz]a.txt aa.txt,fa.txt,za.txt
.

.
1. Home directory . ls *
.
2. echo ???XX ???XX, ;
3. Home directory
:
a. .c
b. .c
mod.
c.
file.
d. .c,.f .p.
4. c_source. .c
.
5. touch (: touch ),
.
a. ? .
b. ?. .
c. * .
d. .?? .
e. .* .
echo .
6. rm
.
rm (interactive).

UNIX & LINUX - PERMISSIONS.


$ ls l
total 4
-rw-r--r--rw-r--r--rw-r--r-drwxr-xr-x

1
1
1
2

larry
larry
larry
larry

system
system
system
system

101 Jun 5 10:03 file1


75 Jun 5 10:03 file2
65 Jun 5 10:06 file3
32 Jun 5 10:07 project

Permissions
File
Owner
type
Links
Group

Timestamp
Size

Owner

Name

Group

Others

d r w x r - x r w x

Execute
Write
File type

Read

UNIX (owner),
. ( )
.
:
Owner : O .
Group : (.. ,
..) .
Others :
.
.
.
Read : O
.
read
.
Write : O .
write
.

.
Execute : O
.
execute
read
.

chmod (Change
Mode). .
:
r
w
x

read
write
execute

:
+

group :
u
g

a
none

user ( )
group( )
other( )
all( )

$chmod u+x,g=rx,o-rw f2
$chmod go-rw f2
H chmod .

. :
read = 4
write = 2
execute = 1
.
( ).
chmod .

:
rwxrxx
user
rwx
4+2+1
7

group
rx
4+0+1
5

others
x
0+0+1
1

chmod :
chmod 751 filename


.
1. Home directory mod5.1.T
;
;
2. mod5.1 w .
;
3. mod5.1 rw .
;
;
4. mod5.1
;
5. mod5.1 mod5.2.
write mod5.2. ;
;
6. mesg y. device file
. ( who am I .
/dev directory).
; mesg n. ;
mesg ;

.
1. Home directory mod5.dir.
mod5.1 mod5.dir.
. mod5.dir.
2. mod5.dir rw .
mod5.dir;
mod5.dir; mod5.1
mod5.dir;
3. mod5.dir w x .
; mod5.1
mod5.dir; mod5.dir.
4. Home directory ;
Home directory ;
5. /usr/bin/date Home directory ;

5

INPUT AND OUTPUT REDIRECTION

. ,
date,ls,who ... ,
mail,write,cat ...
Unix .

.
.

.


mail.
shell ( ) :
stdin Standard input
stdout Standard output
stderr Standard error

> >>
stdout
.

Create/Overwrite
$ date > date.out
$ date > who.log
$ cat > cat.out

Ctrl + d
Create/Appned
$ ls >> ls.out
$ who >> who.log
$ ls >> who.log

2> 2>>
stderr
.

$ cp 2> cp.err
$cp 2>> cp.err
$
$ more cp.err
.
.
.
;

stdin
stdout .
cat stdin stdout.
grep string .
sort
wc (word count). , .


1. date date.out Home
Directory .
2. date.out ls .
date.out. ;
3. mail write
date.out .
4. f1 f2 cat
.
5. cat f1
f2. cat f.join
f1 f2. ;
6. cat f1 f2
f.new( f.new ). ;
stdout stderr;
7. cat f1 f2
f.new( f.new ). f.error.
; ; .

8. cat f1 f2
f.new( f.new ). ,
f.good
f.error. ; ; .
9. cat . ?
cp.error. ; cp
stdout;
10. /etc/passwd user name.
11. /etc/passwd . ;
. ;
12. /etc/passwd string epp.
grepped.
string epp.
13.
;
14. ;
/etc/passwd .

You might also like