You are on page 1of 225

______________

UNIX

UNIX
UNIX
UNIX

UNIX
UNIX60Bell

(AT&T)70
UNIX
70
UNIX

UNIX

UNIX

GNU
GNUGNUs not UNIX
1984Project GNU Richard Stallman

GNUmicro kernel
GNU

GPLGNU

FSFFree Software Foundation


Free Software gratis
copyleft
open source

Linux
Linus Torvalds
Unix
GNU GPL

Linux
UNIXAPIUNIX

Red Hat Linux


CPU
128 MB
600MB()1.2GB

CDROM3.5

Linux
XFree86:Linux X Window
XFree86 3.3.X
XFree86 4.2.X
GNOMEThe GNU Network Object Model
EnvironmentGTK
KDE QT

______________

Linux

(Kernel)
Shell
(Terminal Emulator)
X Window
(Window Manager)
(Desktop Environment)


Red Hat Linux release 9.0 (Shrike)
Kernel 2.4.20-8 on an i686

loginroot
password______

home
[root@stationXX root]#
@

home


useradd
password
example

[root@stationXX root]# useradd student


[root@stationXX root]# passwd student
Changing password for user student
New password:

Retype new password:

passwd: all authentication tokens updated successfully


[root@stationXX root]#



ls -l /etc/X11


--help
mknod --help

man
man mknod

info
info mknod


man
man -k keyword
man -f keyword
man -a keyword
man n keyword

ls
cp
mv
rm
touch

cd
pwd
mkdir
rmdir

cat
more
less
date
cal


df
du


head

tail

Linux
block
character


126

Alt+Fn(n=1~12)
su
su - username



reboot
shutdown -r now
init 6

halt
shutdown -h now
poweroff
init 0

______________


ls l

file
linux
file


linux

-
d
b
c
l
p


Linux

u
g
o

r
w


chmod
chmod [-R]

root


chmod



4
2
1


ln

ln


ln s

ext2/3
ext2ext3
inod+block
rminode

statblockinode

rootchown



rootchgrp


255
.

______________


d
/
Linux
/
shell

...
...
.
..


ext2
setuid setgid)(sticky)

ugoset uidset gidsticky


set uidset gidugxs


stickyt

set gid

setgid


wx


set uid
set gid


chmod

set uidchmod u+s


set gidchmod g+s
stickychmod o+t

4(set uid)
2(set gid)
1(sticky)

umask

umask
umask

umak002
umask022

/bin
/boot
/dev
/etc
/home
/lib
/lost+foundfsck

/mnt
/opt
/proc
/rootroot
/sbin
/tmp
/usr
/var

______________


Linux




stdin0


stdout (1)

I/O
stderr(2)


<

<


<<


>

ls l > listfile

listfile


>

ls l > listfile

>>
ls l >> listfile


I/O

2>
find / -type s 2> /dev/null

2>>
find / -name passwd 2>> results


>2>

find / -perm -2 2> error > results

&>
find / -perm +6000 > file

ls l | grep pass


ls l | more

cat < filea > fileb


fileafileb

cat file.* > file


______________


which

alias -> $PATH

whereis

slocate

slocate
[]
locate []

slocate

find

find [] [] []



find [] [] [] -exec {} \
{}find
\


wc
grep
sort

diff
comp
uniq
cut
paste


gzipgunzip
Linux
75%

compressuncompress
Unix

bzip2bunzip2
Linux
gzip

Z
gzipz

zcat
zless
zdiff
zcmp

tar
ZIP


c
v
x


tar cvf backup.tar *.txt
tar xvf backup.tar C backup/

dump/restore
ext2/3



dump 0u f /var/tmp/hda2dump /dev/hda1
restore rf /var/tmp/hda2dump

______________


mesg --

write
wall




VIM
EMACS

Vi
vi
Unix
ViLinux
Red Hat Linux
/ visual editor vimvi improved


vi

vi



:w
:q
:wq /:x /ZZ
:q!
:e

vi
vi




<ESC>

v
1.
2. c y
3. p

u
U
<ctrl-r>
:e!


vi
/ ?

: r <>
:r !<>
<>
:nr <>
<>n
:!<>
<>,
:sh
SHELL
:so <>
<>,

BASH
______________

Shell
Shell

UnixShellLinuxbash
shell
shell/etc/shells

bash

bashBourne Again Shell


GNU
UnixBourne Shell


bash
shell

setenv

HOME
PATH
LANG
PS1

history
bashhistory


HISTSIZE
historylogout
.bash_history
login
.bash_history
HISTFILESIZE


