@mrz1
2018-01-07T10:09:49.000000Z
字数 2493
阅读 1044
Linux系统管理命令
[root@centos7 x86_64]#sed -i.bak 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config
[root@centos7 x86_64]#setenforce 0 //修改完生效
[root@centos7 x86_64]#getenforce
Permissive
[root@centos7 x86_64]#iptables -nvL 查看有没有开启如果有东西就开启了
[root@centos7 x86_64]#systemctl stop firewalld 现在关闭
[root@centos7 x86_64]#systemctl disable firewalld 下次开机不要启动
[root@centos6 ~]#sed -i.bak 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config
[root@centos6 ~]#setenforce 0 //修改完生效
[root@centos6 ~]#getenforce
Permissive
[root@centos6 ~]#chkconfig iptables off
[root@centos6 ~]#service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[root@centos6 ~]#iptables -nvL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
开启一个服务 : 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 root@172.254.23.111
root :是登录主机所属用户
172.254.23.111:主机的ip地址
这个方式是以登录密码的方式,其中最后一行输入密码。
在登录之前,主机要执行一下步骤开始ssh服务
systemctl stop firewalls.service ##关闭防火墙
ystemctl start sshd ##开启ssh服务
[root@centos7 app]#systemctl status sshd
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2017-11-25 08:32:00 CST; 3h 15min ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 1053 (sshd)
CGroup: /system.slice/sshd.service
└─1053 /usr/sbin/sshd -D
Nov 25 08:31:59 centos7.qifei.com systemd[1]: Starting OpenSSH server daemon...
Nov 25 08:32:00 centos7.qifei.com sshd[1053]: Server listening on 0.0.0.0 port 22.
Nov 25 08:32:00 centos7.qifei.com sshd[1053]: Server listening on :: port 22.
Nov 25 08:32:00 centos7.qifei.com systemd[1]: Started OpenSSH server daemon.
Nov 25 08:42:37 centos7.qifei.com sshd[1647]: Accepted password for root from 192.168.109.1 port 51918 ssh2
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: 服务配置错误