Difference between revisions of "Service network restart"
m (→systemd) |
|||
(4 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
This relates to Linux System Process Initialization (SysV). | This relates to Linux System Process Initialization (SysV). | ||
− | + | The main purpose of init is to start and stop essential processes on the system. There are three major implementations of init in Linux, System V, Upstart and systemd. | |
+ | |||
+ | [[Linux Sys V]] starts and stops processes sequentially. Sys V scripts start and stop services referencing runlevels which are set from 0 to 6. | ||
+ | |||
+ | ==Sys V== | ||
service network restart | service network restart | ||
− | + | System V is on its way out with respect to Linux. | |
− | + | ==systemd== | |
+ | This system manager has replaced Sys V and uses new commands. | ||
+ | |||
+ | systemctl is command line utility and primary tool to manage the systemd daemons/services such as (start, restart, stop, enable, disable, reload & status). | ||
+ | |||
+ | systemd uses .service files Instead of bash scripts (SysVinit uses). systemd sorts all daemons into their own Linux cgroups and you can see the system hierarchy by exploring /cgroup/systemd file. | ||
+ | |||
+ | Rather than "'''service'''" we use "'''systemctl'''" which is short for 'system control' and is unfortunately a rather ugly command as one now has to keep straight an abbreviated phrase rather than a common English word. | ||
+ | |||
+ | Activate a service immediately: | ||
+ | systemctl start foo | ||
+ | |||
+ | Deactivate a service immediately: | ||
+ | systemctl stop foo | ||
+ | |||
+ | Restart a service: | ||
+ | systemctl restart foo | ||
+ | |||
+ | Show the status of a service including if it is running or not: | ||
+ | systemctl status foo | ||
+ | |||
+ | Enable a service to be started on bootup: | ||
+ | systemctl enable foo | ||
+ | |||
+ | Disable a service to not start during bootup: | ||
+ | systemctl disable foo | ||
+ | |||
+ | Prevent a service from starting dynamically or even manually unless unmasked: | ||
+ | systemctl mask foo | ||
+ | |||
+ | Check if a service is already enabled or not: | ||
+ | systemctl is-enabled foo | ||
== Redhat / Fedora / CentOS == | == Redhat / Fedora / CentOS == | ||
Line 26: | Line 61: | ||
== Debian / Ubuntu / Mint == | == Debian / Ubuntu / Mint == | ||
+ | |||
+ | How to restart network in Ubuntu Server: | ||
+ | |||
+ | /etc/init.d/networking restart script based command. | ||
Use service to run a System V init script such as networking. | Use service to run a System V init script such as networking. |
Latest revision as of 20:47, 1 October 2019
This relates to Linux System Process Initialization (SysV).
The main purpose of init is to start and stop essential processes on the system. There are three major implementations of init in Linux, System V, Upstart and systemd.
Linux Sys V starts and stops processes sequentially. Sys V scripts start and stop services referencing runlevels which are set from 0 to 6.
Sys V
service network restart
System V is on its way out with respect to Linux.
systemd
This system manager has replaced Sys V and uses new commands.
systemctl is command line utility and primary tool to manage the systemd daemons/services such as (start, restart, stop, enable, disable, reload & status).
systemd uses .service files Instead of bash scripts (SysVinit uses). systemd sorts all daemons into their own Linux cgroups and you can see the system hierarchy by exploring /cgroup/systemd file.
Rather than "service" we use "systemctl" which is short for 'system control' and is unfortunately a rather ugly command as one now has to keep straight an abbreviated phrase rather than a common English word.
Activate a service immediately:
systemctl start foo
Deactivate a service immediately:
systemctl stop foo
Restart a service:
systemctl restart foo
Show the status of a service including if it is running or not:
systemctl status foo
Enable a service to be started on bootup:
systemctl enable foo
Disable a service to not start during bootup:
systemctl disable foo
Prevent a service from starting dynamically or even manually unless unmasked:
systemctl mask foo
Check if a service is already enabled or not:
systemctl is-enabled foo
Redhat / Fedora / CentOS
CentOS 7 restart network service
In centos 7 or RHEL7, the network service name is changed to “network.service“, issue the following systemctl command to restart network service on your current system:
systemctl restart network.service
or
systemctl restart network
To check the status of network service, run the following command:
systemctl status network.service
Debian / Ubuntu / Mint
How to restart network in Ubuntu Server:
/etc/init.d/networking restart script based command.
Use service to run a System V init script such as networking.
service restart networking
Debian 6 : command error /etc/init.d/networking restart is deprecated because it may not enable again some interfaces
command error /etc/init.d/networking restart is deprecated because it may not enable again some interfaces
Restart networking for the latest version of Ubuntu server.
systemctl restart networking
To start networking service, enter :
sudo /etc/init.d/networking start
OR
sudo service networking start
To stop networking service, enter:
sudo /etc/init.d/networking stop
OR
sudo service networking stop
A note about desktop users
If above command failed, try the following command:
sudo service network-manager restart
OR systemd based Ubuntu system (latest version:
sudo systemctl restart network-manager