Difference between revisions of "Redhat: Sudo"
Jump to navigation
Jump to search
| (3 intermediate revisions by the same user not shown) | |||
| Line 6: | Line 6: | ||
| − | == | + | == Limits on Root access, su and sg == |
| + | == su == | ||
| + | |||
| + | A regular user with the ability to log in as root, can take root privileges temporarily using the sudo and su commands. The su command will prompt the user for the root password. | ||
| + | |||
| + | <syntaxhighlight> | ||
| + | [michael@head ~]$ su - | ||
| + | Password: | ||
| + | [root@head ~]# | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | |||
| + | Adding a username will allow you to log in as that user as long as you have the password. | ||
| + | |||
| + | <syntaxhighlight> | ||
| + | su - david | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | |||
| + | The -c flag will give you admin rights for a single command | ||
| + | |||
| + | <syntaxhighlight> | ||
| + | su -c '/sbin/fdisk /dev/sdd' | ||
| + | </syntaxhighlight> | ||
== sg== | == sg== | ||
Latest revision as of 10:01, 2 September 2013
The Root User
The Root user is the all powerful user on the system. If a cracker was to take control of the root user they would have full control of the system.
Most commands should be run as a regular user, as the limits on regular users can protect the system. But for certain purposes a user may need to take root privileges using the sudo, su and sg commands.
Limits on Root access, su and sg
su
A regular user with the ability to log in as root, can take root privileges temporarily using the sudo and su commands. The su command will prompt the user for the root password.
[michael@head ~]$ su -
Password:
[root@head ~]#
Adding a username will allow you to log in as that user as long as you have the password.
su - david
The -c flag will give you admin rights for a single command
su -c '/sbin/fdisk /dev/sdd'