Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3303983
  • 博文数量: 631
  • 博客积分: 10716
  • 博客等级: 上将
  • 技术积分: 8397
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-01 22:35
文章分类

全部博文(631)

文章存档

2020年(2)

2019年(22)

2018年(4)

2017年(37)

2016年(22)

2015年(1)

2013年(12)

2012年(20)

2011年(19)

2010年(20)

2009年(282)

2008年(190)

分类:

2009-03-03 15:45:41

ex 13.04
# /etc/profile
# Systemwide environment and startup programs
# Functions and aliases go in /etc/bashrc

PATH="$PATH:/usr/X11R6/bin" #设置SHELL查找命令的路径
PS1="[\u@\h \W]\\$ " #这里设置\u 是用户名 \h 是机器名 \W为当前目录 [username@chinaunix shell_dir]$

ulimit -c 1000000 #如果此文件CORE DUMP的时候最大的CORE文件大小为1000,000bytes
if [ `id -gn` = `id -un` -a `id -u` -gt 14 ]; then #id -gn 取groupname,id -un 取username,id-u 取用户的ID。
        umask 002
else
        umask 022
fi

USER=`id -un`
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"

HOSTNAME=`/bin/hostname`
HISTSIZE=1000
HISTFILESIZE=1000
export PATH PS1 HOSTNAME HISTSIZE HISTFILESIZE USER LOGNAME MAIL

for i in /etc/profile.d/*.sh ; do
        if [ -x $i ]; then
                . $i
        fi
done # 对/etc/profile.d/*.sh下面的sh文件遍历,全部执行一边,如果这个文件的权限为可执行的话

unset i #


ex 13.05
# .bash_profile
# The file is sourced by bash only when the user logs on.
#source让此文件在当前进程内执行
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi#-f 在这里判断~/.bashrc时候是一个文件

# User-specific environment and startup programs

PATH=$PATH:$HOME/bin
ENV=$HOME/.bashrc     # or BASH_ENV=$HOME/.bashrc
USERNAME="root"
export USERNAME ENV PATH
mesg n #The mesg command is executed with the n option, disallowing others to write to the terminal
if [ $TERM = linux ]
then
startx    # Start the X Window system
fi


Note1:注意if then fi的两种写法。
Note2:此贴用于个人学习,欢迎讨论并指出错误。

学习结果展示贴:持续改进。。。。
#!/bin/bash

#####################Main Part##############################

if [ id -un!="Cuser" ];then
                checkCuser()
else
    umask 002
    sourceAll()
fi

mesg n
ulimit -c 1000000

if [ $SHELL!="Bash" ]
then
bash    # Change to Bash
fi

###########################################################


#####################Function set #########################
function checkCuser() {
echo "Please change to Cuser,use \"su -\""
}

function sourceAll() {
for i in ./scripts/*.sh; do
        if [ -x $i ];then
            . $i
        fi
done
}

###########################################################
阅读(1576) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~