-
2021-06-11 13:49:00
一般情况下只要知道软件名字就行了比例
$ service nginx stop #关闭 $ service nginx start #启动 $ service nginx restart #重启
$ service php-fpm-70 stop $ service php-fpm-70 start $ service php-fpm-70 restart
如果出现找不到该服务,那大概率名字是不对的,下面方法找到名字,自由的玩耍去吧
$ cd /usr/lib/systemd/system $ ll
更多相关内容 -
Linux系统安装Tomcat并配置Service启动关闭
2021-01-09 00:37:13在Linux系统下配置service启动和关闭 1, 通过命令cd /etc/init.d文件夹下 2, 再通过命令 vim tomcat 进入vim编辑界面 3,用过 i键 现在把下面代码贴入编辑界面 shell脚本如下 #!/bin/bash # This is the ... -
在Linux中利用Service启动、停止jar,配置开机自启
2021-01-09 03:33:28#description: test service .... LANG=en_US.UTF-8 #设置编码utf-8 export LANG export JAVA_HOME=/usr/java/jdk1.8.0_231-amd64 export JRE_HOME=/$JAVA_HOME/jre export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar -
linux service命令
2021-05-11 06:18:32service命令,顾名思义,就是用于管理Linux操作系统中服务的命令。1. 声明:这个命令不是在所有的linux发行版本中都有。主要是在redhat、fedora、mandriva和centos中。2. 此命令位于/sbin目录下,用file命令查看此...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: [ 确定 ]
[root@node34 root]#
-
linux关闭服务命令
2021-05-09 00:53:21在linux中关闭一些没有的服务可以释放系统资源,那么我们要怎么关闭服呢?下面由学习啦小编为大家整理了linux关闭服务的相关命令,希望对大家有所帮助。1.linux关闭服务原因服务器的本质是为各种服务提供访问功能。使...在linux中关闭一些没有的服务可以释放系统资源,那么我们要怎么关闭服呢?下面由学习啦小编为大家整理了linux关闭服务的相关命令,希望对大家有所帮助。
1.linux关闭服务原因
服务器的本质是为各种服务提供访问功能。使服务器只运行所需的服务,关闭没有使用的服务。这样做不仅会释放一些系统资源,而且也会使服务器变得更加安全。比如,如果只是运行一个简单的服务器,显然不需要X显示或者桌面环境。如果不需要Windows网络共享功能,则可以放心关闭Samba。
2.linux关闭服务命令
使用下面的命令能查看伴随系统启动而启动的服务:
代码如下:
chkconfig --list | grep "3:on"
如果系统运行了systemd,执行这条命令:
代码如下:
systemctl list-unit-files --type=service | grep enabled
然后使用下面的命令关闭服务:
代码如下:
chkconfig service off
或
代码如下:
systemctl disable service
在上面的例子中,把“service”替换成真正想要停止的服务名称。实例如下:
代码如下:
chkconfig httpd off
或
代码如下:
systemctl disable httpd
-
Linux Service文件
2021-05-09 08:54:09从service文件说起之前的linux系统,从开机到启动初始化进程,要经过:BIOS -> Boot Loader -> 加载系统内核 -> 对内核初始化 -> 启动初始化进程,提供工作环境现有的systemd采用了并发启动机制,提升了...从service文件说起
之前的linux系统,从开机到启动初始化进程,要经过:
BIOS -> Boot Loader -> 加载系统内核 -> 对内核初始化 -> 启动初始化进程,提供工作环境
现有的systemd采用了并发启动机制,提升了开机速度。它将原来的初始化进程改为了systemd管理下的目标.target,并用systemctl来管理服务。
service服务启动关闭过程
1.设置httpd服务开机启动
systemctl enable httpd
返回信息
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
可以看到这里是在/etc/下那个目录创建了一个软链接(symbolic link)从/usr/lib/...里,没说反,下面有验证
2.查看服务状态
systemctl status httpd
返回信息
Active:inactive(dead)
3.启动服务
systemctl start httpd
状态更新为
active (running)
相比之前还多了
Main PID:1079(httpd)
status:"Processing requests..."
Tasks:6
Memory:2.9M
CGroup:...(每个httpd化进程占用的端口号和状态)
4.停止httpd服务
systemctl stop httpd.service
再次查看status变回inactive了
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Sat 2020-07-25 09:23:48 CST; 2s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 3578 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
Process: 1079 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=0/SUCCESS)
Main PID: 1079 (code=exited, status=0/SUCCESS)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
如果停不下来了,用kill杀掉
systemctl kill httpd.service
5.前面设置了开机启动,现在把它关掉
systemctl disable httpd
返回结果
Removed symlink /etc/systemd/system/multi-user.target.wants/httpd.service.
就是把创建的软链接删除了
6.[.server]文件里面是什么
cat httpd.server
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target 启动顺序
Documentation=man:httpd(8)
Documentation=man:apachectl(8)
[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/httpd 读取自己的环境参数
ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND 启动进程时执行的命令
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful $OPTIONS来自上面环境参数文件
ExecStop=/bin/kill -WINCH ${MAINPID}
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
KillSignal=SIGCONT
PrivateTmp=true
[Install]
WantedBy=multi-user.target 表示httpd服务所在的Target(服务组)
它分为3个模块:
[Unit]是启动顺序和依赖关系,如果有Wants或Requires字段代表依赖关系
[Service]是启动的行为
[install]是如何安装这个配置文件
.server文件还有很多东西,这里就针对httpd说一下,剩下的遇到了再研究
验证:查看下步骤1.enable里的目录
插一句,简单说下软链接的创建
ln -s file file_ln
-s 创建软链接 没有这个参数就是创建硬链接
接下来先去看下它操作的.service文件
cd /etc/systemd/system/multi-user.target.wants
ll
显示为lrwxrwxrwx的链接文件,原文件在/usr/lib/systemd/system/里
再到/usr/lib/systemd/system/里,找到了httpd.service
-rw-r--r-- 1 root root 752 Nov 27 2019 httpd.service
-
Linux之service命令基本使用
2021-05-23 19:00:14服务(service) 本质就是进程,但是是运行在后台的,通常都会监听某个端口,等待其它程序的请求,比如(mysqld , sshd、防火墙等),因此我们又称为守护进程,是 Linux 中非常重要的知识点。 【原理图】 1.2 service ... -
linux 服务注册 service文件 在service文件中设置变量和环境变量
2021-05-10 11:00:55[Unit]Description= #服务描述After=syslog.target #服务启动依赖[Service]Type=forking #服务启动类型 可选类型有simple forkingEnvironment="LD_LIBRARY_PATH=path" #设置变量ExecStart= #启动命令ExecStop= ... -
linux 开机启动方法之service
2021-07-31 18:05:15linux服务管理有两种方式**service**和**systemctl** `/lib/systemd/system/` 和 `/etc/systemd/system` 存放所有可用的单元文件 手动创建一个开机启动脚本,开机自动执行`/home/book/test_qt_whail/server/sh.sh`... -
linux 之.service文件简介
2021-11-18 16:04:35linux 之.service文件简介 什么是.service文件? Linux中.service文件是某项服务对应的配置文件,可用于systemd管理和控制的服务的设置。 .service 文件通常包含3个模块,即[Unit]控制单元,表示启动顺序和依赖... -
Linux中service文件详解
2021-07-02 09:34:50systemd service是一种以 .service 结尾的配置文件,是一个专用于 Linux 操作系统的系统与服务管理器。简单来说,用于后台以守护精灵(daemon)的形式运行程序。 systemd 服务的内容主要分为三个部分,控制单元 ... -
Linux中的service命令的详细解释
2021-05-13 16:11:02一、Linux中的service命令的详细解释service命令是Redhat Linux兼容的发行版中用来控制系统服务的实用工具,它以启动、停止、重新启动和关闭系统服务,还可以显示所有系统服务的当前状态。语法service(选项)(参数)选... -
Linux service命令
2019-06-18 09:48:49service命令是Redhat Linux兼容的发行版中用来控制系统服务的实用工具,它以启动、停止、重新启动和关闭系统服务,还可以显示所有系统服务的当前状态。 1.1 语法 service(选项)(参数) 1.2 选项 选项 描述 ... -
linux的service命令无法使用解决方法
2021-05-09 04:40:55下面由学习啦小编为大家整理了linux下service命令无法使用的相关知识,希望对大家有帮助!linux下service命令无法使用的解决方法一在linux上运行service https start,响应service command not found后来google了一下... -
linux查看防火墙状态和开启、关闭防火墙命令-service方式
2018-02-06 15:40:28查看防火墙状态: service iptables status防火墙开启状态防火墙关闭状态关闭防火墙命令:service iptables stop开启防火墙命令:service iptables startiptables方式可以查看参考博文参考博客:... -
Linux关闭防火墙-iptables|iptable.service could not be found
2022-03-16 22:24:20事后定位是服务部署的Linux默认启动了防火墙,没有关闭、以至于服务不能访问。后来、这个命令就印在脑袋瓜了。动手学学看吧~~1、使用命令「service iptable status」查看当前防火墙状态、Redire -
Linux 服务管理两种方式service和systemctl
2021-07-25 13:24:55文章目录service命令systemctl命令systemctl命令兼容了servicesystemctl命令管理systemd的资源Unit.mount文件.service文件.target文件.wants文件 service命令 service命令其实是去/etc/init.d目录下,去执行相关程序... -
linux 之.service文件简介 (新版systemctl服务)
2021-12-02 17:02:25Linux中.service文件是某项服务对应的配置文件,可用于systemd管理和控制的服务的设置。 .service 文件通常包含3个模块, 即[Unit]控制单元,表示启动顺序和依赖关系; [Service]服务,表示服务的定义; ... -
linux查看防火墙是否关闭的实例方法
2021-01-09 04:04:46推荐教程:linux教程 二、iptables方式 先进入init.d目录,命令如下: [root@centos6 ~]# cd /etc/init.d/ [root@centos6 init.d]# 然后查看防火墙状态: [root@centos6 init.d]# /etc/init.d/iptables status ... -
linux service命令解析(重要)
2019-07-04 06:28:36我们平时都会用service xxx start来启动某个进程,那么它背后究竟执行了什么? 其实service的绝对路径为/sbin/service ,打开这个文件cat /sbin/service,我们会发现其实它就是一个很普通的shell脚本: [root@zejin... -
Linux服务怎么重启与关闭之service命令
2021-05-10 16:14:401. Linux管理服务工具之service简介本文主要是讲解service命令的功能与日常使用方法,该命令是红帽兼容系列的发行版中用来控制系统服务的实用工具,它以启动、停止、重新启动和关闭系统服务,还可以显示所有系统服务... -
linux中systemctl命令理解以及.service文件参数解析
2022-05-12 11:39:14linux中systemctl命令理解以及.service文件参数解析一、systemctl介绍二、利用.service文件管理程序的步骤三、.service配置文件参数详解1. Unit2. Service3. Install四、systemctl命令详解四、参考 一、systemctl... -
linux查看防火墙状态与开启关闭命令详解
2021-01-10 07:06:43linux查看防火墙状态与开启关闭命令有以下两种方式: 一、service方式 查看防火墙状态: [root@centos6 ~]# service iptables status iptables:未运行防火墙。 开启防火墙: [root@centos6 ~]# service iptables ... -
Linux自定义service
2020-01-17 16:23:38新建一个文件,如 eureka.service [Unit] Description=My Service After=syslog.target [Service] #/usr/lib/systemd/system #工作目录 WorkingDirectory=/www/java/yml #java指令 ExecStart=/usr/bin/ja... -
linux系统关掉网卡命令_如何关闭Linux系统?
2020-10-13 18:57:30linux系统关掉网卡命令I am new to Linux and I have installed some Linux distributions. I try to learn bash commands. I can shutdown my computer from Desktop manager easily. But How can I shutdown ... -
Linux中systemd的service文件说明
2021-03-14 01:38:04历史版本中的linux对服务的操作是通过service来完成的。若创建用户自定义的服务,则需要较为复杂的操作。目前linux新的发行版已经内置了systemctl来操作服务。 一、systemd有系统和用户区分 系统(/user/lib/systemd... -
停止linux机器的auditd.service
2022-04-30 07:16:56所以绝对停掉auditd.service服务看看。 但这个服务的service文件配置了,RefuseManualStop=yes,是不允许手动停止的。 所以需要这里RefuseManualStop=yes 改成no,然后操作。 ansible all-lin... -
Linux下service xxx start/stop/restart启动服务、关闭服务、重启服务深入理解@
2018-07-12 19:22:05Linux下启动服务通常有两种方法使用service xxx start/ stop/restart /status启动服务 实际上是运行的/etc/init.d/目录之下的脚本 /etc/init.d/目录下发现下面都是shell脚本,脚本里面运行的程序最终还是指向了... -
Linux守护进程service Daemon 【C语言构建简单的守护进程】
2022-03-25 11:42:03Linux Daemon Writing HOWTO 1 什么是守护进程? 守护进程是后台运行,自动运行,少交互或不交互。 守护进程(或服务)是一个后台进程,设计为自动运行,几乎不需要用户干预。ApacheWeb服务器http守护程序(httpd)...