Linux中的service命令

service命令,顾名思义,就是用于管理Linux操作系统中服务的命令。

这个命令不是在所有的linux发行版本中都有。主要是在redhat、fedora、mandriva和centos中。

此命令位于/sbin目录下,用file命令查看此命令会发现它是一个脚本命令。

分析脚本可知此命令的作用是去/etc/init.d目录下寻找相应的服务,进行开启和关闭等操作。

开启httpd服务器:service httpd start
start可以换成restart表示重新启动,stop表示关闭,reload表示重新载入配置。

关闭mysql服务器:service mysqld stop

强烈建议大家将service命令替换为/etc/init.d/mysqld stop (因为有一些linux的版本不支持service)

Usage: service < option > | –status-all | [ service_name [ command | –full-restart ] ]

service oracle start
service oracle stop
service oracle restart
service oracle status

service --status-all #显示所有服务的状态

[root@beanpc /]# service --status-all
abrtd (pid  1645) is running...
abrt-dump-oops (pid 1653) is running...
acpid (pid  1419) is running...
atd (pid  1692) is running...
auditd (pid  2511) is running...
automount (pid  1499) is running...
avahi-daemon (pid  1326) is running...
Usage: /etc/init.d/bluetooth {start|stop}
certmonger (pid  1836) is running...
Running
cgred is stopped
conmand is stopped
cpuspeed is stopped
crond (pid  5541) is running...
cupsd (pid  1394) is running...
dnsmasq (pid 1821) is running...
Generated by ebtables-save v1.0 on Sun Dec 27 07:34:24 CST 2015
*nat
:PREROUTING ACCEPT
:OUTPUT ACCEPT
:POSTROUTING ACCEPT

/usr/sbin/fcoemon -- UNUSED
No interfaces created.
firstboot is not scheduled to run
gpm is stopped
hald (pid  1428) is running...
JAVA_EXECUTABLE or HSQLDB_JAR_PATH in '/etc/sysconfig/hsqldb' is set to a non-file.
httpd is stopped
ip6tables: Firewall is not running.
iptables: Firewall is not running.
irqbalance is stopped
iscsi is stopped
iscsid is stopped
Kdump is not operational
ksm is not running
ksmtuned (pid  1669) is running...
ktune settings are not applied.
libvirtd (pid  1716) is running...
started
libvirt-qmf is stopped
lldpad is stopped
lvmetad is stopped
mailman is stopped
qpidd is stopped
matahari-qmf-hostd is stopped
matahari-qmf-networkd is stopped
matahari-qmf-rpcd is stopped
matahari-qmf-serviced is stopped
matahari-qmf-sysconfigd is stopped
matahari-qmf-sysconfig-consoled is stopped
Checking for mcelog
mcelog is stopped
mcstransd is stopped
mdmonitor is stopped
memcached is stopped
messagebus (pid  1301) is running...
mip6d is stopped
multipathd is stopped
mysqld is stopped
No open transaction
netconsole module not loaded
Configured devices:
lo eth0 eth1
Currently active devices:
lo eth0 eth1 virbr0
NetworkManager (pid  1312) is running...
rpc.svcgssd is stopped
rpc.mountd is stopped
nfsd is stopped
rpc.rquotad is stopped
rpc.statd (pid  1345) is running...
ntpd is stopped
numad is stopped
oddjobd is stopped
portreserve is stopped
master (pid  1621) is running...
Process accounting is disabled.
qpidd is stopped
quota_nld is stopped
radvd is stopped
rdisc is stopped
restorecond (pid  2750) is running...
rhsmcertd (pid 1807) is running...
rngd is stopped
rpcbind (pid  1274) is running...
rpc.gssd is stopped
rpc.idmapd (pid 1384) is running...
rpc.svcgssd is stopped
rsyslogd (pid  1226) is running...
sandbox is stopped
saslauthd is stopped
sfcb is not running
smartd is stopped
snmpd is stopped
snmptrapd is stopped
spice-vdagentd is stopped
openssh-daemon (pid  1539) is running...
sssd is stopped
No managed stap-server is running
Usage: /etc/init.d/stinit {start}
svnserve is stopped
No systemtap scripts are present
tuned is stopped
virt-who dead but subsys locked
Xvnc is stopped
vsftpd (pid 7820) is running...
wdaemon is stopped
wpa_supplicant (pid  1341) is running...
xinetd is stopped
ypbind is stopped
[root@beanpc /]# 
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值