Stop network service with init.d For Ubuntu

Started by nikolaymartin, April 29, 2020, 08:19:22 AM

Previous topic - Next topic

nikolaymartin

How can I stop the networking service by using init.d for the Ubuntu operationg system?

deanwebb

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?
Take a baseball bat and trash all the routers, shout out "IT'S A NETWORK PROBLEM NOW, SUCKERS!" and then peel out of the parking lot in your Ferrari.
"The world could perish if people only worked on things that were easy to handle." -- Vladimir Savchenko
Вопросы есть? Вопросов нет! | BCEB: Belkin Certified Expert Baffler | "Plan B is Plan A with an element of panic." -- John Clarke
Accounting is architecture, remember that!
Air gaps are high-latency Internet connections.

Otanx

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

edizgeorgi

#3
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


deanwebb

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?
Take a baseball bat and trash all the routers, shout out "IT'S A NETWORK PROBLEM NOW, SUCKERS!" and then peel out of the parking lot in your Ferrari.
"The world could perish if people only worked on things that were easy to handle." -- Vladimir Savchenko
Вопросы есть? Вопросов нет! | BCEB: Belkin Certified Expert Baffler | "Plan B is Plan A with an element of panic." -- John Clarke
Accounting is architecture, remember that!
Air gaps are high-latency Internet connections.

Otanx

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

Dieselboy

Must be a really REALLY old ubuntu version? AFAIK it should be `systemctl` like `systemctl stop network`