Command for enabling networking?

47,979

Solution 1

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.

Solution 2

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}
Share:
47,979

Related videos on Youtube

Nirmik
Author by

Nirmik

A true LINUX lover and APPLE fan!! An aspiring OS DEVELOPER i love to work on linux. :) With an encounter with linux from the past 1year,I have definitely succeded in creating a LINUX community around with many friends. Love LINUX for every bit of it..!! :) <3

Updated on September 18, 2022

Comments

  • Nirmik
    Nirmik over 1 year

    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.

    • Nanne
      Nanne over 11 years
      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 ;)
  • Nirmik
    Nirmik over 11 years
    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
    Nirmik over 11 years
    nope! it crashed whole of unity! :(
  • mx7
    mx7 over 11 years
    Unity crash ? hmm strange issue . hope some one will help you
  • Gufran
    Gufran over 11 years
    @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
    Gufran over 11 years
    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
    Gufran over 11 years
    Is there any specific error ? Can you post what exactly you run in terminal, just scribble your original password before posting ;)
  • Nirmik
    Nirmik over 11 years
    bash: !": event not found..it looks like an error coz of "!" being a character in my passwd...how can i solve this?
  • Nirmik
    Nirmik over 11 years
    i have to put the passwd in "" rite?
  • Gufran
    Gufran over 11 years
    Just use single quotes for (!) exclamation sign alone. Like, if your password is "s!de" it will go like this "s"'!'"de", So while echoing out the password wrap other characters in double quotes but ! sign in single quote. for the instance here is how you should do it: echo "s"'!'"de" | sudo -S service network-manager start. I added one more switch -S that is necessary here. I have updated above post about that.
  • nekketsuuu
    nekketsuuu about 6 years
    Note: If you write password in the command, it will remain in the command history.
  • titusfx
    titusfx about 3 years
    Sometimes you need to start network-manager first, and then you can execute your command. To start networkmanager execute sudo service network-manager start