首先看看/etc/passwd
它保存著用戶名、加密后的密碼等信息,我們登錄系統所有信息都要在里面查找
用戶登錄時自動讀取/etc/profile 此文件包含:
讓我們來看一個詳細的profile
用戶的$HOME.profile
下面顯示如何在命令提示符中設置主機名:
stty用于設置終端特性。要查詢現在的stty選項,使用stty -a
創建.logout文件
它保存著用戶名、加密后的密碼等信息,我們登錄系統所有信息都要在里面查找
- -bash-3.00$ cat /etc/passwd | tr ":" "\t" | sort -k0
- adm x 4 4 Admin /var/adm
- bin x 2 2 /usr/bin
- daemon x 1 1 /
- gdm x 50 50 GDM Reserved UID /
- jiang x 100 1 / /bin/sh
- listen x 37 4 Network Admin /usr/net/nls
- lp x 71 8 Line Printer Admin /usr/spool/lp
- noaccess x 60002 60002 No Access User /
- nobody x 60001 60001 NFS Anonymous Access User /
- nobody4 x 65534 65534 SunOS 4.x NFS Anonymous Access User /
- nuucp x 9 9 uucp Admin /var/spool/uucppublic
- /usr/lib/uucp/uucico
- root x 0 0 Super-User / /bin/bash
- smmsp x 25 25 SendMail Message Submission Program /
- sys x 3 3 /
- ttaserv x 101 100 / /bin/sh
- ttasys x 102 100 / /bin/sh
- uucp x 5 5 uucp Admin /usr/lib/uucp
- webservd x 80 80 WebServer Reserved UID /
- www x 81 81 WebServer User /
- -bash-3.00$ cat /etc/passwd | sed -n '/jiang/'p
- jiang:x:100:1::/:/bin/sh
- -bash-3.00$ cat /etc/passwd | sed -n '/jiang/'p | tr ':' '\t'
- jiang x 100 1 / /bin/sh
用戶登錄時自動讀取/etc/profile 此文件包含:
- 全局或局部環境變量。
- PATH信息
- 終端設置
- 安全命令
- 日期信息或放棄操作信息
讓我們來看一個詳細的profile
- -bash-3.00$ cat /etc/profile
- #ident "@(#)profile 1.19 01/03/13 SMI" /* SVr4.0 1.3 */
- # The profile that all logins get before using their own .profile.
- trap "" 2 3 #忽略兩個信號,即使用QUIT退出或<Ctrl-c>鍵停止文件執行
- ulimit -d 100000 #限制內存溢出,設置數據段的最大值:單位kbytes
- export LOGNAME PATH #導出LOGNAME 和 PATH
- export LANG=C #設置語言環境
- if [ "$TERM" = "" ] #設置終端類型
- then
- if /bin/i386
- then
- TERM=sun-color
- else
- TERM=sun
- fi
- export TERM
- fi
- # Login and -su shells get /etc/profile services.
- # -rsh is given its environment in its .profile.
- case "$0" in
- -sh | -ksh | -jsh | -bash)
- if [ ! -f .hushlogin ]
- then
- /usr/sbin/quota
- # Allow the user to break the Message-Of-The-Day only.
- trap "trap '' 2" 2
- /bin/cat -s /etc/motd
- trap "" 2
- /bin/mail -E
- case $? in #建立郵件信息(當有新郵件到達時顯示提示信息)
- 0)
- echo "You have new mail."
- ;;
- 2)
- echo "You have mail."
- ;;
- esac
- fi
- esac
- umask 022 #設置umask值,使文件創建時帶有一定的缺省權限位集
- trap 2 3 #重新設置捕捉信號<Ctrl-C>和QUIT,即恢復信號量的默認操作
- # add by jianghua
- export
- PATH=$PATH:/usr/local/bin:/usr/local/mysql/bin:/opt/SunStudio_11/SUNWspro/bin:/usr/ccs/bin:
- /usr/sfw/bin:.
- export HISTSIZE=1000
- export HISTFILESIZE=1000
- #
- # Show Unix-Center.Net Welcome Message in Chinese
- #
- show_welcome_message
用戶的$HOME.profile
下面顯示如何在命令提示符中設置主機名:
- -bash-3.00$ PS1='$PWD >'
- /home/l/g/tomotoboy >export PS1
stty用于設置終端特性。要查詢現在的stty選項,使用stty -a
- /home/l/g/tomotoboy >stty -a
- speed 9600 baud;
- rows = 25; columns = 82; ypixels = 0; xpixels = 0;
- csdata ?
- eucw 1:0:0:0, scrw 1:0:0:0
- intr = ^c; quit = ^\; erase = ^?; kill = ^u;
- eof = ^d; eol = <undef>; eol2 = <undef>; swtch = <undef>;
- start = ^q; stop = ^s; susp = ^z; dsusp = ^y;
- rprnt = ^r; flush = ^o; werase = ^w; lnext = ^v;
- -parenb -parodd cs8 -cstopb -hupcl cread -clocal -loblk -crtscts -crtsxoff -parext
- -ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -iuclc
- ixon -ixany -ixoff imaxbel
- isig icanon -xcase echo echoe echok -echonl -noflsh
- -tostop echoctl -echoprt echoke -defecho -flusho -pendin iexten
- opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel tab3
創建.logout文件
- trap "$HOME /.logout " 0
- /home/l/g/tomotoboy >cat .logout
- rm -f $HOME/*.txt
- rm -f $HOME/*.tmp
- rm -f $HOME/x*
- echo "Bye...bye $LOGNAME"