页面“Debian服务器初始化”与“Debian 添加自启动服务”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
(导入1个版本)
 
docker>Evan
 
第1行: 第1行:
  <pre>
+
== update-rc.d 方式==
useradd -d /data/evan -s /bin/bash -m evan
+
<pre>在基于Debian的发行版中你可以使用 update-rc.d:
数m表示如果该目录不存在,则创建该目录
+
update-rc.d mysql defaults
 +
sudo update-rc.mysql start 20 3 4 5 . stop 20 0 1 2 6 .
  
 +
run 'update-rc.d -f uwsgi defaults', or use the appropriate command on your
  
apt install net-tools vim
+
sudo service mysql start
 +
sudo python manage.py runserver 192.168.1.158:80
 +
</pre>
 +
== systemctl方式==
 +
<pre>
 +
如何激活服务并在启动时启用或禁用服务(即系统启动时自动启动服务)
 +
#启动
 +
systemctl enable  vsftpd
 +
# systemctl enable ssh.service
 +
# systemctl disable ssh.service
  
安装Fail2Ban
+
  systemctl is-active ssh.service # 这个 试过不可以 一开始还以为是查看
  </pre>
 
  
[https://www.debian.cn/archives/2880 Debian 安装 fail2ban 方式SSH爆破攻击]
 
  
 +
如何屏蔽(让它不能启动)或显示服务(如 httpd.service)
 +
# systemctl mask httpd.service
 +
ln -s '/dev/null' '/etc/systemd/system/httpd.service'
 +
# systemctl unmask httpd.service
 +
rm '/etc/systemd/system/httpd.service'
 +
</pre>
  
[[Debian配置iptables]]
+
==参考==
=参考=
+
MariaDB的自动启动与停止
 +
https://mariadb.com/kb/zh-cn/iniciando-e-parando-mariadb-automaticamente/
  
[https://blog.51cto.com/wzlinux/2043586 Ubuntu 新装服务器部署流程]
+
http://wenzhixin.net.cn/2013/10/30/debian_script_init
  
[https://www.howtoing.com/install-java-in-debian-and-ubuntu 如何在Debian和Ubuntu系统中安装Java 9]
+
http://www.cnblogs.com/ac1985482/p/4046355.html
  
[http://www.ruanyifeng.com/blog/2014/03/server_setup.html Linux服务器的初步配置流程]
+
 [[category:ops]]  [[category:linux]]
 
 
[http://spenserj.com/blog/2013/07/15/securing-a-linux-server/ Securing a Linux Server]
 
 
 
[http://blog.51cto.com/feihan21/1060365 Linux服务器初始化配置脚本]
 
 
 
[https://blog.imdst.com/linux-fu-wu-qi-chu-shi-hua-an-quan-jia-gu/ Linux服务器初始化调优及安全加固]
 
 
 
[https://linux.cn/article-5067-1.html 如何使用 fail2ban 防御 SSH 服务器的暴力破解攻击]
 
 
 
[https://blog.csdn.net/developerinit/article/details/73065229?utm_source=blogxgwz7 Debian的一些常用命令]
 
[[category:ops]] [[category:debian]]
 

2019年3月9日 (六) 14:56的版本

update-rc.d 方式

在基于Debian的发行版中你可以使用 update-rc.d:
update-rc.d mysql defaults
sudo update-rc.d  mysql  start 20 3 4 5 . stop 20 0 1 2 6 .

run 'update-rc.d -f uwsgi defaults', or use the appropriate command on your

sudo service mysql start
sudo python manage.py runserver 192.168.1.158:80

systemctl方式

如何激活服务并在启动时启用或禁用服务(即系统启动时自动启动服务)
#启动
systemctl enable  vsftpd
# systemctl enable ssh.service
# systemctl disable ssh.service

 systemctl is-active ssh.service # 这个 试过不可以 一开始还以为是查看


如何屏蔽(让它不能启动)或显示服务(如 httpd.service)
# systemctl mask httpd.service
ln -s '/dev/null' '/etc/systemd/system/httpd.service'
# systemctl unmask httpd.service
rm '/etc/systemd/system/httpd.service'

参考

MariaDB的自动启动与停止 https://mariadb.com/kb/zh-cn/iniciando-e-parando-mariadb-automaticamente/

http://wenzhixin.net.cn/2013/10/30/debian_script_init

http://www.cnblogs.com/ac1985482/p/4046355.html