[root@host ~]# ps -ef | grep ssh

root      1561      1  0 02:57 ?        00:00:00 /usr/sbin/sshd

root      1750   1561  0 02:58 ?        00:00:00 sshd: root@pts/0

root      1779   1561  0 02:59 ?        00:00:00 sshd: [accepted]

root      1788   1754  0 03:00 pts/0    00:00:00 grep ssh

查看进程ssh


[root@host ~]# netstat -lntup | grep 22

tcp       0      0 0.0.0.0:22                0.0.0.0:*                LISTEN      1561/sshd          

tcp       0      0 :::22                     :::*                    LISTEN      1561/sshd          

查看端口号22


[root@host ~]#/etc/init.d/iptables stop

iptables: Settingchains to policy ACCEPT: filter          [ OK  ]

iptables: Flushingfirewall rules:                     [  OK  ]

iptables:Unloading modules:                       [  OK  ]

闭关防火墙       status查看状态


如ssh故障,如何排查

fd467c91dd0b37ca0bd5b3b398f45bea.png

1e119fe7670317dc5bb206458c41248c.png

64c1cf63ceddfbb44f41667dcbbd77a2.png


服务端叫ssh服务,进程名sshd,软件openssh连接用  openssl加密用


正常我们添加用户

useradd xxx

然后passwd YYYYY密码

这属于交互式的


[root@host ~]#echo "021241" | passwd --stdin xxx(用户名)

Changing passwordfor user user1.

passwd: allauthentication tokens updated successfully.   也可以这样,非交互式设置密码


657884c9800ebaa8974c9f334a2cc20c.png


SELinux 正常生产环境关闭的

查看目前状态

[root@hosttmp" "21:23:04]#getenforce

Enforcing

修改 vim/etc/selinux/config  或者  sed              

[root@hosttmp" "21:15:38]#sed 's#SELINUX=enforcing#SELINUX=disabled#g'/etc/selinux/config

差点就错了  没用加-i  只是显示的时候替换  实际并没有修改源文件


#sed -i's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config

这样就好了

不过这样 也行  先看  对了 再改

得重启再能生效  


如果不想重启

[root@hosttmp" "21:27:47]#setenforce

usage:  setenforce [ Enforcing | Permissive | 1 | 0 ]

[root@hosttmp" "21:28:31]#setenforce 0


查看运行级别    cat /etc/inittab

# Defaultrunlevel. The runlevels used are:

#   0 - halt (Do NOT set initdefault to this)     关机

#   1 - Single user mode      单用户状态

#   2 - Multiuser, without NFS (The same as 3,if you do not have networking)     多用户 没用NFS

#   3 - Full multiuser mode  命令行模式  正在使用

#   4 - unused  保留

#   5 - X11     桌面

#   6 - reboot (Do NOT set initdefault to this)   重启

id:3:initdefault:      在这里可以修改


查看当前运行级别

[root@hosttmp" "21:36:13]#runlevel

N 3


其实# init 6就是重启  #init 0 就是关机

shutdown -h now 

shutdown -r now

这两命令我不习惯用了


关闭防火墙

[root@hosttmp" "21:44:14]#/etc/init.d/iptables stop

iptables: Settingchains to policy ACCEPT: filter                 [ OK  ]

iptables: Flushingfirewall rules:                             [  OK  ]

iptables:Unloading modules:                              [  OK  ]

[root@hosttmp" "21:52:24]#/etc/init.d/iptables status

iptables: Firewallis not running.


#chkconfigiptables off  永久关闭


[root@hosttmp" "22:28:17]#cp /etc/sysconfig/i18n /etc/sysconfig/i18n.old  备份

[root@hosttmp" "22:28:33]#echo 'LANG="zh_CN.UTF-8"' >/etc/sysconfig/i18n  重定向内容

[root@hosttmp" "22:29:16]#source /etc/sysconfig/i18n  重读

[root@hosttmp" "22:29:26]#echo $LANG

zh_CN.UTF-8

改为中文字符集 

再改回来

[root@hosttmp" "22:33:30]#rm -f /etc/sysconfig/i18n

[root@hosttmp" "22:33:38]#mv /etc/sysconfig/i18n.old /etc/sysconfig/i18n

[root@hosttmp" "22:33:54]#source /etc/sysconfig/i18n

[root@hosttmp" "22:34:03]#echo $LANG

en_US.UTF-8



history -c 删除全部命令历史

history -d X 删除指定命令

echo $TMOUT

export TMOUT=3600 类似锁屏  

export HISTSIZE=5 保留5条命令行记录

exportHISTFILESIZE=5 保留命令历史文件记录的长度

以上只是当前生效


要想永久  可以放这个文件里  

[root@host ~""22:55:02]#cat /etc/profile

然后source下生效

c5f72186e3cf9a387a939740be6af36e.png


issue 说是启动时有显示  不安全 要删除(清空)????????

有时候  清空没问题  删除就有


 

快照类似 在虚拟机上面N个节点

克隆类似 电影复制到别的电脑上

但是我克隆完,用新的不能上网

解决方法:

1:编辑/etc/sysconfig/network-scripts/ifcfg-eth0配置文件,将ifcfg-eth0的配置文件里里面以前的关于MAC地址这一行删除掉或修改。  UUID不删也能用

2:找到/etc/udev/rules.d/70-persistent-net.rules删除后重启机器,系统会自动生成一个70-persistent-net.rules文件。


d979fe6ac44f95d05496ef2f27677555.png

[root@host ~""00:40:45]#mount /dev/sr0/mnt

mount: blockdevice /dev/sr0 is write-protected, mounting read-only

[root@host ~""00:40:55]#mount              这个版本已不是/dev/cdrom  而是/dev/sr0

/dev/sr0 on /mnttype iso9660 (ro)


cat/etc/fstab  系统自动已经挂载的

8f21d28f043d2e2301887e284217e966.png


e93dd011810c3eea5f6c92698c58e05d.png

bin    常用二进制命令 比如cp    ls   mkdir    rm    cut

boot   内核及系统引导程序所需的文件目录

data

dev    设备文件目录

etc   二进制软件安装包(yum,rpm)的配置文件默认路径

      fstab 开机自动挂载设备的文件

      inittab 开机自动加载的文件

      motd  登录显示自定义信息

      profile  全局环境变量

home   普通用户家目录

lib    

lib64

lost+found

media

mnt

opt

proc   显示内核及进程信息的虚拟文件系统

root   超级管理员的家目录

sbin/usr/sbin    超级用户命令的目录

selinux

srv

sys   

tmp   临时文件目录

usr   用户程序及数据、帮助文件、二进制命令等目录

var   变化的目录,一般是日志文件,cache的目录


service networkrestart 对所有网卡有效

ifdown eth0&& ifup eth0 只针对一个网卡

c2f0f98123b43b52b5225e2e10485124.png