码迷,mamicode.com
首页 > 其他好文 > 详细

笔记 7-9 12

时间:2016-10-11 00:17:55      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:详细信息   关键字   僵尸   用户   

《《《《《《《《《《《《《《《第七单元》》》》》》》》》》》》。

1.进程  系统正在做的事情

2.进程状态  运行 休眠  停止  继续  结束  僵尸进程(进程结束 但是仍然占用内存)

3.图形界面查看进程  gnome-system-monitor

4.用命令查看进程  

ps        进程查看工具
    -a    shell中运行的进程(前端)
     a    shell中的所有进程
    -x    不在shell重运行的进程
    -u    查看进程用户
    -l    显示进程的详细信息
    -f    完全信息full的缩写
    -e    显示系统中的所有进程

ps    -aux    |grep    进程关键字

ps ax    -o %cpu,%mem,user,pid,comm    ##查看进程某项信息
ps aux --sort +|-%cpu|%mem...        ##进程按指定方式排序

eg:     ps ax -o %cpu,comm --sort +%cpu      按顺序大小正向排列  (从小到大)
    ps ax -o %cpu,comm --sort —%cpu      按顺序大小逆向排列  (从大到小)

5.控制shell重进程的前后台调用

命令&        进程在shell后台运行
ctrl +z        把占用shell的进程打入后台停止
jobs        查看被打入后台的进程信息
fg job号    把指定进程调回前台
bg job号    运行后台停止进程
ctrl +c        关闭占用shell进程


6.如何用命令控制进程

1)信号
信号 1        reload进程
信号 2        ctrl +c 删除进程在内存中的信息
信号 3        内存中的鼠标信息清除
信号 9        强行关闭进程
信号 15        正常关闭进程
信号 18        开启停止的进程
信号 19        停止正在运行的进程
信号 20        ctrl +z


2)信号发起
kill     信号     pid
killall    信号    进程名称
pkill -u username    ##结束某个用户的所有进程
7.用户登陆监控

w        查看当前使用系统的用户
w    -f    查看当前使用系统的用户并显示使用地点

last        查看登陆过系统的用户
lastb        查看试图登陆但没有成功的用户

ifconfig eth0 查看用户id

8.top命令
u username
k        信号
h          显示帮助
s 1        表示1秒刷新一下        
m          切换显示内存信息
c          切换显示命令名称和完整命令行


《《《《《《《《《《第八单元》》》》》》》》》》》》》

1.服务  service
    
    服务就是在系统中运行的软件,这个软件主要是对外提供某项功能,那么我们把这一类软件叫做服务

2.服务管理,systemctl命令


  systemctl     start   服务名称     开启服务
         stop            关闭服务
         restart            重启服务
         reload            重新加在服务配置
         status            查看服务状态
         enable            设定服务开机启动
         disable            禁止服务开机启动
          list-dependencies                    查看服务依赖关系
          list-units                        查看当前运行的所有服务
         list-unit-files                 查看服务的开机启动情况
         set-default multi-user.target      开机不启动图形
         set-default graphical.target              开机启动图形


eg:  systemctl    start  ssyd


<<<<<<<<<<<<第九单元》》》》》》》》》》》》》》》》

1.openssh    一个提供远程访问控制的软件

2.如何实现远程访问

ssh 远程主机用户@远程主机ip地址
ssh root@172.25.254.1
The authenticity of host ‘172.25.254.1 (172.25.254.1)‘ can‘t be established.
ECDSA key fingerprint is 55:dd:43:ce:bf:94:dd:91:49:e7:97:29:63:3d:02:02.
Are you sure you want to continue connecting (yes/no)? yes    建立安全传输key

root@172.25.254.1‘s password:    密码输入没有回显

Last failed login: Sun Oct 11 16:56:29 CST 2015 from 172.25.254.206 on ssh:notty
There was 1 failed login attempt since the last successful login.
Last login: Sun Oct 11 16:55:46 2015 from 172.25.254.206

[root@foundation1 ~]#        登陆成功

ctrl +d    |logout            退出

[root@foundation1 ~]# logout
Connection to 172.25.254.1 closed.

[root@localhost ~]# vim /etc/motd     设定登陆显示字符


2.ssh的key认证

生成key

[test@foundation0 ~]$ ssh-keygen     生成公钥和私钥的工具

Generating public/private rsa key pair.
Enter file in which to save the key (/home/test/.ssh/id_rsa):『enter』 指定加密字符保存文件,使用默认

Created directory ‘/home/test/.ssh‘.
Enter passphrase (empty for no passphrase):     密码,必须大于4位

Enter same passphrase again:

Your identification has been saved in /home/test/.ssh/id_rsa.
Your public key has been saved in /home/test/.ssh/id_rsa.pub.
The key fingerprint is:                确认密码

