posts - 19, comments - 53, trackbacks - 0, articles - 283
            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          登陸環(huán)境

          Posted on 2009-11-29 11:59 Gavin.lee 閱讀(254) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): Linux shell 入門(mén)
          首先看看/etc/passwd
          它保存著用戶(hù)名、加密后的密碼等信息,我們登錄系統(tǒng)所有信息都要在里面查找
          Shell代碼
          1. -bash-3.00$ cat /etc/passwd | tr ":" "\t" | sort -k0   
          2. adm     x       4       4       Admin   /var/adm   
          3. bin     x       2       2               /usr/bin   
          4. daemon  x       1       1               /   
          5. gdm     x       50      50      GDM Reserved UID        /   
          6. jiang   x       100     1               /       /bin/sh   
          7. listen  x       37      4       Network Admin   /usr/net/nls   
          8. lp      x       71      8       Line Printer Admin      /usr/spool/lp   
          9. noaccess        x       60002   60002   No Access User  /   
          10. nobody  x       60001   60001   NFS Anonymous Access User       /   
          11. nobody4 x       65534   65534   SunOS 4.x NFS Anonymous Access User     /   
          12. nuucp   x       9       9       uucp Admin      /var/spool/uucppublic      
          13.   
          14. /usr/lib/uucp/uucico   
          15. root    x       0       0       Super-User      /       /bin/bash   
          16. smmsp   x       25      25      SendMail Message Submission Program     /   
          17. sys     x       3       3               /   
          18. ttaserv x       101     100             /       /bin/sh   
          19. ttasys  x       102     100             /       /bin/sh   
          20. uucp    x       5       5       uucp Admin      /usr/lib/uucp   
          21. webservd        x       80      80      WebServer Reserved UID  /   
          22. www     x       81      81      WebServer User  /   
          23. -bash-3.00$ cat /etc/passwd | sed -n  '/jiang/'p   
          24. jiang:x:100:1::/:/bin/sh   
          25. -bash-3.00$ cat /etc/passwd | sed -n  '/jiang/'p | tr ':' '\t'  
          26. jiang   x       100     1               /       /bin/sh  


          用戶(hù)登錄時(shí)自動(dòng)讀取/etc/profile 此文件包含:
          • 全局或局部環(huán)境變量。
          • PATH信息
          • 終端設(shè)置
          • 安全命令
          • 日期信息或放棄操作信息

          讓我們來(lái)看一個(gè)詳細(xì)的profile
          Shell代碼
          1. -bash-3.00$ cat /etc/profile   
          2. #ident  "@(#)profile    1.19    01/03/13 SMI"   /* SVr4.0 1.3   */   
          3.   
          4. # The profile that all logins get before using their own .profile.   
          5.   
          6. trap ""  2 3 #忽略?xún)蓚€(gè)信號(hào),即使用QUIT退出或<Ctrl-c>鍵停止文件執(zhí)行   
          7.   
          8.   
          9. ulimit -d 100000 #限制內(nèi)存溢出,設(shè)置數(shù)據(jù)段的最大值:?jiǎn)挝籯bytes   
          10. export LOGNAME PATH #導(dǎo)出LOGNAME 和 PATH   
          11. export LANG=C #設(shè)置語(yǔ)言環(huán)境   
          12. if [ "$TERM" = "" ] #設(shè)置終端類(lèi)型   
          13. then   
          14.         if /bin/i386   
          15.         then   
          16.                 TERM=sun-color   
          17.         else   
          18.                 TERM=sun   
          19.         fi   
          20.         export TERM   
          21. fi   
          22.   
          23. #       Login and -su shells get /etc/profile services.   
          24. #       -rsh is given its environment in its .profile.   
          25.   
          26. case "$0" in   
          27.   
          28. -sh | -ksh | -jsh | -bash)   
          29.   
          30.         if [ ! -f .hushlogin ]   
          31.         then   
          32.                 /usr/sbin/quota   
          33.                 #       Allow the user to break the Message-Of-The-Day only.   
          34.                 trap "trap '' 2"  2  
          35.                 /bin/cat -s /etc/motd   
          36.                 trap "" 2  
          37.   
          38.                 /bin/mail -E   
          39.                 case $? in #建立郵件信息(當(dāng)有新郵件到達(dá)時(shí)顯示提示信息)   
          40.                 0)   
          41.                         echo "You have new mail."  
          42.                         ;;   
          43.                 2)   
          44.                         echo "You have mail."  
          45.                         ;;   
          46.                 esac   
          47.         fi   
          48. esac   
          49.   
          50. umask 022 #設(shè)置umask值,使文件創(chuàng)建時(shí)帶有一定的缺省權(quán)限位集   
          51. trap  2 3 #重新設(shè)置捕捉信號(hào)<Ctrl-C>和QUIT,即恢復(fù)信號(hào)量的默認(rèn)操作   
          52.   
          53. # add by jianghua   
          54.   
          55. export   
          56. PATH=$PATH:/usr/local/bin:/usr/local/mysql/bin:/opt/SunStudio_11/SUNWspro/bin:/usr/ccs/bin:   
          57.   
          58. /usr/sfw/bin:.   
          59. export HISTSIZE=1000  
          60. export HISTFILESIZE=1000  
          61. #   
          62. # Show Unix-Center.Net Welcome Message in Chinese   
          63. #   
          64. show_welcome_message  


          用戶(hù)的$HOME.profile
          下面顯示如何在命令提示符中設(shè)置主機(jī)名:
          Shell代碼
          1. -bash-3.00$ PS1='$PWD >'  
          2. /home/l/g/tomotoboy >export PS1  


          stty用于設(shè)置終端特性。要查詢(xún)現(xiàn)在的stty選項(xiàng),使用stty -a
          Shell代碼
          1. /home/l/g/tomotoboy >stty -a   
          2. speed 9600 baud;   
          3. rows = 25; columns = 82; ypixels = 0; xpixels = 0;   
          4. csdata ?   
          5. eucw 1:0:0:0, scrw 1:0:0:0  
          6. intr = ^c; quit = ^\; erase = ^?; kill = ^u;   
          7. eof = ^d; eol = <undef>; eol2 = <undef>; swtch = <undef>;   
          8. start = ^q; stop = ^s; susp = ^z; dsusp = ^y;   
          9. rprnt = ^r; flush = ^o; werase = ^w; lnext = ^v;   
          10. -parenb -parodd cs8 -cstopb -hupcl cread -clocal -loblk -crtscts -crtsxoff -parext   
          11.   
          12. -ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -iuclc   
          13. ixon -ixany -ixoff imaxbel   
          14. isig icanon -xcase echo echoe echok -echonl -noflsh   
          15. -tostop echoctl -echoprt echoke -defecho -flusho -pendin iexten   
          16. opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel tab3  


          創(chuàng)建.logout文件
          Shell代碼
          1. trap "$HOME /.logout " 0  
          2.   
          3. /home/l/g/tomotoboy >cat .logout   
          4. rm -f $HOME/*.txt   
          5. rm -f $HOME/*.tmp   
          6. rm -f $HOME/x*   
          7. echo "Bye...bye $LOGNAME"  
          主站蜘蛛池模板: 沅江市| 江陵县| 加查县| 微博| 中牟县| 通江县| 磐安县| 崇州市| 丘北县| 禹州市| 扎囊县| 中卫市| 青海省| 普定县| 兴化市| 安阳县| 南郑县| 阿拉善盟| 突泉县| 沁阳市| 台中市| 霸州市| 九台市| 武鸣县| 凤翔县| 苗栗市| 改则县| 科尔| 图片| 同仁县| 施秉县| 十堰市| 江源县| 肇源县| 泽库县| 调兵山市| 三穗县| 普陀区| 南部县| 玉龙| 宁国市|