010708笔记

来源:互联网 发布:四川农业大学网络教育 编辑:程序博客网 时间:2024/06/18 11:00

第七单元

1.进程定义

进程就是cpu未完成的工作

 2.ps命令

ps

a ##关于当前环境的所有进程

x ##与当前环境无关的所有进程

f ##显示进程从属关系

e ##显示进程调用环境工具的详细信息

l ##长列表显示进程的详细信息

u ##显示进程的用户信息


 ps ax -o %cpu,%mem,user,group,comm,nice,pid ##指定显示进程的某些信息

%cpu ##显示进程cpu负载

%mem ##显示进程内存负载

user ##进程用户

group ##进程组

comm ##进程名称

nice ##进程优先级

pid ##进程的id


 ps ax -o %cpu,comm --sort <+|-%cpu > <+|-%mem> ##按照进程信息排序

+ ##正序

- ##倒序

%cpu ##cpu负载排序

%mem ##内存负载


 3.进程优先级

1.进程的优先级范围

-20~19

 2.优先级查看

ps ax -o pid,nice,comm


 3.指定某个优先级开启进程

nice -n 优先级数字 进程名称

nice -n -5 vim & ##开启vim并且指定程序优先级为-5


 4.改变进程优先级

reince -n 优先级数字 进程pid

renice -n -5 1806 ##改变1806进程的优先级为-5


4.环境中进程的前后台调用

jobs ##查看被打入环境后台的进程

ctrl+z ##把占用终端的进程打入后台

fg ##把后台进程调回前台

bg ##把后台暂停的进程运行

comm & ##让命令直接在后台运行

 5.进程信号

1.常用信号等级

1 ##进程重新加载配置

2 ##删除进程在内存中的数据

3 ##删除鼠标在内存中的数据

9 ##强行结束单个进程

15 ##正常关闭进程

18 ##运行暂停的进程

19 ##暂停某个进程

20 ##把进程打入后台

man 7 signal ##查看信号详细信息

 kill -信号 进程pid

killall -信号 进程名字

pkill -u student -信号

6.用户登陆审记

 1

w ##查看使用系统的当前用户有那些

w -f ##-f查看使用地点


 2

last ##查看用户登陆成功历史


3.

lastb ##查看用户登陆未成功历史



 7.top命令

top ##监控系统负载工具


 


8.系统服务的控制

1.systemd

系统初始化程序,系统开始的第一个进程,pid为1

 2.systemctl 命令

systemctl list-units ##列出当前系统服务的状态

systemctl list-unit-files ##列出服务的开机状态

systemctl status sshd ##查看指定服务的状态

systemctl stop sshd ##关闭指定服务

systemctl start sshd ##开启指定服务

systemctl restart sshd ##从新启动服务

systemctl enable sshd ##设定指定服务开机开启

systemctl disable sshd ##设定指定服务开机关闭

systemctl reload sshd ##使指定服务从新加载配置

systemctl list-dependencies sshd ##查看指定服务的倚赖关系

systemctl mask sshd ##冻结指定服务

systemctl unmask sshd ##启用服务

systemctl set-default multi-user.target ##开机不开启图形

systemctl set-default graphical.target ##开机启动图形

 3.服务状态

systemctl status 服务名称

 loaded ##系统服务已经初始化完成,加载过配置

active(running) ##正有一个或多个程序正在系统中执行,

# vsftpd 就是這種模式

 atcive(exited) ##僅執行一次就正常結束的服務,

# 目前並沒有任何程序在系統中執行

 atcive(waiting) ##正在執行當中,

# 不過還再等待其他的事件才能繼續處理

 inactive ##服务关闭

enbaled ##服务开机启动

disabled ##服务开机不自启

static ##服务开机启动项不可被管理

failed ##系统配置错误


9.openssh-server

1.openssh-server

 功能:让远程主机可以通过网络访问sshd服务,开始一个安全shell

 2.客户端连接方式

ssh 远程主机用户@远程主机ip

[root@desktop0 ~]# ssh root@172.25.0.11

The authenticity of host '172.25.0.11 (172.25.0.11)' can't be established.

ECDSA key fingerprint is eb:24:0e:07:96:26:b1:04:c2:37:0c:78:2d:bc:b0:08.

