Skip to content

Instantly share code, notes, and snippets.

@gladx
Created September 1, 2017 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gladx/e54ebdc55d25485e2bcfe1c07d5d2ced to your computer and use it in GitHub Desktop.
Save gladx/e54ebdc55d25485e2bcfe1c07d5d2ced to your computer and use it in GitHub Desktop.
how detect system ?
/usr/lib/systemd tells you you're on a systemd based system.
/usr/share/upstart is a pretty good indicator that you're on an Upstart-based system.
/etc/init.d tells you the box has SysV init in its history
----- OR
strings /sbin/init | grep -q "/lib/systemd" && echo SYSTEMD
strings /sbin/init | grep -q "sysvinit" && echo SYSVINIT
strings /sbin/init | grep -q "upstart" && echo UPSTART
----- OR
sudo stat /proc/1/exe
----------------------------- Systemctl to Manage Systemd Services and Units
systemd
لیست کردن همه واحد ها units شامل (mounts, service, jobs)
systemctl list-units
شروع کردن سرویس
systemctl start [NAME...]
استپ سرویس
systemctl stop [NAME...]
فعال کردن سرویس
systemctl enable [NAME...]
غیر فعال کردن سرویس
systemctl disable [NAME...]
نمایش وضعیت سرویس
systemctl status apache2.service
sudo systemctl restart application.service
sudo systemctl reload application.service
* نمایش وابستگی های سرویس
systemctl list-dependencies $service
systemctl list-dependencies apache2
------
لیست کردن همه سرویس ها
systemctl -t service
systemctl list-units --type=service
لیست کردن همه سرویس های فعال
systemctl -t service -a
نمایش همه
systemctl -a
systemctl
-------------
فعال کردن و غیر فعال کرده هنگام بوت
sudo systemctl enable application.service
sudo systemctl disable application.service
بررسی کردن وضعیت هنگام بوت
systemctl is-enabled application.service
systemctl is-enabled apache2.service
-------------
نمایش همه واحد های فعال
systemctl list-units --all --state=running
systemctl -t service --state=running
---------------------
sudo systemctl poweroff
sudo systemctl reboot
--------------------
دستورات کاربردی برای من
sudo systemctl disable mysql.service
sudo systemctl disable sshd.service
sudo systemctl disable ssh.service
sudo systemctl disable tor
sudo systemctl disable bluetooth.service
sudo systemctl disable openvpn.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment