Command for enabling networking?
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}
Related videos on Youtube
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, 2022Comments
-
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 over 11 yearsIf 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 over 11 yearsnope...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 over 11 yearsnope! it crashed whole of unity! :(
-
mx7 over 11 yearsUnity crash ? hmm strange issue . hope some one will help you
-
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 over 11 yearsalso, 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 thisecho "p@$$w0rD" | sudo service network-manager start
-
Gufran over 11 yearsIs there any specific error ? Can you post what exactly you run in terminal, just scribble your original password before posting ;)
-
Nirmik over 11 yearsbash: !": event not found..it looks like an error coz of "!" being a character in my passwd...how can i solve this?
-
Nirmik over 11 yearsi have to put the passwd in "" rite?
-
Gufran over 11 yearsJust 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 about 6 yearsNote: If you write password in the command, it will remain in the command history.
-
titusfx about 3 yearsSometimes you need to start network-manager first, and then you can execute your command. To start networkmanager execute
sudo service network-manager start