Are you sure you want to continue connecting (yes/no)? yes ##连接陌生主机时需要建立认证关系

Warning: Permanently added '172.25.0.11' (ECDSA) to the list of known hosts.

root@172.25.0.11's password: ##远程用户密码

Last login: Mon Oct  3 03:13:47 2016

[root@server0 ~]# ##登陆成功

 ssh 远程主机用户@远程主机ip -X ##调用远程主机图形工具

ssh     远程主机用户@远程主机ip command ##直接在远程主机运行某条命令


 3.sshkey加密

1.生成公钥私钥

[root@server0 ~]# ssh-keygen ##生成公钥私钥工具

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):[enter] ##加密字符保存文件(建议用默认)

Created directory '/root/.ssh'.

Enter passphrase (empty for no passphrase): [enter] ##密钥密码,必须>4个字符

Enter same passphrase again: [enter] ##确认密码

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

ab:3c:73:2e:c8:0b:75:c8:39:3a:46:a2:22:34:84:81 root@server0.example.com

The key's randomart image is:

+--[ RSA 2048]----+

|o                |

|E.               |

|..               |

|.  . o           |

|.o. * . S        |

|oo.o o   .       |

|+ =. .  .        |

|o. oo.+..        |

|    ..o*.        |

+-----------------+

[root@server0 ~]# ls /root/.ssh/

id_rsa  id_rsa.pub

id_rsa ##私钥,就是钥匙

id_rsa.pub ##公钥,就是锁

 

2.添加key认证方式

[root@server0 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub  root@172.25.0.11

ssh-copy-id ##添加key认证方式的工具

-i ##指定加密key文件

/root/.ssh/id_rsa.pub ##加密key

root ##加密用户为root

172.25.0.11 ##被加密主机ip

 

3.修改配置文件


4.分发钥匙给client主机

[root@server0 ~]# scp /root/.ssh/id_rsa root@172.25.0.10:/root/.ssh/

 

5.测试

[root@desktop0 ~]# ssh root@172.25.0.11 ##通过id_rsa直接连接不需要输入用户密码

Last login: Mon Oct  3 03:58:10 2016 from 172.25.0.250

[root@server0 ~]#

 

4.提升openssh的安全级别

1.openssh-server配置文件

/etc/ssh/sshd_config

78 PasswordAuthentication yes|no ##是否开启用户密码认证,yes为支持no为关闭

48 PermitRootLogin yes|no ##是否允许超级用户登陆

49 AllowUsers student westos ##用户白名单,只有在名单中出现的用户可以使用sshd建立shell

50 DenyUsers westos ##用户黑名单

 

11.管理网络

 1.ip基础知识

1.ipv4

2进制32位-----10进制

 172.25.0.10/255.255.255.0

172.25.0.10:ip地址

255.255.255.0:子网掩码

子网掩码255位对应的ip位为网络位

子网掩码0对应的ip位为主机位

 2.配置ip

<<图形化>>

1.图形界面

nm-connection-editor

2.文本化图形

nmtui

 <<命令>>

ifconfig 网卡 ip netmask ##临时设定

 nmcli connection add type ethernet con-name westos ifname eth0 autoconnect yes

nmcli connection add type ethernet con-name westos ifname eth0 ip4 ip/24

nmcli connection delete westos

nmcli connection show

nmcli connection down westos

nmcli connection up westos

nmcli connection modify "westos" ipv4.addresses newip/24

nmcli connection modify "westos" ipv4.method <auto|manual>

nmcli device connect eth0

nmcli device disconnect eth0

nmcli device show

nmcli device status

 <<文件>>

dhcp ##动态获取

vim /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0 ##接口使用设备

BOOTPROTO=dhcp ##网卡工作模式

ONBOOT=yes ##网络服务开启时自动激活

NAME=eth0 ##网络接口名称

wq

systemctl restart network

 static|none ##静态网络

vim /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0  ##设备

BOOTPROTO=static|none  ##设备工作方式

ONBOOT=yes  ##开启网络服务激活设备

NAME=eth0  ##网络接口名称

IPADDR=172.25.0.100   ##IP

NETNASK=255.255.255.0 | PREFIX=24 ##子网掩码



0 0