Skip to content
Tech BlogTeach yourself :)
  • About
  • AWS
  • OpenSource
  • DevOps
  • Azure

su command and sudo command in linux

February 1, 2017 0 comments Article Linux Jerrish

su – Substitute User

If one user needs to login as another user in the same CLI(shell)

eg: su -l user-name

Note:

  1. Root user can login as any of the other user without needing the password of the other users
  2. Normal user can login as any of the other user with password

In some cases where a normal user wants to execute a command(that can normally executed only by root) if the local system administrator(root) is not available, sharing the root’s password is not recommended, so sudo command can be used

sudo

To exec any command with root privilege – prepend sudo in front of the command

eg:sudo useradd testuser

but, not all users are sudo users by default.

To Make a user as a Sudo User in RHEL

Add a user to wheel group
usermod -aG wheel testuser

Now testuser can exec any command with root privilege without needing root password

and all the commands executed by a sudo user will be logged in a file /var/log/secure

if non-sudo user tries to give command it will be reported as a mail(auto-generated) to root

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • More
  • Click to share on Pocket (Opens in new window)
  • Click to share on Skype (Opens in new window)

Related

Leave a Reply Cancel reply

Calendar

February 2017
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728  
« Jul   Apr »

Archives

  • February 2019
  • November 2018
  • December 2017
  • April 2017
  • February 2017
  • July 2016
  • May 2016
  • March 2016
  • February 2016

Categories

  • Cloud Computing
  • Firewall
  • Linux
  • Networking
  • Notes
  • Virtualization
  • Windows

Copyright Tech Blog 2021 | Theme by ThemeinProgress | Proudly powered by WordPress