下载PDF文件下载PDF文件

这篇文章教你如何在Linux中强制重启当前运行的服务。无论你的Linux类型是什么,只需几个简单的命令即可。

  1. How.com.vn 中文: Step 1 打开命令行。
    大多数Linux发行版在屏幕左下角都有一个菜单选项,你可以在菜单中找到叫做“终端”的应用程序;你需要打开这个应用程序才能显示命令行。
    • 由于Linux发行版的界面因版本而异,你可能需要在菜单文件夹中寻找“终端”或命令行应用程序。
    • 你可能会在桌面或者屏幕底部的工具栏里,而不是在菜单中找到“终端”应用程序。
    • 有些Linux发行版在屏幕的顶部或底部有一个命令行栏。
  2. How.com.vn 中文: Step 2 输入命令以显示当前运行的服务。
    在“终端”中输入ls /etc/init.d,并按Enter。这样就会显示当前运行服务的列表,及其相应的命令名称。
    • 如果这个命令不起作用,那就尝试ls /etc/rc.d/
  3. How.com.vn 中文: Step 3 找到要重启的服务的命令名称。
    通常可以在屏幕左侧找到服务的名称(例如,“Apache”),而命令名称(例如,“httpd”或“apache2”,取决于你的Linux发行版)会出现在屏幕右侧。
  4. How.com.vn 中文: Step 4 输入重启命令。
    在“终端”中输入sudo systemctl restart service,确保用服务的命令名称替换命令中的service部分,并按Enter
    • 例如,想要在Ubuntu Linux 中重启Apache,你需要在“终端”中输入sudo systemctl restart apache2
  5. How.com.vn 中文: Step 5 出现提示时输入密码。
    输入超级用户账户的密码,然后按Enter。这样就会重新启动进程。
    • 这样操作后,如果服务没有重启,尝试输入sudo systemctl stop service,按 Enter,然后输入sudo systemctl start service
    广告

小提示

  • 你可以使用“chkconfig”命令在系统启动时添加和删除服务。
  • 要查看电脑上所有目录中所有当前服务的完整列表,在“终端”中输入ps -A
广告

警告

  • 在尝试这个操作时,不要随意停止服务。有些服务是保持系统稳定和运行流畅所必需的。
广告

关于本How.com.vn

How.com.vn 中文: How.com.vn员工
共同创作者是 :
How.com.vn专职作家
这篇文章由我们训练有素的编辑和研究团队共同创作,他们对文章的准确性和全面性进行了验证。

How.com.vn的内容管理团队会严密监督编辑人员的工作,确保每篇文章都符合我们的高质量标准要求。 这篇文章已经被读过19,556次。
本页面已经被访问过19,556次。

这篇文章对你有帮助吗?

⚠️ Disclaimer:

Content from Wiki How 中文 language website. Text is available under the Creative Commons Attribution-Share Alike License; additional terms may apply.
Wiki How does not encourage the violation of any laws, and cannot be responsible for any violations of such laws, should you link to this domain, or use, reproduce, or republish the information contained herein.

Notices:
  • - A few of these subjects are frequently censored by educational, governmental, corporate, parental and other filtering schemes.
  • - Some articles may contain names, images, artworks or descriptions of events that some cultures restrict access to
  • - Please note: Wiki How does not give you opinion about the law, or advice about medical. If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.
  • - Readers should not judge the importance of topics based on their coverage on Wiki How, nor think a topic is important just because it is the subject of a Wiki article.

广告