View Single Post
Old 25. May 2009, 05:47 PM   #8 (permalink)
debtboy
Senior Member
 
debtboy's Avatar
 
Join Date: May 2009
Location: ~/
Posts: 128
Default root su sudo

Hi everyone,

As you move around the filesystem and view the contents of files
with more, you will eventually run into permission issues.
For example there is a file /etc/sudoers that can only be viewed by root (all powerful OZ!!!).

First we'll cd /etc then ls -l sud* notice the (*) it's a wildcard.
In english I'm asking to change the directory to /etc and then
I want a listing of everything starting with sud



Now I try to view this file with more and WTH!!!
Notice the permissions, according to those permissions,
Only root or anyone in the root group can read this file.
If this doesn't make sense read Permissions a few posts back on this thread.



So I need root permissions to view this file...
There are many ways to handle this, but I'm going to demonstrate 2.
sudo this is a good way to substitute the user on a command by command basis
The user is based on the sudoers file (the very one we're trying to open),
but root is the default.

sudo more sudoers
It will ask for the root password, once supplied it will execute as root and you will remain as your normal user.



Now I'm kind of old school, and I have always used the su command.
The su command allows you to become any (substitute user) and remain that
user until your finished.
For example:
su root allows you to become root after the root password is supplied.
You are now root and can do anything within the system, BE CAREFUL!!!



NOTE:
There is no protection from root messing the system up
so proceed with caution as the root user.

Let's say you finished being root and want to return as your normal user...
just type exit in the console and you will exit root and be the normal user again.
If you get confused as to who you are because of su,
just type whoami and it tells you who you are logged in as.
For networking purposes, who shows you everyone who is logged into the system.

We need to start combining commands soon, and using pipes.
Once you get used to piping, you'll understand how linux can
be much easier to use than Windows (Ha! Ha! Ha!).

Any question so far??
I'm not very good at explaining things.
debtboy is offline   Reply With Quote