Solved

RHEL 6 su command question

Posted on 2011-03-22
3
750 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

697 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