Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/help/en/bash/su.html
blob: c6d9d146474ad94a896304511409945f95eedeaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<link rel="STYLESHEET" href="../term_tools/main.css" type="text/css">
<title>su MAN Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body><!-- #BeginLibraryItem "/Library/head_bash.lbi" --><div id="nav-menu">
<ul>
<li><a class="rl" href="../term_tools/index.html"><img src="../term_tools/images/ss64.gif" title="Home" alt="Home"></a></li>
<li><a class="rl" href="../term_tools/bash"><img src="../term_tools/images/bash-l.gif" title="bash" alt="bash"></a></li>
<li><!-- Search Google -->
<form action="http://www.google.com/search" method="get" style="margin:0px;padding:0px;">
<div align="right">
<input name="q" type="text" class="body" size="25">
<input class="submit" type="submit" value="Search">
<input type="hidden" name="q" value="site:ss64.com/bash/">
</div>
</form></li>
<li><a class="rr" href="syntax.html"><img src="../term_tools/images/syntax-r.gif" title="Bash Syntax"></a></li>
</ul>
</div> <!-- #EndLibraryItem --><h1> su</h1> 
<p>Substitute user identity<br>
  Run a command with substitute user and 
  group id, allow one user to temporarily become another user. It runs a command 
  (often an interactive shell) with the real and effective user id, group id, 
and supplemental groups of a given <i>user</i>. </p>
<pre>Syntax
      su [<em>options</em>]... [<em>user</em> [<em>arg</em>]...]

Options

-c <em>COMMAND</em>
--command=<em>COMMAND</em>
     Pass <em>COMMAND</em>, a single command line to run, to the shell with a
     -c option instead of starting an interactive shell.

-f
--fast
     Pass the `-f' option to the shell.  This probably only makes sense
     if the shell run is `csh' or `tcsh', for which the `-f' option
     prevents reading the startup file (`.cshrc').  With Bourne-like
     shells, the `-f' option disables file name pattern expansion
     (globbing), which is not likely to be useful.

-
-l
--login
     Make the shell a login shell.  This means the following.  Unset all
     environment variables except `TERM', `HOME', and `SHELL' (which
     are set as described above), and `USER' and `LOGNAME' (which are
     set, even for the super-user, as described above), and set `PATH'
     to a compiled-in default value.  Change to USER's home directory.
     Prepend `-' to the shell's name, intended to make it read its
     login startup file(s).

-m
-p
--preserve-environment
     Do not change the environment variables `HOME', `USER', `LOGNAME',
     or `SHELL'.  Run the shell given in the environment variable
     `SHELL' instead of the shell from USER's passwd entry, unless the
     user running `su' is not the superuser and USER's shell is
     restricted.  A "restricted shell" is one that is not listed in the
     file `/etc/shells', or in a compiled-in list if that file does not
     exist.  Parts of what this option does can be overridden by
     `--login' and `--shell'.

-s <em>SHELL</em>
--shell=<em>SHELL</em>
     Run <em>SHELL</em> instead of the shell from USER's passwd entry, unless
     the user running `su' is not the superuser and USER's shell is
     restricted (see `-m' just above).</pre>
<p> If no <i>user</i> is given, the default is 'root', the super-user. <br>
  <br>
  The shell to use is taken from user's 'passwd' entry, or /bin/sh if none is 
  specified there.<br>
  <br>
  If USER has a password, `su' prompts for the password unless run by a user with 
  effective user id of zero (the super-user). <br>
  <br>
  By default, su does not change the current directory. It sets the environment 
  variables `HOME' and `SHELL' from the password entry for USER, and if USER is 
  not the super-user, sets `USER' and `LOGNAME' to USER. <br>
  <br>
  By default, the shell is not a login shell. Any additional ARGs are passed as 
  additional arguments to the shell. <br>
  <br>
  GNU su does not treat `/bin/sh' or any other shells specially (e.g., by setting 
  `argv[0]' to -su, passing `-c' only to certain shells, etc.). su can optionally 
  be compiled to use syslog to report failed, and optionally successful, su 
  attempts. (If the system supports syslog.) However, GNU su does not check 
  if the user is a member of the `wheel' group; see options above. </p>
<p><i>"It was just like Romeo and Juliet, only it ended in tragedy" 
  - Milhouse</i><br>
  <br>
  <b> Related</b>:<br>
  <br>
  <a href="chroot.html">chroot</a> - Run a command with a different root directory<br>
  <a href="id.html">id</a> - Print user and group id's <br>
  <a href="logname.html">logname</a> - Print current login name<br>
Equivalent Windows command:  <a href="../term_tools/nt/runas.html">RUNAS</a> /user</p>
<!-- #BeginLibraryItem "/Library/foot_bash.lbi" --><p align="left"><script type="text/javascript"><!--
google_ad_client = "pub-6140977852749469";
google_ad_width = 300;
google_ad_height = 250;
google_ad_format = "300x250_as";
google_ad_type = "text_image";
google_ad_channel ="1984328893";
google_color_border = "CCCCCC";
google_color_bg = "CCCCCC";
google_color_link = "000000";
google_color_text = "333333";
google_color_url = "0000FF";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br>
</p>
<div align="center"><hr size="1">
  <p id="top"><a href="#"><img src="../term_tools/images/top-4.gif" width="47" height="53" border="0" alt="Back to the Top" title="Back to the Top"></a></p>
  <p class="tagline">&copy; Copyright <a href="http://ss64.com/">SS64.com</a> 1999-2010<br>
Some rights reserved<br>
</p>
</div><!-- #EndLibraryItem --></body>
</html>