Linux常用知识点整理

Linux常用知识点整理



前言

本文主要以CentOS7为例进行梳理


一、系统服务管理

1. 后台服务管理

(1)临时生效
开启服务:

systemctl  start	服务名	(如firewalld、network)

关闭服务:

systemctl  stop	服务名	

重新启动服务:

systemctl   restart	 服务名	

查看服务状态:

systemctl   status	 服务名

查看正在运行的服务:

systemctl  --type  service

(2)自启动配置
查看所有服务器自启配置:

systemctl  list-unit-files  

关掉指定服务的自动启动:

systemctl  disable 服务名(如firewalld、network)

开启指定服务的自动启动:

systemctl  enable  服务名  

查看服务开机启动状态:

systemctl  is-enabled 服务名

二、系统进程管理

1.ps命令

(1)命令

ps -aux | grep xxx
ps -ef | grep xxx	

(2)实例

[root@localhost system]# ps aux
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root          1  0.0  0.2 193904  5336 ?        Ss   5月16   0:17 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
root          2  0.0  0.0      0     0 ?        S    5月16   0:00 [kthreadd]
root          3  0.0  0.0      0     0 ?        S    5月16   0:03 [ksoftirqd/0]
root          5  0.0  0.0      0     0 ?        S<   5月16   0:00 [kworker/0:0H]
root          7  0.0  0.0      0     0 ?        S    5月16   0:08 [migration/0]
root          8  0.0  0.0      0     0 ?        S    5月16   0:00 [rcu_bh]
root          9  0.0  0.0      0     0 ?        S    5月16   0:18 [rcu_sched]
root         10  0.0  0.0      0     0 ?        S<   5月16   0:00 [lru-add-drain]
root         11  0.0  0.0      0     0 ?        S    5月16   0:07 [watchdog/0]
root         12  0.0  0.0      0     0 ?        S    5月16   0:14 [watchdog/1]
root         13  0.0  0.0      0     0 ?        S    5月16   0:06 [migration/1]
root         14  0.0  0.0      0     0 ?        S    5月16   0:11 [ksoftirqd/1]
root         16  0.0  0.0      0     0 ?        S<   5月16   0:00 [kworker/1:0H]
root         17  0.0  0.0      0     0 ?        S    5月16   0:06 [watchdog/2]
[root@localhost system]# ps -ef
UID         PID   PPID  C STIME TTY          TIME CMD
root          1      0  0 5月16 ?       00:00:17 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
root          2      0  0 5月16 ?       00:00:00 [kthreadd]
root          3      2  0 5月16 ?       00:00:03 [ksoftirqd/0]
root          5      2  0 5月16 ?       00:00:00 [kworker/0:0H]
root          7      2  0 5月16 ?       00:00:08 [migration/0]
root          8      2  0 5月16 ?       00:00:00 [rcu_bh]
root          9      2  0 5月16 ?       00:00:18 [rcu_sched]
root         10      2  0 5月16 ?       00:00:00 [lru-add-drain]
root         11      2  0 5月16 ?       00:00:07 [watchdog/0]
root         12      2  0 5月16 ?       00:00:14 [watchdog/1]
root         13      2  0 5月16 ?       00:00:06 [migration/1]
root         14      2  0 5月16 ?       00:00:11 [ksoftirqd/1]
root         16      2  0 5月16 ?       00:00:00 [kworker/1:0H]

(3)参数说明
USER:该进程是由哪个用户产生的
PID:进程的ID号
%CPU:该进程占用CPU资源的百分比,占用越高,进程越耗费资源;
%MEM:该进程占用物理内存的百分比,占用越高,进程越耗费资源;
VSZ:该进程占用虚拟内存的大小,单位KB;
RSS:该进程占用实际物理内存的大小,单位KB;

2. top命令

top 【选项】
选项为:-d、-i、-p
选项说明:
(1)-d 秒数 指定top命令每隔几秒更新。默认是3秒在top命令的交互模式当中可以执行的命令
(2)-i 使top不显示任何闲置或者僵死进程。
(3)-p 通过指定监控进程ID,监控某个进程的状态。

3. netstat命令

查看该进程网络信息:

netstat -anp |grep 进程号

查看网络端口号占用情况:

netstat -nlp	| grep 端口号

三、系统定时任务

1. crond 服务管理

(1)系统配置文件/etc/crontab

[root@localhost system]# cat /etc/crontab 
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed

(2)重启定时任务

systemctl restart crond

2. 设置定时任务

crontab [选项]
选项 功能
-e 编辑crontab定时任务
-l 查询crontab任务
-r 删除当前用户所有的crontab任务

四、系统软件包管理

1. rpm查询命令

rpm -qa |grep xxx

2. rpm卸载命令

rpm -e xxx
rpm -e --nodeps xxx

3. rpm安装命令

rpm -ivh xxx.rpm

总结

未完待续…

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值