查看系统版本:
1
|
cat
/
proc
/
version
|
返回结果:
1
2
|
[
root
@
blog
-
seo
~
]
# cat /proc/version
Linux
version
3.10.0
-
693.21.1.el7.x86_64
(
builder
@
kbuilder
.dev
.centos
.org
)
(
gcc
version
4.8.5
20150623
(
Red
Hat
4.8.5
-
16
)
(
GCC
)
)
#1 SMP Wed Mar 7 19:03:37 UTC 2018
|
查看内存及用量(M为单位)
1
2
3
4
5
|
free
-
m
# 结果是
total
used
free
shared
buff
/
cache
available
Mem
:
128806
7115
115910
77
5780
120877
Swap
:
0
0
0
|
查看内存及用量(G为单位):
1
|
free
-
g
|
结果是:
1
2
3
|
total
used
free
shared
buff
/
cache
available
Mem
:
125
6
113
0
5
118
Swap
:
0
0
0
|
查看各分区使用情况: 硬盘容量
1
2
3
4
5
6
7
8
9
10
|
df
-
h
[
root
@
blog
-
seo
~
]
# df -h
文件系统
容量
已用
可用
已用
%
挂载点
/
dev
/
vda1
40G
8.0G
30G
22
%
/
devtmpfs
488M
0
488M
0
%
/
dev
tmpfs
497M
0
497M
0
%
/
dev
/
shm
tmpfs
497M
664K
496M
1
%
/
run
tmpfs
497M
0
497M
0
%
/
sys
/
fs
/
cgroup
tmpfs
100M
0
100M
0
%
/
run
/
user
/
0
|
查看当前目录文件及文件夹大小:
1
2
3
4
5
6
7
8
|
[
root
@
blog
-
seo
~
]
# du -sh *
110M
168seo.sql
40M
art_word
_crawl
8.0K
demo
_flask
201M
lnmp1
.
4
2.9M
lnmp
-
install
.log
110M
mariadb_all_backup20180323100405
.sql
1.3M
upgrade_mariadb20180323100405
.log
|
查看所有进程:
1
2
3
4
5
6
|
blog_django
ps
-
ef
UID
PID
PPID
C
STIME
TTY
TIME
CMD
0
1
0
0
二
10上午
?
?
9
:
37.40
/
sbin
/
launchd
0
48
1
0
二
10上午
?
?
0
:
19.71
/
usr
/
sbin
/
syslogd
0
49
1
0
二
10上午
?
?
0
:
16.85
/
usr
/
libexec
/
UserEventAgent
(
System
)
0
51
1
0
二
10上午
?
?
0
:
02.99
/
System
/
Library
/
PrivateFrameworks
/
Uninstall
.framework
/
Resources
/
uninstalld
|
筛选进程:
1
2
3
4
5
6
|
[
root
@
blog
-
seo
~
]
# ps -ef | grep python
root
712
1
0
3月
23
?
00
:
00
:
46
/
usr
/
bin
/
python
-
Es
/
usr
/
sbin
/
tuned
-
l
-
P
root
4872
4857
0
3月
23
?
00
:
42
:
00
python3
/
app
/
bin
/
splash
--
proxy
-
profiles
-
path
/
etc
/
splash
/
proxy
-
profiles
--
js
-
profiles
-
path
/
etc
/
splash
/
js
-
profiles
--
filters
-
path
/
etc
/
splash
/
filters
--
lua
-
package
-
path
/
etc
/
splash
/
lua_modules
/
?
.lua
root
14377
14182
0
09
:
00
pts
/
1
00
:
00
:
00
grep
--
color
=
auto
python
root
24260
1
0
3月
27
?
00
:
00
:
23
/
usr
/
bin
/
python3
.
6
/
usr
/
bin
/
gunicorn
--
bind
unix
:
/
tmp
/
d
.
168seo.cn.socket
mysite
.wsgi
:
application
root
24263
24260
0
3月
27
?
00
:
00
:
04
/
usr
/
bin
/
python3
.
6
/
usr
/
bin
/
gunicorn
--
bind
unix
:
/
tmp
/
d
.
168seo.cn.socket
mysite
.wsgi
:
application
|
批量杀死进程
获取进程id
1
2
3
4
5
6
|
[
root
@
blog
-
seo
~
]
# ps -ef | grep python | cut -c 9-15
712
4872
14421
24260
24263
|
1
|
ps
-
ef
|
grep
python
|
cut
-
c
9
-
15
|
xargs
kill
-
9
|
使用 cut 选定字段
通过名字我们就能差不多猜测出该命令是个干嘛地,是用来剪下文本文件的数据,文本文件可以是字段类型或者是字符类型.后一种数据类型在遇到需要从文件里剪下特定的列时,很方便.注意:一个制表符在此被视为单个字符.
案例: 显示系统上每个用户登录名称和全名
cut -d : -f 1,5 /etc/passwd
cut 的语法:
cut -d'分隔字符' -f fields
<==用于有特定分隔字符
cut -c 字符区间
<==用于排列整齐的信息
选项与参数:
-d :后面接分隔字符。与 -f 一起使用;-f :依据 -d 的分隔字符将一段信息分割成为数段,用 -f 取出第几段的意思;
-c :以字符 (characters) 的单位取出固定字符区间;
实用例子:只显示/etc/passwd 的用户和 shell
cat /etc/passwd | cut -d ’:’ -f 1,7
冒号是分割符,比如说.etc/passwd 中的每一行是一条绳子,每个冒号就是这条绳子上的一个标志,这些标志将绳子分成不同的部分.
-c 选项的案例:
echo “hello,world” | cut -c 8-12
输出第 8 到 12 个字符
提示:在/etc/passwd 中如果需要输出第 3-5 列:
cat /etc/passwd | cut -d ’:’ -f 3-5
想要输出 3 到最后一列
cat /etc/passwd | cut -d ’:’ -f 3-
功能:杀死进程名称中包含qemu的所有进程
1
|
ps
aux
|
grep
qemu
|
awk
'{print $2}'
|
xargs
kill
-
9
|