Networking-Forums.com

Professional Discussions => Programming Goodies and Software-Defined Networking => Topic started by: nikolaymartin on April 29, 2020, 08:19:22 AM

Title: Stop network service with init.d For Ubuntu
Post by: nikolaymartin on April 29, 2020, 08:19:22 AM
How can I stop the networking service by using init.d for the Ubuntu operationg system?
Title: Re: Stop network service with init.d For Ubuntu
Post by: deanwebb on April 29, 2020, 10:14:38 AM
I don't know much on Linux, but want to learn... my question is why does it need to be with the init.d (and I admit I don't know what that is for) and not "service networking stop"?

I see this for HPUX:

# /sbin/init.d/net stop
# /sbin/init.d/net start
# /sbin/init.d/hostname start

And then this for Ubuntu:
# service networking stop
# service networking start
# service networking restart

Is init.d a different package or something?
Title: Re: Stop network service with init.d For Ubuntu
Post by: Otanx on April 29, 2020, 11:28:18 AM
init.d vs systemd is one of the Linux holy wars going on. Kind of like vi vs emacs (I use vi, but whatever works for you), or tabs vs spaces for developers(spaces only, tabs are wrong). I don't get that deep into it to care, or really understand the issues. For this either of the two options above by Dean will work. The final one that was introduced with systemd is "systemctl stop networking" to stop the service. Basically it acts just like the service command, but flips the options. Even on systemd the service command still works. At least for what I need it to.

-Otanx
Title: Re: Stop network service with init.d For Ubuntu
Post by: edizgeorgi on April 30, 2020, 07:03:40 AM
There are different ways. You can also use the systemd but as you are asking for init.d use the following command.
sudo /etc/init.d/networking start
Reference: https://www.networking-forums.com/programming-goodies-and-software-defined-networking/stop-network-service-with-init-d-for-ubuntu

Title: Re: Stop network service with init.d For Ubuntu
Post by: deanwebb on April 30, 2020, 10:22:35 AM
So why would I want to use init.d over systemd? Is it just preference or is one easier to work with in scripts/API calls/something else?
Title: Re: Stop network service with init.d For Ubuntu
Post by: Otanx on April 30, 2020, 10:53:46 AM
I don't understand it 100%, but my understanding is it is a change in the architecture of Linux. If you are an init.d person the argument is that the idea behind Linux is a lot of small programs that work together to make a greater whole. This is how init.d works. There isn't one binary that does eveything. It just calls a lot of smaller programs that do their one thing very well. However, systemd actually consolidates a lot of these smaller programs into a monolithic program.

The thing is you are not really going to pick init.d over systemd. You are going to pick your distro, and whatever that distro is using is what you are going to use. So if you are a Redhat shop you will be using systemd. If you are writing services to run on a system then you are going to write your service to support whatever distro your application runs on or you just write for both(I am not really sure if there is a difference here or not).

For most users it isn't going to matter. Even specifically for this thread you are going to use either service networking restart, or systemctl restart networking. One will work, the other won't. On the systemd systems I have used they even have the service command, and it spits out a message about using systemctl, and runs systemctl for you.

-Otanx
Title: Re: Stop network service with init.d For Ubuntu
Post by: Dieselboy on May 01, 2020, 01:47:34 AM
Must be a really REALLY old ubuntu version? AFAIK it should be `systemctl` like `systemctl stop network`