共12个Unit
===============================================================================
RH033-01
RH4 ES 的安装过程
1,建立了/boot,/和/swap三个分区
2,语言选择都是en
3,软件包默认
===============================================================================
RH033-02
RH033共有3个Section
Objecttives of RH033
FIle and directory operations
Understanding users and groups
Standard I/O and pipes
String processing
Managing processes
bash shell operations
The graphical environments in Red Hat Enterprise Linux
Print and Mial
Basic networking tools
The vi editor
System tools
===============================================================================
Unit 1 - Overview
1,UNIX history
2,UNIX princliples
3,GNU Project/FSF
4,GPL- GNU General Pbulic License
5,Linux Origins
6,Why Linux
7,Red Hat Enterprise Linux
8,Recommended Hardware Specifications
9,Local Logins
10,Virtual Consoles
11,The Xorg GUI Framework
12,Xorg Graphical Environments
13,Starting Xorg
14,Changing Your Password
1,UNIX history
AT&T注册了UNIX商标
2,UNIX princliples
Everything is a file (including hardware)
Configuration data stored in text
Small,single-purpose programs
Avoid captive user interfaces
Ability to chain programs together to perform comples tasks 串联多个小程序执行复杂任务
3,GNU Project/FSF
Goal:Create "free" UNIX clone
started in 1984
4中自由:使用,学习,散布,改善
4,GPL- GNU General Pbulic License
Often called "copyleft"
5,Linux Origins
linus Torvalds in 1991
6,Why Linux
a UNIX-like OS
Multi-user and multi-tasking
Wide hardware support
Fully supported
7,Red Hat Enterprise Linux
A distribution of Linux
Custom version of a recent Linux kernel
Utilities and applicatios
8,Recommended Hardware Specifications
P2 with 256MB RAM
9,Local Logins
Text-mode 区分管理员和普通用户的提示符不同
Graphical login
10,Virtual Consoles
Multiple non-GUI logins
CTRL+ALT+F1--F6
tty指令可以判断目前在哪个虚拟控制台
X在CTRL+ALT+F7里面
11,The Xorg GUI Framework
clinet/server architecture
RHEL4:ssh protocol
12,Xorg Graphical Environments
GNOME = The default desktop
KDE
13Starting Xorg
startx
14,Changing Your Password
Password change
passwd指令可以修改自己密码
建议用ACSII code做密码
只有root可能修改他人密码
===============================================================================
Unit 2 - Running Commands and Getting Help
1,Running Commands
2,Some Simple Commands
3,Getting Help
4,The whatis Command
5,The --help Option
6,Reading Usage Summaries
7,The man Command
8,Navigating man Pages
9,The info Command
10,Navigating info Pages
11,Extended Documentation
12,Red Hat Documentation
1,Running Commands
一条指令的3个组成部分,每个部分之间用空格隔开
command [options] [arguments]
指令 选项 参数
[options]修改指令功能
如果是整个单词,前面接--,单个字母用- 多个单个字母可以连写如: -a -l写成--al
[arguments]文件名或其它信息
举例:passwd -S user1 查看user1的密码信息
useradd user
passwd --status user2 相同 -S
2,Some Simple Commands
date -s 22:02
date +%T
date +%T%D
cal 6 2008
3,Getting Help
Don't try to memorize everything
whatis
--help
man and info
/usr/share/doc
Red Hat documentiation
4,The whatis Command
Display short description
5,The --help Option
Displays usage summary and argument list
used by most but not all,command
6,Reading Usage Summaries
Arguments in "[]" are optional
Arguments in "<>" are variables
x|y|z means "x or y or z" 其中一个
-abc menas -a -b -c 任意组合
7,The man Command
man []
比较重要的是1,5,8 章节
man 5 passwd
man lvm
8,Navigating man Pages
arrows,pgUp,pgDown
/ search for text
n/N netx/previous keywords
man -k list all matching pages
man -k passwd
9,The info Command
比man更详细
info page are structured like a web site
tab可以进入其它主题
info
10,Navigating info Pages
arrows,pgUp,pgDown
Tab/Enter
n/p/u next/previous/up-one(上一层) node
s[] search for text
11,Extended Documentation
/usr/share/doc
12,Red Hat Documentation
===============================================================================
Unit 3 Beowsing the Filesystem
1,Linux File Hierarchy Concepts
2,Some Important DIrectories
3,Other Important DIrectories
4,Current Working DIrectory
5,File and Directory Names
6,Absolute Pathnames
7,Relative Pathnames
8,Changing Directories
9,Listing Directory Contents
10,Copy files and Directories
11,Copy files and Directories:The Destination
12,Moving and Renaming files and Directories
13,Moving and Renaming files and Directories:The Destination
14,Creating and Removing Files
15,Creating and Removing Directories
16,Using Nautilus
17,Moving and Copying in Nuatilus
18,Determineing File Content
19,Viewing an entire Text FIle
20,Viewing Text Page by Page
1,Linux File Hierarchy Concepts
单根目录,大小写敏感,以.开头的文件/目录是隐藏的
2,Some Important DIrectories
/home/username
/bin /sbin
/media /mnt
3,Other Important DIrectories
/etc /tmp /boot /dev /usr
4,Current Working DIrectory
pwd
5,File and Directory Names
Names may be up to 255 characters
All characters are valid,except the "/"
名字中有空格,用双引号扩起,大小写区分
6,Absolute Pathnames
begin with a slash (/)
7,Relative Pathnames
spectifies location relative to your current working directory
8,Changing Directories
cd cd.. cd~
9,Listing Directory Contents
ls [options] [files or directories]
10,Copy files and Directories
More than one file may be copied at a time if the destination is a directory
cp file1 file2 dest
cp -p 不修改文件属性(时间)
cp -r 复制目录用
11,Copy files and Directories:The Destination
if the destination exists and is a direcory, the copy is placed there with the same name
if the destination exists and is a file,the copy overwrites the destination file
if the destination does not exist,the copy is created with that name
12,Moving and Renaming files and Directories
More than one file may be moved at a time if the destination is a directory
13,Moving and Renaming files and Directories:The Destination
if the destination exists and is a direcory, the source file or directory is moved there with the same name
if the destination exists and is a file,the source file is moved to that filename,overwriting the file
if the destination does not exist,the source file or directory is renamed with that name
14,Creating and Removing Files
rm -i interactive
rm -r recursive 目录
rm -f force
touch -create empty file or update file timestamps
15,Creating and Removing Directories
mkdir
rmdir empty directory
rm -r 包含内容
16,Using Nautilus
gnome graphical filesystem browser
can run in spatial(每个目录都开一个窗口) or browser(资源管理器样式) mode
$nautilus
17,Moving and Copying in Nuatilus
Drag and Drop
Left-button : move on same filesystem, copy on different filesystem
Ctrl-Left-button : alwayls copy
Alt-Left-button : Ask whether to copy,move or create symbolic link
18,Determineing File Content
file [options] filename
19,Viewing an entire Text FIle
cat [options] filename
多个文件会连载输出
cat -A 可以看到换行符
cat -b 带行号
20,Viewing Text Page by Page
less filename
arrows / pgUp /pgDown
/text search for text
n -next match
v 进入编辑模式
===============================================================================
Unit 4 - The bash SHell
1,bash introduction
2,bash heritage
3,Command Line Shortcuts: File Globbing
4,Command Line Shortcuts: The Tab Key
5,Command Line Shortcuts: history
6,Command Line Shortcuts: Tilde(~)
7,Command Line Shortcuts: Variable and Curly braces({})
8,Command Line Shortcuts: Command and Math
9,Command Line Shortcuts: Backslash(\)
10,Command Line Shortcuts: Quotes
11,History Tricks
12,Command Editing Tricks:Editing Modes
13,gonme - terminal
1,bash introduction
"Bourne Again Shell"
用户和kernel之间的桥梁
2,bash heritage
unix分为两派:Sys V (sh) BSD(csh->ksh->tchsh->zsh)
3,Command Line Shortcuts: File Globbing
* 0个或多个字符
? 1个字符
[]字符范围
[^]非字符范围
4,Command Line Shortcuts: The Tab Key
补齐未输入完全的指令 tou->touch
pw tab一次不会补齐,再tab一次,显示所有以tab开头的指令
文件名字也可以补齐
5,Command Line Shortcuts: history
!指令编号
^2^1 把上个指令中的2改成1 用在ping中比较合适
6,Command Line Shortcuts: Tilde(~)
回到home目录
7,Command Line Shortcuts: Variable and Curly braces({})
echo $HOME
touch {a,b} ->a,b
touch a{a,b} ->aa,ab
touch {a,b}.{1,2} -> a.1,a,2,b.1,b.2
8,Command Line Shortcuts: Command and Math
`` 反引号取指令结果
echo "Hostname: `hostname`" 或者
echo "Hostname:$(hostname)"
$[] 数学运算
echo $[$a + $c]建立加空格
9,Command Line Shortcuts: Backslash(\)
转义字符
echo Your cost is $5.00
将\放到指令最后,代表指令接到下一行(一行没有完成指令)
10,Command Line Shortcuts: Quotes
Single quotes(')
Double quotes(") except:$ \ ` !
echo ** 00000 **
11,History Tricks
up and down arrow
CTRL+R search for a history command
recall last argument from previous command
ESC放开加. /ALT不放加.
ping适用 先ping后telnet
12,Command Editing Tricks:Editing Modes
By default,bash uses emacs-style
set -o vi 变成vi模式 set +o vi 变回来
set -o 可见模式
13,gonme - terminal
Ctrl+Shift+t open a new tab
Ctrl-pgUP/pgDn Next/Prev tab
Alt -号码 change to N号 tab
Ctrl+Shift+c/v Copy/Paste
Ctrl+Shift+w open a tab
====================================================================================
Unit 5 Standard I/O and Pipes
1,Standard input and output
2,Redirecting output displayed on the terminal
3,Redirecting input and output
4,Overwriting or Appending
5,Redirecting Standard Output
6,Redirecting Standard Error
7,Redirecting Both Standard Output and Error
8,Redirecting input
9,cut
10,sort
11,Using Pipes to Connect Processes
12,Using Pipes For Mail
13,tee
1,Standard input and output
Standard input - keyboard 0
Standard output - terminal windows 1
Standard error - terminal windows 2
ls -l /dev/std*
2,Redirecting output displayed on the terminal
find /etc -name passwd
3,Redirecting input and output
>,>>,<
4,Overwriting or Appending
5,Redirecting Standard Output
find /etc -name passwd 1 > stdout
find /etc -name passwd > stdout 默认就是标准输出1
6,Redirecting Standard Error
find /etc -name passwd 2 > stdout
7,Redirecting Both Standard Output and Error
find /etc -name passwd 2 > error 1 > output 两个文件
find /etc -name passwd > alloutput 2>&1
find /etc -name passwd &> allput
8,Redirecting input
tr 'A-Z' 'a-z' < .bash_profile
9,cut
-f 位置
-d 分隔符
-c 字母数目 c4-8
10,sort
-r 反向
-f 忽略大小写
-u 取消重复项
-t 使用 x做为分隔符
-n 数值排列
-k POS1 按某一栏做排列
sort -t: -k3 /etc/passwd
sort -t: -k3 -n /etc/passwd
11,Using Pipes to Connect Processes
ls -l | less
12,Using Pipes For Mail
mail -s "1st mail" user2 cat /var/spool/mail/user2 可以看到内容
cat ~user2/mbox 阅读过的邮件
ls -l | mail -s "3rd mail" user2
cat list.txt | xargs rm -f 删除list.txt列表文件里面的每一行
ls -l | lpr = > prn
13,tee
资料分流
cut -f1 -d: /etc/passwd | sort | less
cut -f1 -d: /etc/passwd | tee cut.file | sort |tee sort.file | less
======================================================================================
unit 6 - Users,Groups,and Permissions
1,The Linux Security Model
2,Users
3,Groups
4,The root User
5,Linux File Security
6,Permissions Types
7,Examining Permissions
8,Interpreting Permissions
9,Examining Directories
10,Processing Linux Security
11,Changing Permissions - Symbolic Method
12,Changing Permissions - Numeric Method
13,Changing Permissions - Nautilus
1,The Linux Security Model
Users and groups are used to control access to files and resources
Every file on the system is owned
2,Users
uid
/etc/passwd 7 fields
/etc/shadow
/home/
/etc/passwd 将密码字段的x删除,登录无需密码.
3,Groups
gid
/etc/group user2:x:501:成员列表
/etc/gshadow group名字:group passwd
4,The root User
Root has complete control over the system
5,Linux File Security
owner,group,others
6,Permissions Types
r,w,x,-
7,Examining Permissions
ls -i
8,Interpreting Permissions
10个字符的意义
9,Examining Directories
ls -ld
10,Processing Linux Security
判断过程
是否root->uid是否相同(owner?)->gid是否相同(群组)->other
11,Changing Permissions - Symbolic Method
chmod [=R] mode filename
12,Changing Permissions - Numeric Method
4210
13,Changing Permissions - Nautilus
==========================================================================================
Unit 7 vi Editor Basics and Printing
1,Starting vi
2,Three Modes of vi
3,Cursor Movemnet
4,Entering insert Mode
5,Leaving insert Mode:
6,Change,Delete,and Yank(copy):command mode
7,Put(paste):command mode
8,Undoing Changes:command mode
9,Searching for text:command mode
10,command-mode tricks
11,svageing and quiting:ex mode
12,Printing in Linux
13,Printing Commands
14,Printing Utilities
1,Starting vi
vi filename
2,Three Modes of vi
command mode:cursor movement,change,delete,copy,paste,search
insert mode:(进入a,i退出ESC)type
extended mode(:) quit,save,search and replace
3,Cursor Movemnet
h->left,j->down,k->up,l->down
w->word ahead,b->word back
(->sentence back,)->sentence forward
{->paragraph above,}->paragraph below
4,Entering insert Mode
a(光标停在后一格),i(光标停在原地)
A(光标停在行尾),I(光标停在行首)
o(光标停在新增的下一空白行),O(光标停在新增的上一空白行)
5,Leaving insert Mode:
ESC可以多次按
6,Change,Delete,and Yank(copy):command mode
cut delete yank(copy)
line cc dd yy
letter cl dl yl
word cw dw yw
7,Put(paste):command mode
p,P changed,deleted or copied date
For line oriented data:
p puts the data below the current lne
P puts the data above the current lne
For character oriented date:
p puts the data after the cursor
Pputs the data before the cursor
8,Undoing Changes:command mode
u undo most recent change
Ctrl-r redo last "undone" change
U undo all changes
9,Searching for text:command mode
/text search downwards for "text"
?text search upwards for "text"
n continue search in the same direction
N continue search in the opposite direction
10,command-mode tricks
dtc delete from cursor to the letter c
rc replace a character with c
x delete a character
5dd delete 5 lines
5yy copied 5 lines
5x delete 5 characters
R replace character-for-character until
11,svageing and quiting:ex mode
w saving
q quitting
! forcing
root可以强写只读文件
12,Printing in Linux
CUPS
local printer
network printer
documnets->queue->input filter->printer
13,Printing Commands
BSD System V
lpr/lpq/lprm lp/lpstat/cancel
lpr filename
lpr -Php README hp是打印机名称
queue->/var/spool/cups
搬移打印工作从一个队列到另一个队列 lpmove
lpmove ok-9 hp 名字 队列
插队lp -i17 -q51
i代表job编号 q51设置优先权(默认都是50)
disable ok 让打印机停用再开启/usr/bin/enable ok (必须指明路径)(第二道门)
reject ok关闭第一道门 accept ok
14,Printing Utilities
enscript convert 文件 -p 新文件名
ggv postscript and pdf 查看
ps2pdf/pdf2ps ps2pdf readme.ps > rs.pdf
mpage print multipages per sheet
mpage -4 r.ps > m.ps 4页合成1页
==============================================================================================
Unit 8 - The Linux Filesystem In-Depth
1,Partitions and Filesystems
2,Inodes
3,Directories
4,cp and inodes
5,mv and indoes
6,rm and inodes
7,Symbolic ( or soft ) Links
8,Hard Links
9,The Seven Fundamental Filetypes
10,Checking Free Space
11,Removable Media
12,Mounting CDs and DVDs
13,Mounting USB Media
14,Mounting Floppy Disks
15,Formatting Floppy Disks
16,Why Archive FIles
17,Creating an Archive
18,inspecting Archive
19,Extracting an Archive
20,Why use Files Compression?
21,Compression Utilities
22,Using Commpression
23,Compressing Archives
24,tar to Unformatted Floppies
1,Partitions and Filesystems
Disk Drives are divided into partitions
Partitions are formatted with filesystems,allowing users to store data
one block : 4K
2,Inodes
An inode table contains a list of all files
An inode (index node) is an entry (metadata) in the table -->FAT
inode-no,file type,permission,link count,uid,gid,size,time stamp....pointer(所有bloks)
time(access time,modify time,change time)
inode-no.->inode table->pointer->block
3,Directories
A directory is a mapping between the human name for the file and the inode number
ls -i可以看到每个文件对应的inode号码
4,cp and inodes
Allocates a free inode number,placing a new entry in the inode table
Creates a directory entry,referencing the files human file name to the inode number
Copies date into the new file
5,mv and indoes
if the destination of the mv command is on the same filesystem as the source:
Creates a new directory entry with the new file name
Deletes the old directory entry with the old file name
Has no impact on the inode table or the location of data on the disk:: no data moved
6,rm and inodes
Decrements the link count,thus releasing the inode number to be reused
Place data block int the free list
Remove the direcory entry
7,Symbolic ( or soft ) Links
A symbolic link point to another file
ls -s filename linkname
8,Hard Links
cannot span drives or partitons
ln filename [linkname] 避免重要文件被删除,同一个目录下不能建立
9,The Seven Fundamental Filetypes
-/d/l/b/c/p/s
/dev/initct1
10,Checking Free Space
df ->reports disk sapce usage per filesystem -h 以G为单位显示
du ->per diectory -s (summary) -h 以G为单位显示
du -h /root | less
11,Removable Media
By default,non-root users may only mount certian deices (cd ,dvd,flppy,usb,etc)
12,Mounting CDs and DVDs
Automatically mounted in Gnome/KDE
reject
13,Mounting USB Media
Detected by the kernel as scsi devices
/dev/sdaX
Automatically mounted in Gnome/KDE
14,Mounting Floppy Disks
mount /media/floppy
15,Formatting Floppy Disks
A low level format (rarely) ->fdformat /dev/fd0
A filesystem
mkfs -t ext2 /dev/fd0
mke2fs /dev/fd0
16,Why Archive FIles
Easier to backup,store
tar archive file with the inode table
17,Creating an Archive
tar cvf archive_name files..
18,inspecting Archive
tar tf a.tar
tar tvf a.tar (ls -l)
19,Extracting an Archive
tar xvf a.tar
20,Why use Files Compression?
Results in smaller file size
21,Compression Utilities
gzip / gunzip
bzip2 /bunzip2
22,Using Commpression
gzip 文件名
gzip -v 文件名 显示压缩比
gzip -c 文件名 保留原来的
gunzip 文件名
不能压缩目录
23,Compressing Archives
tar z for gzip
tar j for bzip2
tar -cvfz a.tar.gz doc
24,tar to Unformatted Floppies
floppies can be used like tape drives
low level format required
file system not needed
floppy cannot be mounted
/dev/fd0 is the destination
tar cvfM /dev/fd0 ~ M代表分卷
tar xvfM /dev/fd0
==============================================================================================
Unit 9 - Configuring the bash shell
1,Configuring the bash shell
2,Variables
3,Configuring the shell:local variables
4,common local variables
5,the ps1 local variable
6,Aliases
7,Other Shell Configuration Methods
8,Configuring Commands:Environment variables
9,Common Environment variables
10,the TERM Environment variables
11,the PATH Environment variables
12,How the Shell expands the command line
13,shell startup scripts
14,login shell
15,startup script:order of execution
16,/etc/profile
17,/etc/profile.d
18,~/.bash_profile and ~/.bashrc
19,~/.hash_login
1,Configuring the bash shell
local variables
aliases and functions
set
2,Variables
two types:local and environment
local Variables are used only by the shell
environment Variables are passed onto other commands
set to display all ariables
env to display environment Variables
3,Configuring the shell:local variables
data in shell scripts and environment settings stored in variables
conventionally all up-case
4,common local variables
HISTFILESIZE -> history command
COLUMNS -> the width of the terminal
LINES -> the height of the terminal
5,the ps1 local variable
\d -> today's date
\h -> short hostanme
\t -> current time
\u -> user name
\W -> current working directory
\l -> which tty
6,Aliases
alias lf='ls -laF'
7,Other Shell Configuration Methods
set -o noclobber -> do not clobber files with > and & operators 保护不被覆盖
set -o vi
8,Configuring Commands:Environment variables
export variablename
unset variablename
仅root可以unset Environment variables
9,Common Environment variables
HOME/LANG/PWD
10,the TERM Environment variables
TERM environment variable defines the terminal type (xterm)
reset 重设屏幕
11,the PATH Environment variables
which 根据PATH找可执行文件
12,How the Shell expands the command line
split the line into shell words
function an alias expansion
curly brace string expansion
tilde expansion
parameter and variable expansion
split the line into shell words again
file glob expansion
file redirection
run the command
13,shell startup scripts
scripts of commands executed at login
建立自定义变量,建立环境变量,建立别名,自动执行的程序
14,login shell
A login shell,non-login shell
15,startup script:order of execution
login shells
/etc/profile 用". "来调用其它脚本
/etc/profile.d
~/.bash_profile
~/.bashrc
/etc/bashrc
non-login shells
~/.bashrc
/etc/bashrc
/etc/progfile.d
16,/etc/profile
建立许多变量
17,/etc/profile.d
应用程序需要的启动脚本,初始化一些变量
18,~/.bash_profile and ~/.bashrc
用户偏好设置
19,~/.hash_logout
备份文件,删除临时文件.
==============================================================================================
Unit 10 - Advanced Topics in Users,Groups and Permissions
1,User and Group ID Numbers
2,/etc/passwd,/etc/shadow, and /etc/group
3,System Users and Groups
4,Changing your identify
5,user information Commands
6,Default Permissions
7,Special Permissions
8,Special Permissions for Executables
9,Special Permissions for Directories
1,User and Group ID Numbers
Napping user names to user ID numbers
data stored on the hard disk is stored numberically
2,/etc/passwd,/etc/shadow, and /etc/group
用户数据库
密码是用户ID和密码MD5计算的
3,System Users and Groups
内建的用户和群组1-499
4,Changing your identify
su user1
su - user1 不仅变成user1,环境变量也变成user1的 $PATH
passwd --status user1
5,user information Commands
whoami
groups,id
users,who,w(IP)
last
6,Default Permissions
file 666
directories 777
umask non-privileged 002
umask root 022
不可以用666-033
umask 033 touch a.txt ls -l
7,Special Permissions
a fourth Permission
三种:suid,sgid,sticky
分别借执行位三个x来标识,如果原来有X,用s表示权限,如果原来没有X,用S表示
sticky 用t/t表示
chmod u+s file1
chmod o+t file2 如果file2的o里面没有x,自动变成大T
数字代表4 2 1
755 -> file1
chmod 2755 file1 >加上sgid
chmod 7755 file1 >全加上
nautilus内也可以设置
8,Special Permissions for Executables
suid:command run with permission of the owner of the command,not executor of the command
ls -l /bin/ping 带有suid
ping 192.168.0.1 -c4
chmod u-s /bin/ping 但是o里面有x,所以其它人可用
user1去ping
ping:icmp open socket:operation not permitted
sgid:command run with group affiliation of the group of the command
9,Special Permissions for Directories
sticky bit和gid可以放到目录上
sticky目录里面的文件只有owner和root可以删除
ls -ld tmp 发现有sticky
sgid目录里面只有所属群组可以建立文件
Often both the stcky bit and the sgid permission will be set on a project directory
==============================================================================================
Unit 11 - Advanced Uses of the vi Editors (female)
1,File Repositioning
2,Screen Repositioning
3,Filtering
4,ex mode: Search and Replace
5,Advanced Reading and Saving
6,Configuring vi
1,File Repositioning
G -> go to last line in file
1G -> go to first line in file
Ctrl -d -> go down half a screen
Ctrl -u -> go up half a screen
2,Screen Repositioning
H -> go to first line on screen
M -> go to middle line on screen
L -> go to low line on screen
z -> make current line first line on screen
z- -> make current line last line on screen
3,Filtering
The output of a command can be placed in the file
!!ls -l -> 插入文件列表
!!date
!}sort ->排序
!}fmt -w60 ->段落宽度
4,ex mode: Search and Replace
sed
no address -> current line only
1,10
1,$ or % -> all
.,.+ 10 -> from currnet line to 10
s/This/That -> 替换一个
s/This/That/g -> 这一行内所有
1,10s/This/That/g ->前10行所有
.,-3代表从当前行加上上三行
5,Advanced Reading and Saving
:r file1
:1,20w file2
:1,$w file3 另存为
:1,20w >> file4
:n 下一个文件
:rew 第一个文件
:n# 两个文件之间切换
6,Configuring vi
:set ignorecase 忽略大小写 n下一个
:set noic
:set number 行号
:set nonu
==============================================================================================
Unit 12 - Introduction to String Processing
1,head
2,tail
3,wc
4,uniq
5,Other String Processing Tools
6,Version Comparison with diff
7,Spell Checking with aspell
8,Formatting Tools
1,head
use -n 行数 (default 10 lines)
use --lines 10
use -12 filename
适合查看文件开头的介绍部分
2,tail
-n or --lines or -n
适合查看刚刚更新的文件/etc/passwd
-f 查看文件时不关闭文件,适合查看正在更新的日志
cat /var/log/messages
3,wc
-l for only line count
-w word
-c character
wc README
207 1924 13001
4,uniq 去掉相邻的重复行
sort file1 |uniq = sort -u
-c count numbers of 重复行
5,Other String Processing Tools
paste 水平合并多个文件(tab)分隔
paste fiel1 fiel2 > file3
cat file1 file2 >file3 垂直合并
tr替换
tr 'A-Z' 'a-z'
例子:unix和dos下文本文件的段落符$ \r
cat -A file4
a$
a$$
cat -A file4 | tr '$' '\r'>file5
a^M$
aa^M$
unix2dos file4
6,Version Comparison with diff
< indicates line in first file 在第一个文件中出现
> indicates line in second file
sdiff ABC abc 以对比形式出现结果
7,Spell Checking with aspell
aspell check file1
less /usr/share/dict/words
cat /usr/share/dict/words | wc l