Linux The VISUDO Command

~uNIx~

Disciple
Like in Windows you can create an account with Administrative rights
the same can be done in Linux to give a user the root priviledges.

First add an user and give password:
# useradd unix ; passwd unix

Now to give user unix all root priviledges so that he can run all
the root commands that are not allowed for a normal limited user, you
will have to edit this file -> /etc/sudoers

NOte: The other way is to change unix UserId and GroupId to 0 and he is the superuser. Just open the file /etc/passwd and locate unix and uid and gid to "0" like this
unix:x:0:0:/home/unix:/bin/bash

Now you cannot edit this file with vi /etc/sudoers (exception is wq! to force save) so you will have
to type this command:
now just insert this line at the end:

unix ALL=(ALL) NOPASSWD: ALL

Note: NOPASSWD means it will not prompt for user's (unix) password
before executing root commands. If you remove NOPASSWD: then just
enter user's password and not the root password dude :p when prompted

save and close the file.

Now login as unix and you are ready to execute all the root commands
this way:

$ sudo <root commands>
Now suppose you don't want to give unix all root priviledges but
just want to give the right to start services like Samba(service smb
start) or NFS(service nfs start) etc. then just insert this line in
visudo:

unix ALL=(root) NOPASSWD: /etc/rc.d/init.d/smb

save and close the file and now login as unix and start the samba
service with this command:

# sudo /etc/rc.d/init.d/smb start
Now if you don't want to type the full path /etc/rc.d/init.d/smb then:
# vi /home/unix/.bash_profile
and add /etc/rc.d/init.d to the PATH line:

PATH=$PATH:$HOME/bin:/etc/rc.d/init.d

If you want you may also add "/usr/sbin , /usr/bin and /sbin" where all
root binaries are located. So now the PATH line looks like this:

PATH=$PATH:$HOME/bin:/etc/rc.d/init.d:/sbin:/usr/bin:/usr/sbin

save and close. Now you can type:
example:
$ sudo smb start[

$ sudo ifconfig eth0 <IP number>

$ sudo chkconfig --list | more

$ ls -l /etc/passwd
$ sudo chmod 777 /etc/passwd
$ ls -l /etc/passwd

^^ above command is **** risky so don't forget to retore default
permissions to chmod 644 ;-)

and finally for all details on the command sudo and file sudoers give command:
man sudo
man sudoers

Bye!
 
But I do like u. U remind me of my old pal UC. Wish he were here too.
But then again, if he were I wud probably never get off the net.
 
KingKrool said:
But I do like u. U remind me of my old pal UC. Wish he were here too.
But then again, if he were I wud probably never get off the net.

thank you :)
ut i want to know who is UC and how come I remind u of him :tongue:
 
UC = Ulitmate chaos. Used to be on TA b4 he was banned for treason and flaming every single thread on the board. We used to argue non stop.
People used to accuse him of being sick too.
 
Back
Top