!
!!
!aa
!numberhistory
number
!-numbernumber

<ctrl+r>history

alias
shellaliasalias
alias

unalias
aliasshell

` `


$[ ]

pwd ; ls l

shell()
shell
shell


shell
&& ||
&&

||

shell
shellumask
aliaslogout
login
shell
shell
shellshellshell

shell

shell
bash


/etc/profile
/etc/bashrc

~/.bashrc
~/.bash_profile

shell
~/.bash_logoutlogout

~/.bash_historylogin
historylogout
history
/etc/profile.d/*.sh/etc/profile


Ctrl + dshell
exit
Ctrl + c
Ctrl +s & Ctrl + q/
Ctrl + lclear
Tab
Tab

X window
______________

X window

Linux
1986
/
XFree86 X

GNOME



GNOME office

GTK+

KDE

KDEK Desktop Environment

Koffice
QT

Sawfish
GNOME

http://sawfish.themes.org


sawfish-ui
GNOME

X
GNOMEKDEX11

WindowMaker
NeXTSTEP GUI

fvwm
Linux

twm
X


switchdesk
GNOMEKDE

~/.Xclients~/.Xclients_defaults

GNOME
KDE

(exec gnome-session)
(exec startkde)

redhat-config-mouse
mouseconfig

XFree86
runlevel5
X
gdmkdmxdm
X
startxX

GUI
xterm
XFree86

gnome-terminal
GNOME

konsole
KDE

nautilus
GNOME
start here
nautilus
httpftp
texthtmlmaninfomp3


gvim
GUIvim

kwrite
KDE

xemacs
xemacs

gedit
GNOME


gimp
GNU

display

convert

gqview

ee


xmms
Linuxwinamp

gmix
GNOME

gtcd
GNOMECD


gftp
FTP

xchat
IRC

evolution

mozilla

Office
Open Office
staroffice
oowriter ooimpressoodrawoomath
oocalc

koffice
KDEoffice
kwordkspreadkpresenterkontour
kchart

X
CtrlAltBackspace

Ctrl+Alt+Fn
n

Alt+Tab

X
redhat-config-xfree86
Red Hat X
root



______________

unam e
hostname
last
lastlog
free
top

init
initPID1

init



ps [option]

pstree

top


kill
kill [-signal] PID

15
kill -lkill

killall


nice
nicenice
nice -n num command

renicenice
renice -n pid



shell


command &

nohup command &

ctrl + Z


jobs
fg
bg

/proc
/proc

cat /proc/

/proc/sys


/var/log


/var/log/dmesg

/var/log/messages

/var/log/maillog


/var/log/xferlog
FTP

/var/log/secure

/var/log/wtmp

Shell Scripts
______________

Shell
Shell Scriptsshell

Shell

Shell

Shell

shell
shell
script
#
shell


shellshell

shell
export
export

unset


read
read username
username

echo
echo hello world

printf

shell

1.
2.
3.

shell
sh //
//
. //

if

if

then
elif
then
else

fi

case

case

esac

in
1

select

select
do

done

in

for

for
do

done

in

while

while
do

done

until

until
do

done

Shell
Shell
#command [option1] [option2] ..
Shell
$0

$1
(option1)
$2
(option2)

______________

who
groups
id
finger

useradd <username>
passwd <password>

1.
2.
3.
4.
5.

/etc/passwd/etc/group

/etc/skel

/

redhat-config-userskusers

usermod

userdel

-r

/etc/passwd
passwd
:


passwd

passwd

login name
passwd
uid
gid
full name
home directory
shellshell

Home directory
login.defscreate home

/etc/skel

chown R user.group

/etc/shadow
Red Hat Linux
/etc/shadow
passwd644shadow
400
shadow
shadow
:
authconfigshadow
md5

shadow
shadow

md5
197011
0
99999

197011


/etc/group
/etc/group

groupadd
groupdel
groupmod

newgrp


/etc/group :

group_name
password
GID
user_list

______________


LinuxUnix


b
c

/dev

/dev/hd[a-t]IDE
/dev/sd[a-z]SCSI
/dev/fd[0-7]
/dev/md[0-31]raid
loop[0-15]
ram[0-19]

/dev/null
/dev/zero
/dev/tty[0-31]
/dev/ttyS[0-9]
/dev/lp[0-3]
/dev/console
/dev/fb[0-31]framebuffer


/dev/cdrom
/dev/modem
/dev/pilot

/dev/hd[a-t]sd[a-z]
/dev/ttyS[0-9]
/dev/ttyS[0-9]

echo hello > /dev/tty2


ttyhello

cp /dev/fd0 /dev/fd1

dd if=/dev/hda of=/root/mbr bs=512 count=1


mbr/rootmbr

dd

ddcopy

if=
of=
bs=xxx
count=n

mknod
mknod

mknod


/usr/src/linux2.4/Documentation/devices.txt

kudzu
kudzuRed Hat Linux

/etc/sysconfig/hwconf
/etc/modules.conf

kudzu/usr/share/hwdata

hwbrowser



/Master Boot Record/MBR
/Standard Partition Table/SPT
/Primary Partition
/Extended Partition
/Logical Partition

Red Hat LinuxIDE63


SCSI15
fdisk16



disk druid

fdisk

______________

Linux

Linuxmount

Linux
Linuxext2/ext3

ext2/ext3
ext2/ext3rwx
attributes
ext2/ext3block+inode

ext2/ext3
superblock
blockinode
inode


ext2/3

lsattr
chattr
+-

ext3
ext3ext2
ext2
ext2
ext3
ext3


fsck

minix
msdos/fatmicrosoft
vfatwin95win98
ntfswin2000
iso9660
ReiserFS/JFS


mkfs
-t

mke2fs
ext2/3block

mount

mount -t []

mount
-t

-o
ext2rwsuid
devexecautonouserasync

/etc/fstab

mount
/etc/fstab
/etc/fstab

fsckdumpquotaonswapon


mount

/etc/mtab



Red Hat Linuxext2

ext2/ext3
e2labelext2

umount

umount [] /


fsck/filesystem check

e2fsckext2

tune2fsext2
resize2fsext2
parted


autofs
automount
autofs/etc/init.d/autofs


autofs


Linux

blockinode

grace
time

quota
1. /etc/fstab
mount
usrquotagrpquota
2. mount o remount
mount/etc/mtab

quota
3. quotacheck auvg
aquota.useraquota.group

4. edquota edquota g

5. quotaon auvgquota

______________

Linux
Linux

at
cron
anacron

at
at
atatd

at
atq
atrm
batch

at
at
/etc/at.allow
/etc/at.deny

cron

crond
cron
service crond start|stop
cron
chkconfigntsysvcron



crontab e
crontab l
crontab r
crontab u user

/var/spool/cron

crontab
* * * * * echo hello | wall
////
#hello



/etc/crontabcrond
crontab

/etc/cron.hourly
/etc/cron.daily
/etc/cron.weekly
/etc/cron.monthly

/etc/cron.d/

cron

root
/ cron
/etc/cron.allow
/etc/cron.deny

anacron

cron
24

/etc/anacrontab

7 80 cron.weekly run-parts /etc/cron.weekly

tmpwatch

/tmp
tmpwatch/etc/cron.daily

/usr/bin/tmpwatch

RPM

______________

RPM
RPMRedHat Package Manager

RPM

rpm -i
rpm -U
rpm -F
rpm -e


-v-h
--nodeps--force
--root

RPM
RPM
rpm -qRPM
rpm -qiRPM
rpm -qlRPM
rpm -qfRPM
rpm -qa
rpm -qpRPM

RPM
RPM
rpm -VRPM
rpm -VaRPM

RPM
rpm -KRPMGPG

______________

Linux


lpr -
:ASCII,PostScript
lpq -
lprm -
System V
lp,lpstat cancel )


PostScript
LPRng

lpr

enscript - PostScript
a2ps - PostScript
gv - PostScript
ps2pdf - PostScriptPDF
pdf2ps - PDFPostScript
mpage -


Linux

pine,mutt

mozilla
Mail,evolution,kmail,balsa

mail

pine - ,
mutt -
evolution - ,,
mozilla mail - ,,

kmail - ,,KDE

POPIMAP
POP - Post Office Protocol

IMAP - Internet Message Access Protocol


mozilla mail
pinemuttprocmail

fetchmail


POP
IMAP
SMTP

sed,awk,
______________

sed
Stream EDitor ()

sed
sed
-
-
-

sed

sed
!

sed
aboutsed.txt"slow"
"fast"
$ sed s/slow/fast/g aboutsed.txt >
output.txt

awk

awk

{ }
pattern {action}

awk
:
$awk 'program' input file

$awk -f program_file input_file

awk
awk/etc/passwd"bash"

$ awk '/bash/ { print }' /etc/passwd

awk
/projectjoshua
.
#ls -l /project | awk '$3 == "joshua" { \
sum += $5 } END { print sum }'

awk



sedawkinfo
$info sed
$info awk

Red Hat Linux:


Perl
Java
CC++
Tcl/TkExpect
GTK+
Qt
php

You might also like