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
}
###########################################################
阅读(1620) | 评论(0) | 转发(0) |