How do I start a network service in Ubuntu?

last updated in Categories ,

I am a new Ubuntu Linux server user and my server located in Amazon data center. How do I start a network service in Ubuntu Linux using the command line?

Ubuntu Linux comes with CLI and graphical utilities to configure your network devices. However, as a server administrators, you need to focus on managing your network on the command line. This page shows how to start, stop, and restart networking service on Ubuntu Linux using the CLI.

Command to start a network service in Ubuntu

The syntax is as follows for the latest version of Ubuntu Linux:
sudo systemctl start networking.service

How do I restart a network service in Ubuntu?

sudo systemctl restart networking.service

How do I stop a network service in Ubuntu?

sudo systemctl stop networking.service

A note about older version of Ubuntu Linux

Try the following syntax to start, stop and restart networking service:
sudo /etc/init.d/networking start
sudo /etc/init.d/networking stop
sudo /etc/init.d/networking restart

Let us see all commands and example in details.

Ubuntu start a network service and see status

List your network interfaces using the ip command:
ip a
ip a s eth0
ip a s ens3

Command to start a network service in Ubuntu Linux

How to view networking configrations

Run the following cat command:
cat /etc/network/interfaces
Sample outputs:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
 
source /etc/network/interfaces.d/*
 
# The loopback network interface
auto lo
iface lo inet loopback
 
# The primary network interface
auto ens3
iface ens3 inet static
	address 192.168.122.17
	gateway 192.168.122.1

How do I change or edit network configuration on Ubuntu?

Edit the /etc/network/interfaces file using a text editor such as vim command/nano command:
sudo nano /etc/network/interfaces
OR
sudo vi /etc/network/interfaces
Once file updated, restart networking service, run:
sudo systemctl restart networking.service

How do I see status of networking service on Ubuntu?

Simply run the following command at the CLI:
sudo systemctl status networking.service
Ubuntu start a network service command

Conclusion

This page showed how to start, restart and stop the networking service on an Ubuntu Linux system using the command line. For more info see this page here.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Start the discussion at www.nixcraft.com

Historical Comment Archive