a5:4f:02:51:68:59:f4:e8:e3:c5:91:1f:6f:86:99:06 test@foundation0.ilt.example.com
The key‘s randomart image is:
+--[ RSA 2048]----+
|      .*+        |
|      +. o .     |
|     .. . E .    |
|       o + + *   |
|        S + * +  |
|       . * . o   |
|        . .      |
|                 |
|                 |
+-----------------+
[test@foundation0 .ssh]$ pwd
/home/test/.ssh            生成密钥存放位置

[test@foundation0 .ssh]$ ls    
id_rsa  id_rsa.pub        id_rsa位私钥,id_rsa.pub位公钥

使用key加密目标主机的目标用户

[test@foundation0 ~]$  ssh-copy-id -i /home/test/.ssh/id_rsa.pub westos@172.25.254.100

The authenticity of host ‘172.25.254.100 (172.25.254.100)‘ 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
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
westos@172.25.254.100‘s password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh ‘westos@172.25.254.100‘"
and check to make sure that only the key(s) you wanted were added.





ssh-copy-id        上传key的工具
-i            指定使用的公钥
/home/test/.ssh/id_rsa.pub    使用公钥的名称
westos            被管理的目标用户
172.25.254.100        被管理用户所在主机的ip


authorized_keys        此文件在目标用户加目录的.ssh中,这个文件就是目标用户被加密的标识,文件内容位公钥内容。


ssh-copy-id -i id_rsa.pub root@172.25.254.5   ###上锁

scp id_rsa root@172.25.254.04:/root/.ssh   ###把自己密码给04 04在进5不需要输入密码

 ssh-keygen                
 cd /root/.ssh/
 ls
 ssh-copy-id -i id_rsa.pub root@自己
 scp id_rsa root@172.25.254.11(要给的):/root/.ssh/


3.sshd服务的简单配置
vim /etc/ssh/sshd_config        sshd服务的配置文件

48 PermitRootLogin yes|no        是否允许root用户通过sshd的认证
78 PasswordAuthentication yes|no    开启或关闭用户密码认证
AllowUsers student westos        用户白名单,只允许在名单中出现的用户使用sshd服务
systemctl restart sshd            从新加载配置

重新安装ssh服务     yum reinstall openssh-server -y
若有错误则          yum install openssh-server -y


<<<<<<<<<<<<<<<<<<第十二单元>>>>>>>>>>>>>>>>>>>>>>>>>


1.打包,压缩

打包  打包表示把一堆文件变成一个整体

tar                打包工具
    -f            指定生成包的名字
    -c            创建包
    -v            显示创建过程
    -t            查看包中内容
    -x            解包
    -r            添加文件到包中
    --delete filename   删除包中指定文件
    --get filename        取出包中指定文件


eg: tar cf etc.tar /etc/    
 tar vcf etc.tar /etc/   
 tar xf etc.tar         
 tar rf etc.tar file     
 tar tf etc.tar          
 tar f etc.tar --get file     
 tar f etc.tar --delete file  

压缩

gzip
gzip xxxx.tar =====> xxxx.tar.gz    压缩
gunzip    xxxx.tar.gz =====> xxxx.tar    解压
tar zcvf xxxx.tar.gz 目标文件        打包压缩文件
tar zxvf xxxx.tar.gz             xxxx.tar.gz===>xxxx

bz2
bzip2 xxxx.tar =====> xxxx.tar.bz2    压缩
bunzip2 xxxx.tar.bz2 =====> xxxx.tar    解压
tar jcvf xxxx.tar.bz2 目标文件         打包压缩文件
tar jxvf xxxx.tar.bz2            xxxx.tar.bz2===>xxxx

xz
xz xxxx.tar =====> xxxx.tar.xz      压缩
unxz xxxx.tar.xz =====> xxxx.tar    解压
tar Jcvf xxxx.tar.xz     目标文件      打包压缩文件
tar Jxvf xxxx.tar.xz                xxxx.tar.xz===>xxxx

zip
zip -r xxx.tar.zip     xxx.tar        压缩
unzip xxx.tar.zip            解压

远程文件传输

scp            远程复制
scp     file    user@ip:/directory        上传文件
scp -r     dir    user@ip:/directory        长传目录
scp     user@ip:/filename    /direcotry    下载文件
scp -r    user@ip:/directory    /direcotry    下载目录

rsync            远程同步
rsync file|direcotry user@ip:/directory
rsync user@ip:/directory /directory
    -r    同步目录
    -l    不忽略链接
    -p    不忽略权限
    -t    不忽略时间戳
    -g    不忽略组信息
    -o    不忽略用户信息
    -D    不忽略设备文件
sftp
rsync file|direcotry user@ip:/directory
如 rsync -r /mnt root@172.25.15.11:/mnt
  rsync -rl /mnt root@172.25.15.11:/mnt

 yum reinstall openssh-server -y   从新安装
 yum install openssh-server -y     不推荐



笔记 7-9 12

标签:详细信息   关键字   僵尸   用户   

原文地址:http://12120116.blog.51cto.com/12110116/1860339

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!