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:
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
Now you cannot edit this file with vi /etc/sudoers (exception is wq! to force save) so you will have
to type this command:
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
when prompted
save and close the file.
Now login as unix and you are ready to execute all the root commands
this way:
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:
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:
^^ 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:
Bye!
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:# visudo
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

save and close the file.
Now login as unix and you are ready to execute all the root commands
this way:
Now suppose you don't want to give unix all root priviledges but$ sudo <root commands>
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:
Now if you don't want to type the full path /etc/rc.d/init.d/smb then:# sudo /etc/rc.d/init.d/smb start
and add /etc/rc.d/init.d to the PATH line:# vi /home/unix/.bash_profile
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!