sudo su

hi,
my super user is crm and password is say pwd

sudo crm and sudo su means same or different

what is passwd comand, cut c ommand?
please advise
LVL 7
gudii9Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arnoldCommented:
Sudo is a rights elevation
Sudo su is redundant, with newer version
Sudo -I is equivalent to su -
Sudo -s is equivalent to su

sudo -I crm
Will result in having the crm shell initialized.

Sudo crm, the result will be crm shell
Sudo su sudo -s will result in root user's shell.


Not sure I understand the last two sentences
Passwd is the command a user would use to change their password.
Root running passwd user can set user's password

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gudii9Author Commented:
https://fossbytes.com/sudo-su-difference-linux/
That’s why su also stands for substitute user or switch user. Simply type su followed by the user account name, e.g., sudo fossbytes, and you’ll enter the password for fossbytes. After completing the job, you can exit the root shell by typing exit. Overall, su basically starts another shell instance with the privileges of the intended user.
i logged in as abc_user by giving abc_password
when i did
pwd
it said
/home/abc_user
not i did
su def_user
password:def_password
now i did pwd
it still shows
/home/abc_user
i thought it should have shown as below

/home/def_user
please advise
arnoldCommented:
if you want to switch user and initialize, you have to add the -
su - def_user
without the - the user is simply switched to the new user, while remaining where they were prior.

it is better to use sudo instead of su as su requires the knowledge of the root password. while sudo through configuration of /etc/sudoers (using visudo) and provides a granular control of what elevated commands a user can run.
once you provide the root password to a user to run su -, the user can do anything and everything on the system

Think of it this way, a building manager gets a painting crew to repaint some offices. granting this crew the master key (SU root password) or the other option is to provide them a subset key (sudo) with access to the locations where the paint should be applied.

sudo -i equal to su -
sudo -s equivalent to su
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

gudii9Author Commented:
what is difference between -i and -s
gudii9Author Commented:
all of sudden if forgot and want to know which used i am on what command i have to us
whoami
??
gudii9Author Commented:
whoami shows def_user though

how - can make so much difference?
gudii9Author Commented:
when i try to switch back to abc_user by giving
su -abc_user
above did not work
if i give
su - abc_user
i am getting
id: cannot find name for group ID 501
is unix is space sensitive also apart from case sensitivity?
gudii9Author Commented:
how to love unix inspite of all the challenges it gives with syntax and space and case and small nitty gritty things
arnoldCommented:
when you run sudo or su, you elevate your rights, similar to what happens on windows if you runas /user:somenewuser cmd
in the windows environment a new command window pops up with somenewuser reflected in the heading .....

sudo -i means elevate to root as though it is a new connection. in this case pwd will reflect /root and whoami will report root.
sudo -s means elevate to root. in this case pwd will reflect the path where you were prior to running this comamnd. whoami will report that you are now root.
to switch to another user
sudo -i -u newuser pwd /home/newuser whoami newuser
sudo -s -u newuser pwd same place you were when you ran the command. whoami newuser.

commands available to you in:
man sudo
it describes the options and their meaning.
arnoldCommented:
when you elevate from usera to userb, you simply exit and you return back to be usera.
you seem to be chaining usera to userb to usera?
gudii9Author Commented:

sudo -i means elevate to root as though it is a new connection. in this case pwd will reflect /root and whoami will report root.
sudo -s means elevate to root. in this case pwd will reflect the path where you were prior to running this comamnd. whoami will report that you are now root.
to switch to another user
sudo -i -u newuser pwd /home/newuser whoami newuser
sudo -s -u newuser pwd same place you were when you ran the command. whoami newuser.

su -i

su -s

when above two used

-s means remain same path eventhough elevated
-i shows new elevated path



su ie switch user is used when ? i think i am kind of clear on sudo now
gudii9Author Commented:
if i just want to swatch from def_user to abc_user how i do it?
arnoldCommented:
Please make a complete scenario.
if you start with dev_user, and want to end up being abc_user as though you just logged in as that user: su - abc_user.

you are all over the place, and I am having difficulty keeping up with what it is you are trying to address.

IT IS BETTER TO USE sudo since this way you do not have to know the passwords of the other users. it only requires you to know your own password and have the requisite rights assigned/delegated to you to run the command.
gudii9Author Commented:
su - abc_user.

giving below error
id: cannot find name for group ID 501

how to resolve that and why i get that?
arnoldCommented:
it means that abc_user has a group membership 501 that does not exist in /etc/groups
id abc_user
groupadd -g 501 somegroupname
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.