经常出现添加一个新用户之后,使用该新用户文件夹,文件等颜色全是白色不区分,需要复制 root 下配置好的 .bashrc 并且需要source ,退出再次登录后依然需要source;
为新创建用户创建默认.bashrc并自动加载
拷贝默认的.bashrc 进入新用户的根目录并更改用户所属
[root@world-alive:~]#groupadd webapps
[root@world-alive:~]# useradd -g webapps -s /bin/bash -d /home/webapps baron
[root@world-alive:~]# mkdir /home/webapps
[root@world-alive:~]# cp ~ /.bashrc /home/webapps/
[root@world-alive:~]# chown -R baron: /home/webapps
[root@world-alive:~]# chown -R baron: /home/webapps/.bashrc
[root@world-alive:~]# su - baron
[baron@world-alive:~]$ vim .profile
- if [ "$BASH" ]; then
- if [ -f ~/.bashrc ]; then
- . ~/.bashrc
- fi
- fi
[baron@world-alive:~]$ cat .bashrc
- # ~/.bashrc: executed by bash(1) for non-login shells.
- # Note: PS1 and umask are already set in /etc/profile. You should not
- # need this unless you want different defaults for root.
- #PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '
- PS1="\[\033[1;36;40m\][\[\033[0;32;40m\]\u\[\e[37;40m\]@\h:\[\033[1;35;40m\]\W\[\033[1;36;40m\]]\[\033[1;33;40m\]\\$\[\033[1;37;40m\] "
- # umask 022
- # You may uncomment the following lines if you want `ls' to be colorized:
- export LS_OPTIONS='--color=auto'
- eval "`dircolors`"
- alias ls='ls $LS_OPTIONS'
- alias ll='ls $LS_OPTIONS -l'
- alias l='ls $LS_OPTIONS -lA'
- #
- # Some more alias to avoid making mistakes:
- alias rm='rm -i'
- alias cp='cp -i'
- alias mv='mv -i'
没有评论