📄 ch05_06.htm
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 5] 5.6 Checklist: Terminal Hangs When I Log In </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly & Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly & Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:33:04Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="ch05_01.htm"TITLE="5. Setting Up Your Terminal"><LINKREL="prev"HREF="ch05_05.htm"TITLE="5.5 Querying Your Terminal Type: qterm "><LINKREL="next"HREF="ch05_07.htm"TITLE="5.7 What termcap and terminfo Do and Don't Control "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch05_05.htm"TITLE="5.5 Querying Your Terminal Type: qterm "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 5.5 Querying Your Terminal Type: qterm "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 5<BR>Setting Up Your Terminal</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch05_07.htm"TITLE="5.7 What termcap and terminfo Do and Don't Control "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 5.7 What termcap and terminfo Do and Don't Control "BORDER="0"></A></TD></TR></TABLE> <HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-0035">5.6 Checklist: Terminal Hangs When I Log In </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-5168"></A><ACLASS="indexterm"NAME="AUTOID-5170"></A><ACLASS="indexterm"NAME="AUTOID-5171"></A><ACLASS="indexterm"NAME="AUTOID-5172"></A><ACLASS="indexterm"NAME="UPT-ART-35-IX-CONFIGURING-TERMINALS"></A><ACLASS="indexterm"NAME="UPT-ART-35-IX-TERMINALS-CONFIGURING"></A>If your terminal seems to "hang" (freeze, lock up) when you log in,here are some things to try:</P><ULCLASS="itemizedlist"><LICLASS="listitem"><PCLASS="para">Have an experienced user look at your shell's<SPANCLASS="link">setup files (<ACLASS="linkend"HREF="ch02_02.htm"TITLE="Shell Setup Files-Which, Where, and Why ">2.2</A>)</SPAN>.There could be some obvious mistakes that you didn't catch.</P></LI><LICLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-5186"></A>Log in to another account and use the<SPANCLASS="link"><EMCLASS="emphasis">su stucklogin</EM> (<ACLASS="linkend"HREF="ch22_22.htm"TITLE="The su Command Isn't Just for the Superuser ">22.22</A>)</SPAN>command (ifthe stuck account uses Bourne-type shells) or the<EMCLASS="emphasis">su -f stucklogin</EM> command (if the stuck account uses <EMCLASS="emphasis">csh</EM>or <EMCLASS="emphasis">tcsh</EM>).Change (<EMCLASS="emphasis">cd</EM>) to the home directory.Rename the account's setup filesso the shell won't see them as youlog in.</P><PCLASS="para">If you can log in after that, you know that the problem is with theaccount's setup files.</P></LI><LICLASS="listitem"><PCLASS="para"><SPANCLASS="link">Set shell debugging (<ACLASS="linkend"HREF="ch08_17.htm"TITLE="verbose and echo Variables Show Quoting ">8.17</A>)</SPAN>.From another account or as the superuser, start an editor and putthe following line at the top of an <EMCLASS="emphasis">sh</EM>-like setup file (like<EMCLASS="emphasis">.profile</EM>).<ACLASS="indexterm"NAME="AUTOID-5201"></A>It'll tell you whetherthe <EMCLASS="emphasis">.profile</EM> is being read at all and where it hangs:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">set -xv</PRE></BLOCKQUOTE></P><PCLASS="para">You'll see each line read from the <EMCLASS="emphasis">.profile</EM> and the commands executedon the screen. If you don't see anything, then the shell probably didn'tread the <EMCLASS="emphasis">.profile</EM>.C shell users should put this command at the top of <EMCLASS="emphasis">.cshrc</EM> instead:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">set echo verbose</PRE></BLOCKQUOTE></P><PCLASS="para">Note that on many UNIX systems, the shell won't read its startup filesif the files aren't owned by you.You might use<SPANCLASS="link"><EMCLASS="emphasis">ls -l</EM> (<ACLASS="linkend"HREF="ch22_02.htm"TITLE="Tutorial on File and Directory Permissions ">22.2</A>)</SPAN>to check.</P></LI><LICLASS="listitem"><PCLASS="para">Look at the entry in the<SPANCLASS="link"><EMCLASS="emphasis">/etc/passwd</EM> file (<ACLASS="linkend"HREF="ch36_03.htm"TITLE="Changing the Field Delimiter ">36.3</A>)</SPAN>for this user.<ACLASS="indexterm"NAME="AUTOID-5220"></A>Be sure it has the correct number of fields (separated by <CODECLASS="literal">:</CODE>).Also, see if there's another user with the same login name.(If your system has the commands <EMCLASS="emphasis">vipw</EM>(8) and <EMCLASS="emphasis">pwck</EM>(8),your system administrator should be using them to edit and check the<EMCLASS="emphasis">passwd</EM> file.They avoid many of these problems.)</P></LI><LICLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-5229"></A><ACLASS="indexterm"NAME="AUTOID-5232"></A>Does your account use any<SPANCLASS="link">directories remotely mounted (by NFS) (<ACLASS="linkend"HREF="ch01_33.htm"TITLE="UNIX Networking and Communications ">1.33</A>)</SPAN>?If the remote host or network is down, and any command in your startupfiles (especially <EMCLASS="emphasis">set path</EM>) tries to access thosedirectories, the shell may hang there.</P><PCLASS="para">To fix that problem, <EMCLASS="emphasis">su</EM> to the account as explained above and take thecommand or directory name out of your startup file.Or, if this problem happens a lot, the system administrator can mount an<ACLASS="indexterm"NAME="AUTOID-5239"></A><ACLASS="indexterm"NAME="AUTOID-5241"></A>NFS filesystem "soft" (instead of the default, "hard") and limit the numberof retrys.</P></LI><LICLASS="listitem"><PCLASS="para">What looks like a "hang" might also be that you just aren't getting any outputto the terminal, for some very weird reason.Then the <EMCLASS="emphasis">set -xv</EM> wouldn't help you.In that case, try adding this line to the start of the <EMCLASS="emphasis">.profile</EM>:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">exec > /tmp/sh.out.$$ 2>&1</PRE></BLOCKQUOTE></P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-5251"></A>If the Bourne shell starts reading the <EMCLASS="emphasis">.profile</EM>, it'll make a file in<SPANCLASS="link"><EMCLASS="emphasis">/tmp</EM> (<ACLASS="linkend"HREF="ch21_03.htm"TITLE="Unique Names for Temporary Files ">21.3</A>)</SPAN>called <CODECLASS="literal">sh.out.<CODECLASS="replaceable"><I>nnn</I></CODE></CODE> with output from the commands and theshell's <EMCLASS="emphasis">set -xv</EM>.</P><PCLASS="para">There's no command like that for the C shell.</P></LI></UL><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">JP</SPAN></P></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch05_05.htm"TITLE="5.5 Querying Your Terminal Type: qterm "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 5.5 Querying Your Terminal Type: qterm "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch05_07.htm"TITLE="5.7 What termcap and terminfo Do and Don't Control "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 5.7 What termcap and terminfo Do and Don't Control "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">5.5 Querying Your Terminal Type: qterm </TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">5.7 What termcap and terminfo Do and Don't Control </TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed & awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -