?? 01. unix note.txt
字號:
dw 刪除詞,剪切詞。 ( 3dw刪除 3 單詞)
cw 替換一個單詞。 (cw 和 dw 的區別 cw 刪除某一個單詞后直接進入編輯模式,而dw刪除詞后仍處于命令模式)
cc 替換一行
C 替換從光標到行尾
yy 復制行 (用法同下的 Y ,見下行)
Y 將光標移動到要復制行位置,按yy。當你想粘貼的時候,請將光標移動到你想復制的位置的前一個位置,然后按 p
yw 復制詞
p 當前行下粘貼
1,2co3 復制行1,2在行3之后
4,5m6 移動行4,5在行6之后
u 當你的前一個命令操作是一個誤操作的時候,那么可以按一下 u鍵,即可復原。只能撤銷一次
r file2 在光標所在處插入另一個文件
~ 將字母變成大寫
J 可以將當前行與下一行連接起來
/字符串 從上往下找匹配的字符串
?字符串 從下往上找匹配的字符串
n 繼續查找
1,$s/舊串/新串/g 替換全文(或者 %s/舊串/新串/g)
(1表示從第一行開始) 沒有g則只替換一次,加g替換所有
3、存盤和退出
w 存盤
w newfile 存成新文件
wq 存盤再退出VI(或者ZZ或 X)
q! 強行退出不存盤
查看用戶
users 顯示在線用戶(僅顯示用戶名)。
who 顯示在線用戶,但比users更詳細,包括用戶名、終端號、登錄時間、IP地址。
who am i 僅顯示自己,(但包括用戶名、端口、登錄時間、IP地址;信息量=who)。
whoami 也僅顯示自己,但只有用戶名(僅顯示自己的有效的用戶名)。
w 顯示比who更多內容,還包括閑置時間、占CPU、平均占用CPU、執行命令。
用法 w [ -hlsuw ] [ 用戶 ]
su 改變用戶,需再輸入密碼。
用法 su [-] [ username [ arg ... ] ]
su - 相當于退出再重新登錄。
查找
find 查找文件
用法 find [-H | -L] 路徑列表 謂詞列表
find / -name perl 從根目錄開始查找名為perl的文件。
find . -mtime 10 -print 從當前目錄查找距離現在10天時修改的文件,顯示在屏幕上。
(注 “10”表示第10天的時候;如果是“+10”表示10天以外的范圍;“-10”表示10天以內的范圍。)
grep 文件中查找字符;有過濾功能,只列出想要的內容
用法 grep -hblcnsviw 模式 文件 . . .
如 grep abc /etc/passwd 在passwd文件下找abc字符
wc 統計
-l 統計行數; -w統計單詞數; -c 統計字符數
如 grep wang /etc/passwd|wc -l 統計passwd文件含“wang”的行數
du 查看目錄情況
如 du -sk * 不加-s會顯示子目錄,-k按千字節排序
用法 du [-a] [-d] [-h|-k] [-r] [-o|-s] [-H|-L] [文件...]
進程管理
ps 顯示進程。
用法 ps [ -aAdeflcjLPyZ ] [ -o 格式 ] [ -t 項列表 ]
[ -u 用戶列表 ] [ -U 用戶列表 ] [ -G 組列表 ]
[ -p 進程列表 ] [ -g 程序組列表 ] [ -s 標識符列表 ] [ -z 區域列表 ]
ps 顯示自己的進程。
ps -e 顯示每個進程,包括空閑進程。
ps -f 顯示詳情。
ps -ef 組合-e和-f,所有進程的詳情。
ps -U uidlist(用戶列表) 具體查看某人的進程。
kill
pkill
sleep
jobs
用法 jobs [-l ]
fg %n
bg %n
stop %n 掛起(僅csh能用)
Ctrl+C
Ctrl+Z
網絡鏈接
ping
usage ping host [timeout]
usage ping -s [-l | U] [adLnRrv] [-A addr_family] [-c traffic_class] [-g gateway [-g gateway ...]] [-F flow_label] [-I interval] [-i interface] [-P tos] [-p port] [-t ttl] host [data_size] [npackets]
ifconfig -a
/sbin/ifconfig 查看本機的IP地址
netstat -rn
rlogin
ftp
幫助文件 [sd0807@localhost ~]$ help
GNU bash, version 3.1.17(1)-release (i686-redhat-linux-gnu)
These shell commands are defined internally. Type `help' to see this list.
Type `help name' to find out more about the function `name'.
Use `info bash' to find out more about the shell in general.
Use `man -k' or `info' to find out more about commands not in this list.
A star (*) next to a name means that the command is disabled.
JOB_SPEC [&] (( expression ))
. filename [arguments]
[ arg... ] [[ expression ]]
alias [-p] [name[=value] ... ] bg [job_spec ...]
bind [-lpvsPVS] [-m keymap] [-f fi break [n]
builtin [shell-builtin [arg ...]] caller [EXPR]
case WORD in [PATTERN [| PATTERN]. cd [-L|-P] [dir]
command [-pVv] command [arg ...] compgen [-abcdefgjksuv] [-o option
complete [-abcdefgjksuv] [-pr] [-o continue [n]
declare [-afFirtx] [-p] [name[=val dirs [-clpv] [+N] [-N]
disown [-h] [-ar] [jobspec ...] echo [-neE] [arg ...]
enable [-pnds] [-a] [-f filename] eval [arg ...]
exec [-cl] [-a name] file [redirec exit [n]
export [-nf] [name[=value] ...] or false
fc [-e ename] [-nlr] [first] [last fg [job_spec]
for NAME [in WORDS ... ;] do COMMA for (( exp1; exp2; exp3 )); do COM
function NAME { COMMANDS ; } or NA getopts optstring name [arg]
hash [-lr] [-p pathname] [-dt] [na help [-s] [pattern ...]
history [-c] [-d offset] [n] or hi if COMMANDS; then COMMANDS; [ elif
jobs [-lnprs] [jobspec ...] or job kill [-s sigspec | -n signum | -si
let arg [arg ...] local name[=value] ...
logout popd [+N | -N] [-n]
printf [-v var] format [arguments] pushd [dir | +N | -N] [-n]
pwd [-LP] read [-ers] [-u fd] [-t timeout] [
readonly [-af] [name[=value] ...] return [n]
select NAME [in WORDS ... ;] do CO set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
shift [n] shopt [-pqsu] [-o long-option] opt
source filename [arguments] suspend [-f]
test [expr] time [-p] PIPELINE
times trap [-lp] [arg signal_spec ...]
true type [-afptP] name [name ...]
typeset [-afFirtx] [-p] name[=valu ulimit [-SHacdfilmnpqstuvx] [limit
umask [-p] [-S] [mode] unalias [-a] name [name ...]
unset [-f] [-v] [name ...] until COMMANDS; do COMMANDS; done
variables - Some variable names an wait [n]
while COMMANDS; do COMMANDS; done { COMMANDS ; }
輸入 man help
BASH_BUILTINS(1) BASH_BUILTINS(1)
NAME
bash, :, ., [, alias, bg, bind, break, builtin, cd, command, compgen, complete, continue,
declare, dirs, disown, echo, enable, eval, exec, exit, export, fc, fg, getopts, hash, help,
history, jobs, kill, let, local, logout, popd, printf, pushd, pwd, read, readonly, return,
set, shift, shopt, source, suspend, test, times, trap, type, typeset, ulimit, umask, una-
lias, unset, wait - bash built-in commands, see bash(1)
BASH BUILTIN COMMANDS
Unless otherwise noted, each builtin command documented in this section as accepting options
preceded by - accepts -- to signify the end of the options. For example, the :, true,
false, and test builtins do not accept options.
: [arguments]
No effect; the command does nothing beyond expanding arguments and performing any
specified redirections. A zero exit code is returned.
. filename [arguments]
source filename [arguments]
Read and execute commands from filename in the current shell environment and return
the exit status of the last command executed from filename. If filename does not
contain a slash, file names in PATH are used to find the directory containing file-
name. The file searched for in PATH need not be executable. When bash is not in
posix mode, the current directory is searched if no file is found in PATH. If the
sourcepath option to the shopt builtin command is turned off, the PATH is not
searched. If any arguments are supplied, they become the positional parameters when
filename is executed. Otherwise the positional parameters are unchanged. The return
status is the status of the last command exited within the script (0 if no commands
are executed), and false if filename is not found or cannot be read.
alias [-p] [name[=value] ...]
Alias with no arguments or with the -p option prints the list of aliases in the form
alias name=value on standard output. When arguments are supplied, an alias is
defined for each name whose value is given. A trailing space in value causes the
next word to be checked for alias substitution when the alias is expanded. For each
name in the argument list for which no value is supplied, the name and value of the
alias is printed. Alias returns true unless a name is given for which no alias has
been defined.
bg [jobspec ...]
Resume each suspended job jobspec in the background, as if it had been started with
&. If jobspec is not present, the shell’s notion of the current job is used. bg
jobspec returns 0 unless run when job control is disabled or, when run with job con-
trol enabled, any specified jobspec was not found or was started without job control.
bind [-m keymap] [-lpsvPSV]
bind [-m keymap] [-q function] [-u function] [-r keyseq]
bind [-m keymap] -f filename
bind [-m keymap] -x keyseq:shell-command
bind [-m keymap] keyseq:function-name
bind readline-command
Display current readline key and function bindings, bind a key sequence to a readline
function or macro, or set a readline variable. Each non-option argument is a command
as it would appear in .inputrc, but each binding or command must be passed as a sepa-
rate argument; e.g., ’"\C-x\C-r": re-read-init-file’. Options, if supplied, have the
following meanings:
-m keymap
Use keymap as the keymap to be affected by the subsequent bindings. Accept-
able keymap names are emacs, emacs-standard, emacs-meta, emacs-ctlx, vi,
vi-move, vi-command, and vi-insert. vi is equivalent to vi-command; emacs is
equivalent to emacs-standard.
-l List the names of all readline functions.
-p Display readline function names and bindings in such a way that they can be
re-read.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -