Skip to content

Commit 19294bf

Browse files
committed
📝 Writing docs.
1 parent a6d3a3f commit 19294bf

7 files changed

Lines changed: 648 additions & 659 deletions

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66

77
- [查看 Linux 命令帮助信息](docs/linux/01.查看Linux命令帮助信息.md) - 关键词:`help`, `whatis`, `info`, `which`, `whereis`, `man`
88
- [Linux 文件目录管理](docs/linux/02.Linux文件目录管理.md) - 关键词:`cd`, `ls`, `pwd`, `mkdir`, `rmdir`, `tree`, `touch`, `ln`, `rename`, `stat`, `file`, `chmod`, `chown`, `locate`, `find`, `cp`, `mv`, `rm`
9-
- [Linux 文件内容查看命令](docs/linux/03.Linux文件内容查看编辑.md) - 关键词:`cat`, `head`, `tail`, `more`, `less`
10-
- [Linux 文件压缩与解压命令](docs/linux/Linux文件压缩与解压命令.md) - 关键词:`tar`, `gzip`, `zip`, `unzip`
11-
- [Linux 用户管理命令](docs/linux/Linux用户管理命令.md) - 关键词:`groupadd`, `groupdel`, `groupmod`, `useradd`, `userdel`, `usermod`, `passwd`, `su`, `sudo`
12-
- [Linux 系统管理命令](docs/linux/Linux系统管理命令.md) - 关键词:`reboot`, `exit`, `shutdown`, `date`, `mount`, `umount`
13-
- [Linux 性能管理命令](docs/linux/Linux性能管理命令.md) - 关键词:`df`, `du`, `top`, `free`, `iotop`
14-
- [Linux 进程管理命令](docs/linux/Linux进程管理命令.md) - 关键词:`ps`, `kill`, `systemctl`, `service`, `crontab`
15-
- [Linux 网络应用命令](docs/linux/Linux网络应用命令.md) - 关键词:`curl`, `wget`, `telnet`, `ip`, `hostname`, `ifconfig`, `route`, `ssh`, `ssh-keygen`, `iptables`
16-
- [Linux 网络测试命令](docs/linux/Linux网络测试命令.md) - 关键词:`host`, `nslookup`, `nc`/`netcat`, `dig`, `ping`, `traceroute`, `netstat`
9+
- [Linux 文件内容查看命令](docs/linux/03.Linux文件内容查看编辑.md) - 关键词:`cat`, `head`, `tail`, `more`, `less`, `sed`, `vi`, `grep`
10+
- [Linux 文件压缩和解压](docs/linux/04.Linux文件压缩和解压.md) - 关键词:`tar`, `gzip`, `zip`, `unzip`
11+
- [Linux 用户管理](docs/linux/05.Linux用户管理.md) - 关键词:`groupadd`, `groupdel`, `groupmod`, `useradd`, `userdel`, `usermod`, `passwd`, `su`, `sudo`
12+
- [Linux 系统管理](docs/linux/06.Linux系统管理.md) - 关键词:`reboot`, `exit`, `shutdown`, `date`, `mount`, `umount`, `ps`, `kill`, `systemctl`, `service`, `crontab`
13+
- [Linux 性能管理](docs/linux/07.Linux性能管理.md) - 关键词:`df`, `du`, `top`, `free`, `iotop`
14+
- [Linux 网络应用](docs/linux/08.Linux网络应用.md) - 关键词:关键词:`curl`, `wget`, `telnet`, `ip`, `hostname`, `ifconfig`, `route`, `ssh`, `ssh-keygen`, `firewalld`, `iptables`, `host`, `nslookup`, `nc`/`netcat`, `ping`, `traceroute`, `netstat`
1715
- [yum 命令](docs/linux/yum.md)
1816
- [linux 监控](docs/linux/linux监控.md)
1917
- [samba 使用详解](docs/linux/samba使用详解.md)
@@ -23,7 +21,7 @@
2321

2422
### [Python](docs/python.md)
2523

26-
### [Vim](docs/vim/README.md)
24+
### [Vim](docs/vim.md)
2725

2826
### [Git](docs/git/README.md)
2927

docs/linux/06.Linux系统管理.md

Lines changed: 179 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ tags:
1010

1111
# Linux 系统管理
1212

13-
> 关键词:`reboot`, `exit`, `shutdown`, `date`, `mount`, `umount`
13+
> 关键词:`reboot`, `exit`, `shutdown`, `date`, `mount`, `umount`, `ps`, `kill`, `systemctl`, `service`, `crontab`
1414
1515
<!-- TOC depthFrom:2 depthTo:3 -->
1616

@@ -22,6 +22,11 @@ tags:
2222
- [date](#date)
2323
- [mount](#mount)
2424
- [umount](#umount)
25+
- [ps](#ps)
26+
- [kill](#kill)
27+
- [systemctl](#systemctl)
28+
- [service](#service)
29+
- [crontab](#crontab)
2530

2631
<!-- /TOC -->
2732

@@ -33,6 +38,11 @@ tags:
3338
- 查看或设置系统时间与日期 - 使用 [date](#date)
3439
- 挂载文件系统 - 使用 [mount](#mount)
3540
- 取消挂载文件系统 - 使用 [umount](#umount)
41+
- 查看系统当前进程状态 - 使用 [ps](#ps)
42+
- 删除当前正在运行的进程 - 使用 [kill](#kill)
43+
- 启动、停止、重启、关闭、显示系统服务(Centos7),使用 [systemctl](#systemctl)
44+
- 启动、停止、重启、关闭、显示系统服务(Centos7 以前),使用 [service](#service)
45+
- 管理需要周期性执行的任务,使用 [crontab](#crontab)
3646

3747
## 命令常见用法
3848

@@ -201,3 +211,171 @@ umount -v /dev/sda1
201211
umount -v /mnt/mymount/
202212
/tmp/diskboot.img umounted
203213
```
214+
215+
### ps
216+
217+
> ps 命令用于报告当前系统的进程状态。可以搭配 kill 指令随时中断、删除不必要的程序。ps 命令是最基本同时也是非常强大的进程查看命令,使用该命令可以确定有哪些进程正在运行和运行的状态、进程是否结束、进程有没有僵死、哪些进程占用了过多的资源等等,总之大部分信息都是可以通过执行该命令得到的。
218+
>
219+
> 参考:http://man.linuxde.net/ps
220+
221+
示例:
222+
223+
```sh
224+
# 按内存资源的使用量对进程进行排序
225+
ps aux | sort -rnk 4
226+
227+
# 按 CPU 资源的使用量对进程进行排序
228+
ps aux | sort -nk 3
229+
```
230+
231+
### kill
232+
233+
> kill 命令用来删除执行中的程序或工作。kill 可将指定的信息送至程序。预设的信息为 SIGTERM(15),可将指定程序终止。若仍无法终止该程序,可使用 SIGKILL(9) 信息尝试强制删除程序。程序或工作的编号可利用 ps 指令或 job 指令查看。
234+
>
235+
> 参考:http://man.linuxde.net/kill
236+
237+
示例:
238+
239+
```sh
240+
# 列出所有信号名称
241+
kill -l
242+
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL
243+
5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE
244+
9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2
245+
13) SIGPIPE 14) SIGALRM 15) SIGTERM 16) SIGSTKFLT
246+
17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
247+
21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU
248+
25) SIGXFSZ 26) SIGVTALRM 27) SIGPROF 28) SIGWINCH
249+
29) SIGIO 30) SIGPWR 31) SIGSYS 34) SIGRTMIN
250+
35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3 38) SIGRTMIN+4
251+
39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8
252+
43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12
253+
47) SIGRTMIN+13 48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14
254+
51) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10
255+
55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7 58) SIGRTMAX-6
256+
59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2
257+
63) SIGRTMAX-1 64) SIGRTMAX
258+
259+
# 先用 ps 查找进程,然后用 kill 杀掉
260+
ps -ef | grep vim
261+
root 3268 2884 0 16:21 pts/1 00:00:00 vim install.log
262+
root 3370 2822 0 16:21 pts/0 00:00:00 grep vim
263+
264+
kill 3268
265+
kill 3268
266+
-bash: kill: (3268) - 没有那个进程
267+
```
268+
269+
### systemctl
270+
271+
> systemctl 命令是系统服务管理器指令,它实际上将 service 和 chkconfig 这两个命令组合到一起。
272+
>
273+
> 参考:http://man.linuxde.net/systemctl
274+
275+
示例:
276+
277+
```sh
278+
# 1.启动 nfs 服务
279+
systemctl start nfs-server.service
280+
281+
# 2.设置开机自启动
282+
systemctl enable nfs-server.service
283+
284+
# 3.停止开机自启动
285+
systemctl disable nfs-server.service
286+
287+
# 4.查看服务当前状态
288+
systemctl status nfs-server.service
289+
290+
# 5.重新启动某服务
291+
systemctl restart nfs-server.service
292+
293+
# 6.查看所有已启动的服务
294+
systemctl list -units --type=service
295+
296+
# 7. 开启防火墙 22 端口
297+
iptables -I INPUT -p tcp --dport 22 -j accept
298+
299+
# 8. 彻底关闭防火墙
300+
sudo systemctl status firewalld.service
301+
sudo systemctl stop firewalld.service
302+
sudo systemctl disable firewalld.service
303+
```
304+
305+
### service
306+
307+
> service 命令是 Redhat Linux 兼容的发行版中用来控制系统服务的实用工具,它以启动、停止、重新启动和关闭系统服务,还可以显示所有系统服务的当前状态。
308+
>
309+
> 参考:http://man.linuxde.net/service
310+
311+
示例:
312+
313+
```sh
314+
service network status
315+
配置设备:
316+
lo eth0
317+
当前的活跃设备:
318+
lo eth0
319+
320+
service network restart
321+
正在关闭接口 eth0: [ 确定 ]
322+
关闭环回接口: [ 确定 ]
323+
设置网络参数: [ 确定 ]
324+
弹出环回接口: [ 确定 ]
325+
弹出界面 eth0: [ 确定 ]
326+
```
327+
328+
### crontab
329+
330+
> crontab 命令被用来提交和管理用户的需要周期性执行的任务,与 windows 下的计划任务类似,当安装完成操作系统后,默认会安装此服务工具,并且会自动启动 crond 进程,crond 进程每分钟会定期检查是否有要执行的任务,如果有要执行的任务,则自动执行该任务。
331+
>
332+
> 参考:http://man.linuxde.net/crontab
333+
334+
示例:
335+
336+
```sh
337+
# 每 1 分钟执行一次 command
338+
* * * * * command
339+
340+
# 每小时的第 3 和第 15 分钟执行
341+
3,15 * * * * command
342+
343+
# 在上午 8 点到 11 点的第 3 和第 15 分钟执行
344+
3,15 8-11 * * * command
345+
346+
# 每隔两天的上午 8 点到 11 点的第 3 和第 15 分钟执行
347+
3,15 8-11 */2 * * command
348+
349+
# 每个星期一的上午 8 点到 11 点的第 3 和第 15 分钟执行
350+
3,15 8-11 * * 1 command
351+
352+
# 每晚的 21:30 重启 smb
353+
30 21 * * * /etc/init.d/smb restart
354+
355+
# 每月 1、10、22 日的 4 : 45 重启 smb
356+
45 4 1,10,22 * * /etc/init.d/smb restart
357+
358+
# 每周六、周日的 1:10 重启 smb
359+
10 1 * * 6,0 /etc/init.d/smb restart
360+
361+
# 每天 18 : 00 至 23 : 00 之间每隔 30 分钟重启 smb
362+
0,30 18-23 * * * /etc/init.d/smb restart
363+
364+
# 每星期六的晚上 11:00 pm 重启 smb
365+
0 23 * * 6 /etc/init.d/smb restart
366+
367+
# 每一小时重启 smb
368+
* */1 * * * /etc/init.d/smb restart
369+
370+
# 晚上 11 点到早上 7 点之间,每隔一小时重启 smb
371+
* 23-7/1 * * * /etc/init.d/smb restart
372+
373+
# 每月的 4 号与每周一到周三的 11 点重启 smb
374+
0 11 4 * mon-wed /etc/init.d/smb restart
375+
376+
# 一月一号的 4 点重启 smb
377+
0 4 1 jan * /etc/init.d/smb restart
378+
379+
# 每小时执行`/etc/cron.hourly`目录内的脚本
380+
01 * * * * root run-parts /etc/cron.hourly
381+
```

0 commit comments

Comments
 (0)