Let’s sudo it – Linux for newbies

Let’s face it, You switched to Linux because you wanted freedom. But you can’t achieve freedom without using “sudo”. By default Ubuntu and many other distro’s won’t allow users to perform actions as root user or super user(su). But we can take control by using sudo and su commands. This is going to be a long post, so grab a cup of coffee and let’s get started.

Warning: Make a mess and clean-up your own mess. That’s how you can learn. If you don’t have an appetite to make a mess you shouldn’t try this.

Becoming root user :
sudo su            ##to use as root user



Why sudo?

Let us try an everyday scenario. try running “apt-get update” without sudo it’ll ask for root user permission. Some processes are limited only to root users. so to do such things we need sudo command. sudo allows a part This command will remove packages with the root privileges. This command will remove packages with the root privileges.

Adding a repository:

A software repository is a storage location from where software packages can be retrieved and installed.

sudo add-apt-repository ppa:ondrej/php5
sudo apt-get update

It is necessary to update run update after adding a repository.

Installing software:
sudo apt-get install packagename

Removing software:

sudo apt-get remove packagename

su command also gives similar functionality with “-c” option. But steer clear of su if you don’t know what you’re doing.

su -c apt-get install packagename

To run the process in background use,

sudo -b apt-get install packagename

Allowing other users to use sudo:

By default only the user who installed the OS have the permission to use sudo but we can add other users to this list by using the following command.

sudo adduser username sudo

Configuring sudo:

sudo nano /usr/sbin/visudo

This allows you to edit visudo file. Don’t do it.

Setting pasword to root account [Highly not recommended]:

sudo passwd root

For more try

man sudo

to get a detailed manual. You can perform almost every process as a root user by using sudo command.

Protip: use gksu or gksudo instead of sudo to run GUI applications as root.

Correct me if there’s any mistake. Subscribe for more new posts. Contact me for any specific tutorial.

Author: Sridhar S Subramanian, Technology enthusiast and a proud geek.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s