[关闭]
@mrz1 2018-01-07T10:09:49.000000Z 字数 2493 阅读 931

Linux系统管理命令和sshd服务

Linux系统管理命令


关闭防火墙centos7

  1. [root@centos7 x86_64]#sed -i.bak 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config
  2. [root@centos7 x86_64]#setenforce 0 //修改完生效
  3. [root@centos7 x86_64]#getenforce
  4. Permissive
  5. [root@centos7 x86_64]#iptables -nvL 查看有没有开启如果有东西就开启了
  6. [root@centos7 x86_64]#systemctl stop firewalld 现在关闭
  7. [root@centos7 x86_64]#systemctl disable firewalld 下次开机不要启动

关闭防火墙centos6

  1. [root@centos6 ~]#sed -i.bak 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config
  2. [root@centos6 ~]#setenforce 0 //修改完生效
  3. [root@centos6 ~]#getenforce
  4. Permissive
  5. [root@centos6 ~]#chkconfig iptables off
  6. [root@centos6 ~]#service iptables stop
  7. iptables: Setting chains to policy ACCEPT: filter [ OK ]
  8. iptables: Flushing firewall rules: [ OK ]
  9. iptables: Unloading modules: [ OK ]
  10. [root@centos6 ~]#iptables -nvL
  11. Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
  12. pkts bytes target prot opt in out source destination
  13. Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
  14. pkts bytes target prot opt in out source destination
  15. Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
  16. pkts bytes target prot opt in out source destination
系统服务管理命令systemctl

开启一个服务 : systemctl start sshd
关闭一个服务: systemctl stop sshd
查看一个服务的状态: systemctl status sshd
重启一个服务: systemctl restart sshd
设定一个服务开机启动: systemctl enable sshd
设定服务开机不启动: systemctl disable sshd
重新加载服务的配置文件: systemctl reload sshd
锁定服务: systemctl mask sshd
解锁服务: systemctl unmask sshd
开机启动图形:systemctl set-default graphical.target
开机不启动图形: systemctl set-default multi-user.target

ssh命令

ssh命令可以远程登录主机,格式
ssh root@172.254.23.111
root :是登录主机所属用户
172.254.23.111:主机的ip地址
这个方式是以登录密码的方式,其中最后一行输入密码。
在登录之前,主机要执行一下步骤开始ssh服务

  1. systemctl stop firewalls.service ##关闭防火墙
  2. ystemctl start sshd ##开启ssh服务

查看sshd服务的状态:

  1. [root@centos7 app]#systemctl status sshd
  2. sshd.service - OpenSSH server daemon
  3. Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
  4. Active: active (running) since Sat 2017-11-25 08:32:00 CST; 3h 15min ago
  5. Docs: man:sshd(8)
  6. man:sshd_config(5)
  7. Main PID: 1053 (sshd)
  8. CGroup: /system.slice/sshd.service
  9. └─1053 /usr/sbin/sshd -D
  10. Nov 25 08:31:59 centos7.qifei.com systemd[1]: Starting OpenSSH server daemon...
  11. Nov 25 08:32:00 centos7.qifei.com sshd[1053]: Server listening on 0.0.0.0 port 22.
  12. Nov 25 08:32:00 centos7.qifei.com sshd[1053]: Server listening on :: port 22.
  13. Nov 25 08:32:00 centos7.qifei.com systemd[1]: Started OpenSSH server daemon.
  14. Nov 25 08:42:37 centos7.qifei.com sshd[1647]: Accepted password for root from 192.168.109.1 port 51918 ssh2
  15. Nov 25 08:42:57 centos7.qifei.com sshd[1703]: Accepted password for root from 172.18.1.9 port 51920 ssh2

active(running):表示程序正在执行
atcive(exited):执行一次就正常退出的服务,不在系统中执行任何程序
active(waiting):正在执行中,不过要等其他服务执行完在继续执行
inactive : 服务关闭
disable :服务开机不启动
enable : 服务开机启动
static : 服务开机启动项被管理
failed: 服务配置错误

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注