linux终端、linuxOS、vi(vim)常用命令及简要说明

Github详细说明(持续更新中…)

general commands set(gcs) about linux

################## Linux OS ###################
cd
touch
mkdir
rm
pwd
ls
vim(vi、nano)
mv
cp
man(info、help)
cat(tac、less、more、head、tail)
shutdown(reboot、poweroff、init)
grep(awk、sed)
find(whereis which)
tar
chmod
chown(chgrp)
usermod
su -
useradd(groupadd) userdel(groupdel)
passwd
wget(curl)
apt-get(dpkg)
yum(rpm)
mount(umount)

################## Terminal ######################
# general command line windows
Ctrl+A: goto the top of line(TOL)
Ctrl+E: goto the end of line(EOL)
Alt+->:move cursor towards the right step by word
Alt+<-:move cursor towards the left step by word
Ctrl+U:delete chars from the cursor to TOL
Ctrl+K:delete chars from the cursot to EOL
Ctrl+C:terminate operation
Ctrl+D:run operation to background
Ctrl+L:clear the screen

################ Vi(Vim) ########################
vim [filename] +n:enter filename goto line number of n
insert mode(i,I,o,O,a,A,s,S)
redo:Ctrl+r
undo:u
r:replace a character
R(Shift+r):replace mode
v(Ctrl+v,Shift+v(V)):enter visual mode --> select text by direction key
d:cut selected text
y:copy selected text
ndh:cut n chars towards head
ndl:cut n chars towards later
nyh:copy n chars towards head
nyl:cut n chars towards later
ndd:cut n lines(dd-->cut a line)
nyy:copy n lines(yy-->copy a line)
p:paste text from clipboard
x:equivalent to del key (nx equivalent to ndl)
X:equivalent to backspace key (nX equivalent to ndh)
d0:cut text from cursor(exclusive) to head
D:cut text from cursor(inclusive) to tail
h j k l: equivalent to direction key
b -->jump cursor step by word towards head
w -->jump cursor step by word towards tail
$:top of line
^:end of line
M:middle of current page
nG(ngg):goto line number of n(gg-->the first line(1gg,1G),G-->the last line)
:n --> move the cursor into line number of n(equivalent tonG OR ngg)
/text(?text): search text use n(N) key to find text one by one
~ -->change character case of cursor
guw -->change word of cursor into lower-case
gUw -->change word of cursor into upper-case
guu -->change line of cursor into lower-case
gUU -->change line of cursor into upper-case

:s/text1/text2 -->only replace the first text1 into text2 of current line (:n --> move cursor to line number of n)
:s/text1/text2/g -->replace all text1 into text2 of current line
:m,ns/text1/text2 --> replace the first text1 of each line from m to n(if n is to $ represent the last line, like the following...)
:n,$s/text1/text2 -->only replace the first text1 into text2 from n to the last line of file
:n,$s/text1/text2/g -->replace all text1 into text2 from n to the last line of file
:%s/text1/text2 -->replace the first text1 into text2 of all lines
:%s/text1/text2/g -->replace all text1(each line) into text2 of all lines
As several commands above, if add /c(confirm) which can replace text1 into text2 by interaction mode, e.g. :%s/text1/text2/gc –>you can replace all the text1(the whole file) into text2 by iteraction mode :s/text1/text2/c :,$s/text1/text2/c –>replace the first text1 of each line into text2 (from current line to the last line of file)by interaction mode

:r [command|file]-->write it to the next line of cursor
ZZ-->:wq :x
ZQ--> :q!
X-->encryption
e!:discard all changes(not written)
:!command -->e.g. :!ls execute command ofls

你可能感兴趣的:(Linux)