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

1. 声明:这个命令不是在所有的linux发行版本中都有。主要是在redhat、fedora、mandriva和centos中。
2. 此命令位于/sbin目录下,用file命令查看此命令会发现它是一个脚本命令。
3. 分析脚本可知此命令的作用是去/etc/init.d目录下寻找相应的服务,进行开启和关闭等操作。
4. 开启httpd服务器:service httpd start
start可以换成restart表示重新启动,stop表示关闭,reload表示重新载入配置。
5. 关闭mysql服务器:service mysqld stop
6. 强烈建议大家将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
示例一 网络重启
当修改了主机名、ip地址等信息时,经常需要把网络重启使之生效。
[root@node34 root]# service network 
用法:/etc/init.d/network {start|stop|restart|reload|status} 
[root@node34 root]# service network status 
配置设备: 
lo eth0 
当前的活跃设备: 
lo eth0 
[root@node34 root]# service network restart 
正在关闭接口 eth0:                                        [  确定  ] 
关闭环回接口:                                             [  确定  ] 
设置网络参数:                                             [  确定  ] 
弹出环回接口:                                             [  确定  ] 
弹出界面 eth0:                                            [  确定  ]
示例二 重启MySQL
[root@node34 root]# service mysql
mysql: unrecognized service
[root@node34 root]# service mysqld
用法:/etc/init.d/mysqld {start|stop|status|condrestart|restart}
[root@node34 root]# service mysqld status
mysqld (pid 1638) 正在运行...
[root@node34 root]# service mysqld restart
停止 MySQL:                                               [  确定  ]
启动 MySQL:                                               [  确定  ]

linux service命令常见使用方法的更多相关文章

  1. Linux awk命令常见使用方法介绍

    Linux awk命令常见使用方法介绍 By:授客 QQ:1033553122   awk运行方式有三种,其中常用的为命令行方式 awk [-F  field_separator]  '{patter ...

  2. 详述Linux ftp命令的使用方法

    转自:http://os.51cto.com/art/201003/186325.htm ftp服务器在网上较为常见,Linux ftp命令的功能是用命令的方式来控制在本地机和远程机之间传送文件,这里 ...

  3. Linux ftp命令的使用方法 -- 转

    http://jingyan.baidu.com/article/066074d68b6a7ac3c21cb038.html FTP(File Transfer Protocol, FTP)是TCP/ ...

  4. Linux service命令

    service命令(其实与其说是命令,不如说是脚本),因为service本身就是一个脚本,这个脚本在/sbin路径下,待后续shell脚本功底好了将去认真去看看这个脚本的内容(可不能被人忽悠了.) s ...

  5. 【转载】linux tail命令的使用方法详解

    本文介绍Linux下tail命令的使用方法.linux tail命令用途是依照要求将指定的文件的最后部分输出到标准设备,通常是终端,通俗讲来,就是把某个档案文件的最后几行显示到终端上,假设该档案有更新 ...

  6. linux tail命令的使用方法详解(转)

    本文介绍Linux下tail命令的使用方法.linux tail命令用途是依照要求将指定的文件的最后部分输出到标准设备,通常是终端,通俗讲来,就是把某个档案文件的最后几行显示到终端上,假设该档案有更新 ...

  7. linux tail命令的使用方法详解 (转载)

    本文介绍Linux下tail命令的使用方法.linux tail命令用途是依照要求将指定的文件的最后部分输出到标准设备,通常是终端,通俗讲来,就是把某个档案文件的最后几行显示到终端上,假设该档案有更新 ...

  8. linux tail命令的使用方法详解

    本文介绍Linux下tail命令的使用方法. linux tail命令用途是依照要求将指定的文件的最后部分输出到标准设备,通常是终端,通俗讲来,就是把某个档案文件的最后几行显示到终端上,假设该档案有更 ...

  9. linux service命令解析(重要)

    我们平时都会用service xxx start来启动某个进程,那么它背后究竟执行了什么? 其实service的绝对路径为/sbin/service ,打开这个文件cat /sbin/service, ...

随机推荐

  1. poj.1988.Cube Stacking(并查集)

    Cube Stacking Time Limit:2000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I64u Submi ...

  2. linux 输出重定向一份到本地文件,屏幕继续输出

    ls -al 2>&1 | tee xLog

  3. 在 2017 年将会更加流行的 6 个 Web 开发趋势

    2016即将过去,2017就要来临. 前阵子看到很多对2016前端领域的总结,也是有人欢喜有人忧啊. 转发了这一篇2017web的发展趋势.那么到底会是怎么样的一个发展趋势的,只好拭目以待了. 201 ...

  4. [codeforces 339]C. Xenia and Weights

    [codeforces 339]C. Xenia and Weights 试题描述 Xenia has a set of weights and pan scales. Each weight has ...

  5. 如何用C语言编写病毒‘

    怎样用C语言编写病毒在分析病毒机理的基础上,用C语言写了一个小病毒作为实例,用TURBOC2.0实现.[Abstract] This paper introduce the charateristic ...

  6. python tkinter用Treeview实现ListView效果

    先上图 再上代码: import ttk from Tkinter import * root = Tk() tree = ttk.Treeview(root, columns=('col1','co ...

  7. WebRTC

    WebRTC,名称源自网页实时通信(Web Real-Time Communication)的缩写,是一个支持网页浏览器进行实时语音对话或视频对话的技术,是谷歌2010年以6820万美元收购Globa ...

  8. Graph Valid Tree

    Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), ...

  9. How to take partial screenshot with Selenium WebDriver in python

    from selenium import webdriver from PIL import Image fox = webdriver.Firefox() fox.get('http://stack ...

  10. Unity3d《Shader篇》Logo闪光特效

    Shader "Custom/Flash" { Properties { _MainTex ("Base (RGB)", 2D) = "white&q ...