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

替换命令的完整形式: :[range]s/from/to/[flags] 替换命令传送门
: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 😒/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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值