Solved

RHEL 6 su command question

Posted on 2011-03-22
3
737 Views
Last Modified: 2013-11-17
What is the difference between

su tcn

Open in new window


and

su - tcn

Open in new window


I looked up the man page and it states:

Change the effective user id and group id to that of USER.

-, -l, --login

Open in new window


Doesn't "su tcn" change the user id.  Would this command not change the group id without the dash ?
0
Comment
Question by:Los Angeles1
  • 2
3 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 35189956
There is a difference between userid/groupid and "effective" userid/groupid.

The effective IDs are only changed with "su -", and also the login profile of the target user is only executed with "su -".

wmp
0
 
LVL 12

Expert Comment

by:upanwar
ID: 35189961
With su you just become that user but home directory will not be changed and it will not read his .bash_profile and .bashrc so env variable set by him will not be available but

With su - it is like you have logged in with that user. home directory will be changed. Path will be set according that user. It will read that users .bash_profile and .bashrc, all custome env variable will be available.
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 35190030
Sorry, seems I've been typing too fast!

I should have written

Only the effective IDs are changed with "su" alone, the login profile of the target user is only executed with "su -".
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now