Shell(二)常用命令和技巧

命令行一些技巧:
*

表示任意字符(也可以无字符)

?

任意一个单字符

[a-z]

包含一个字符范围中的任一字符

[^a-z]

不包含此范围的字符

Tab键

补齐命令名称或其他名称

history

重新输入以前执行过的指令

	!+序号

^

替代上个命令中的某一段字符

	如^2^1 将上个命令中的1替换为2

~

进入家目录(home directory)

	~root

	~user1

$

变量名

	如 echo $HOME

{}

排列组合

	a{a,b}=aa,ab

`` or $()

优先执行的命令

	echo "Hostname: `hostname`"

$[]

进行数学计算

	echo $[$a + $b]

\

后面的命令接着前面的

"

禁止所有特殊资源的功能,除了$ \ ` !

禁止所有特殊资源的功能

+. or +.

补齐上个命令的最后一个参数

set -o/+o vi

切换编辑模式

常用命令:
date
cal: calendar
pwd: parent working directory
cd: change directory
ls: list directory contents
cp: copy files and directories
mv: move and/or rename files and directories
rm: remove files
touch: create empty files or update file timestamps
mkdir: make a directory
rmdir: remove an empty directory
file: check file type
cat: view an entire text file
less: view text page by page
cut: display specific columns of file data
sort: sort text to standard out - original file unchanged
chmod: change access modes
df: report disk space usage(free)
du: report disk space usage(used)
tar: create/extract an archive
gzip: compress
bzip: compress
gunzip: extract
bunzip: extract
passwd: change password
su: start a new shell as a different user
sed: search and replace
head: display first few lines(default 10 lines) of text in a file
tail: display last few lines(default 10 lines) of text in a file
wc: “count lines, words and characters”
uniq: “remove successive, duplicate lines in a file”
paste: paste files together
tr: character translator
diff: version comparison
sdiff: version comparison
aspell: spell checking
expand: expand tabs into spaces
fmt: reformat text into paragraphs
pr: reformat text for printing
top: display snapshot of processes
vmstat: report virtual memory stats
free: summary of system memory usage
renice: change priority of a process
kill: send system signal to a process
fdisk: create partitions
partprobe: reinitialize the kernel in memory of the partition table
mke2fs: filesystem creation
lsattr: display file attributes
chattr: change file attributes
ln: linkname
alias: create shortcuts to commands
whoami: find out who you are
groups: find out what groups you belong to
id: find out what groups you belong to
users: find out who is logged in
who: find out who is logged in
w: find out who is logged in
last: login/reboot history

猜你喜欢

转载自blog.csdn.net/biocity/article/details/83152466