- 让所有用户的PATH环境变量的值多出一个路径,例如:/usr/local/apache/bin


[root@localhost ~]# cat /etc/profile.d/path.sh

#!/bin/bash

PATH=$PATH:/usr/local/apache/bin

- 用户 root 登录时,将命令指示符变成红色,并自动启用如下别名: 

  rm=‘rm –i’

 cdnet=‘cd /etc/sysconfig/network-scripts/’

 editnet=‘vim /etc/sysconfig/network-scripts/ifcfg-eth0’

 editnet=‘vim /etc/sysconfig/network-scripts/ifcfg-eno16777736 或 ifcfg-ens33 ’ (如果系统是CentOS7)

[root@localhost ~]$echo 'PS1="\e[1;31m\][\u@\h \W]\$\e[0m\]"' >> ~/.bashrc

[root@localhost ~]$. .bashrc


[root@localhost ~]# cat .bashrc

# .bashrc

alias rm='rm -i'

alias cp='cp -i'

alias mv='mv -i'

alias free="free -h"

alias cdnet="cd /etc/sysconfig/network-scripts/"

alias editnet='vim /etc/sysconfig/network-scripts/ifcfg-eth0'

- 任意用户登录系统时,显示红色字体的警示提醒信息“Hi,dangerous!”

[root@localhost ~]# cat /etc/profile.d/env.sh

#!/bin/bash

echo -e '\033[1;31m Hi,dangerous! \033[0m'

- 编写生成脚本基本格式的脚本,包括作者,联系方式,版本,时间,描述等

[root@localhost ~]# cat .vimrc

set et

set ts=4

autocmd BufNewFile *.sh exec ":call SetTitle()"

func SetTitle()

    if expand("%:e") == 'sh'

        call setline(1,"#!/bin/bash")

        call setline(2,"#")

        call setline(3,"#********************************************************************")

        call setline(4,"#Author:                                                      Richard")

        call setline(5,"#QQ:                                                        41668690")

        call setline(6,"#Email:                                              41668690@qq.com")

        call setline(7,"#Date:                                                     " .strftime('%Y-%m-%d'))

        call setline(8,"#FileName:                                                     " .expand('%'))

        call setline(9,"#URL:                                                     underdefine")

        call setline(10,"#Version:                                                underdefine")

        call setline(11,"#Description:                                            underdefine")

        call setline(12,"#Copyright:                                  " .strftime("%Y")." All rights reserved")

        call setline(13,"#********************************************************************")

        call setline(14,"")

    endif

endfunc