old-www/LDP/GNU-Linux-Tools-Summary/html/c6239.htm

540 lines
7.3 KiB
HTML

<HTML
><HEAD
><TITLE
>Managing users</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="GNU/Linux Command-Line Tools Summary"
HREF="book1.htm"><LINK
REL="PREVIOUS"
TITLE="Controlling services"
HREF="x6066.htm"><LINK
REL="NEXT"
TITLE="Text Related Tools"
HREF="c6435.htm"></HEAD
><BODY
CLASS="CHAPTER"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>GNU/Linux Command-Line Tools Summary</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x6066.htm"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="c6435.htm"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="CHAPTER"
><H1
><A
NAME="MANAGING-USERS"
></A
>Chapter 10. Managing users</H1
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>su&nbsp;username</DT
><DD
><P
><A
NAME="AEN6246"
></A
>(Switch User), change <A
NAME="AEN6248"
></A
>to a different <A
NAME="AEN6250"
></A
>user. </P
><P
>Use <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>su&nbsp;-</I
></SPAN
> to switch <A
NAME="AEN6254"
></A
>to root or<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
> su username</I
></SPAN
>, to switch <A
NAME="AEN6257"
></A
>to a different <A
NAME="AEN6259"
></A
>username. </P
><DIV
CLASS="TIP"
><BLOCKQUOTE
CLASS="TIP"
><P
><B
>Using sudo<A
NAME="AEN6263"
></A
>: </B
> Its often considered better practice to use the <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>sudo </I
></SPAN
>command rather than switch to the root user</P
><P
> The <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>sudo</I
></SPAN
> command allows you to perform actions as root but logs the actions you take (so you can trace anything that was done to the system by yourself or others). <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>sudo</I
></SPAN
> has a very good manual page which provides plenty of information about it.</P
><P
> You use sudo similar to how you execute a normal command with sudo prepended to it, for example:</P
><P
><PRE
CLASS="SCREEN"
> sudo rpm -U myrpm.i386.rpm </PRE
></P
><P
> This would allow you to install a rpm even if you have the correct sudo access </P
></BLOCKQUOTE
></DIV
><P
>Note that if you want to return <A
NAME="AEN6275"
></A
>to your original <A
NAME="AEN6277"
></A
>user you don't use <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>su</I
></SPAN
> again, type <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>exit</I
></SPAN
> or press <A
NAME="AEN6281"
></A
>
<B
CLASS="KEYCAP"
>CTRL</B
>-<B
CLASS="KEYCAP"
>D</B
>
<A
NAME="AEN6286"
></A
>
.</P
><P
>Simply typing <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>su</I
></SPAN
> will give you some root <A
NAME="AEN6290"
></A
>privileges,<A
NAME="AEN6292"
></A
> but there are minor <A
NAME="AEN6294"
></A
>complications relating to environment <A
NAME="AEN6296"
></A
>variables. It's generally considered better practice <A
NAME="AEN6298"
></A
>to use <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>su&nbsp;- </I
></SPAN
>because it has no restrictions.<A
NAME="AEN6301"
></A
></P
><P
></P
></DD
><DT
>root</DT
><DD
><P
>The superuser.<A
NAME="AEN6308"
></A
> This user has power <A
NAME="AEN6310"
></A
>over everything <A
NAME="AEN6312"
></A
>and all, and can do anything with the system (including destroy <A
NAME="AEN6314"
></A
>it, and of course fix <A
NAME="AEN6316"
></A
>it :)). This user is used to perform most administration <A
NAME="AEN6318"
></A
>functions <A
NAME="AEN6320"
></A
>on the system.</P
></DD
></DL
></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="USERS-AND-GROUPS"
></A
>Users/Groups</H1
><P
></P
><P
>All user information <A
NAME="AEN6326"
></A
>is normally listed in the &ldquo;/etc/passwd&rdquo;<A
NAME="AEN6328"
></A
> file and the group <A
NAME="AEN6330"
></A
>information in the &ldquo;/etc/groups&rdquo;<A
NAME="AEN6332"
></A
> file.</P
><P
>If you need to edit <A
NAME="AEN6335"
></A
>either file it is recommended <A
NAME="AEN6337"
></A
>that you use <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>vipw</I
></SPAN
> to edit the password file and <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>vigr</I
></SPAN
> to edit the group <A
NAME="AEN6341"
></A
>file. These particular <A
NAME="AEN6343"
></A
>commands take care of any processing <A
NAME="AEN6345"
></A
>and locking <A
NAME="AEN6347"
></A
>of the files before and after editing <A
NAME="AEN6349"
></A
>them.</P
><P
>There is a lot of information about adding/removing/controlling users and groups,<A
NAME="AEN6352"
></A
> this information is only the minimal <A
NAME="AEN6354"
></A
>information required.</P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>chsh</DT
><DD
><P
><A
NAME="AEN6361"
></A
>Used to change <A
NAME="AEN6363"
></A
>your login <A
NAME="AEN6365"
></A
>shell. </P
><P
>To list <A
NAME="AEN6368"
></A
>the shells <A
NAME="AEN6370"
></A
>available <A
NAME="AEN6372"
></A
>type:</P
><PRE
CLASS="SCREEN"
>chsh --list-shells</PRE
><P
>Simply type<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
> chsh <A
NAME="AEN6377"
></A
></I
></SPAN
>then [Enter], then type the name of the shell you would like to use every time <A
NAME="AEN6379"
></A
>you login.<A
NAME="AEN6381"
></A
></P
></DD
><DT
>chfn</DT
><DD
><P
><A
NAME="AEN6387"
></A
>Change <A
NAME="AEN6389"
></A
>finger <A
NAME="AEN6391"
></A
>information. </P
><P
>The information <A
NAME="AEN6394"
></A
>this command changes is reflected <A
NAME="AEN6396"
></A
>in the /etc/passwd file, use this utility <A
NAME="AEN6398"
></A
>to update <A
NAME="AEN6400"
></A
>your real name, office <A
NAME="AEN6402"
></A
>and home <A
NAME="AEN6404"
></A
>phone numbers<A
NAME="AEN6406"
></A
> (if they exist). </P
><P
>Use the <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>-f</I
></SPAN
> option to change a users full name. Use this tool as either <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>chfn</I
></SPAN
> or<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
> chfn user_name </I
></SPAN
>(usable by root only).</P
><P
>Command syntax:</P
><PRE
CLASS="SCREEN"
>chfn user_name</PRE
></DD
><DT
>passwd</DT
><DD
><P
><A
NAME="AEN6418"
></A
>Changes the password of a user. You will need to be root if you want to change <A
NAME="AEN6420"
></A
>other users passwords.<A
NAME="AEN6422"
></A
></P
><P
>Simply type<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
> passwd <A
NAME="AEN6426"
></A
></I
></SPAN
>to change <A
NAME="AEN6428"
></A
>your own password or to change <A
NAME="AEN6430"
></A
>another users password <A
NAME="AEN6432"
></A
>type:</P
><PRE
CLASS="SCREEN"
>passwd username</PRE
></DD
></DL
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x6066.htm"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.htm"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="c6435.htm"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Controlling services</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Text Related Tools</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>