7

What is the command for enabling networking and wireless using command line?

I have made a script that delays the startup apps for quicker boot times.

I have learned that disabling networking also helps in a quicker boot time.

I would like to add a command that shall enable networking and wireless in the shell script.

1
  • If the networking start answer makes stuff crash, it could be your delay script does something funky. Maybe you want to post the script, so we can see what you did ;)
    – Nanne
    Oct 28, 2012 at 10:27

3 Answers 3

5

Are you looking for sudo service networking start ?

I believe network-manager handles the networking and interface on Ubuntu 12.04 so it should be like:

sudo service network-manager start

[EDIT]
Just an update in support of my comment below, for automating SUDO when piping the password to it from external source use:

echo "password" | sudo -S service network-manager start

Which will not ask for the password interactively.

-S Switch here make sudo to read the password from standard input and not from terminal.

9
  • nope...error is-----> start: Rejected send message, 1 matched rules; type="method_call", sender=":1.94" (uid=1000 pid=6820 comm="start network-manager ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")
    – Nirmik
    Oct 27, 2012 at 6:05
  • @Nirmik Sorry for this late reply, anyway.. Please have a look above I have updated the commands. You need to run it under elevated privileges.
    – Gufran
    Oct 28, 2012 at 10:21
  • also, if you want to automate the script for sudo whick will not proceed without the admin password you can store the password in script file like this echo "p@$$w0rD" | sudo service network-manager start
    – Gufran
    Oct 28, 2012 at 10:29
  • okay the sudo thing workd but the later part you said about 'echo "the password" | command' is not working as a command when i tried to test it in the commandline
    – Nirmik
    Oct 28, 2012 at 14:05
  • 1
    Note: If you write password in the command, it will remain in the command history.
    – nekketsuuu
    May 5, 2018 at 23:29
4

When using NetworkManager (its service running) there is no need for sudo to enable/disable networking.

Use nmcli:

nmcli networking {on | off | connectivity}

connectivity get network connectivity state (full/none...).

Just for WiFi:

nmcli radio wifi {on | off}
1
  • Sometimes you need to start network-manager first, and then you can execute your command. To start networkmanager execute sudo service network-manager start
    – titusfx
    Feb 16, 2021 at 12:33
1

to start network

sudo /etc/init.d/networking start

to stop

sudo /etc/init.d/networking stop

to restart

sudo /etc/init.d/networking restart

Source

2
  • nope! it crashed whole of unity! :(
    – Nirmik
    Oct 27, 2012 at 6:06
  • Unity crash ? hmm strange issue . hope some one will help you
    – Raja G
    Oct 27, 2012 at 6:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .