添加用戶并指定shell:
? ? #useradd -r -m -s ?/bin/bash test ? ?#test為新增用戶
? ? #passwd test ?#修改用戶密碼
如果添加的時候未指定shelll可能沒有創(chuàng)建用戶目錄和生成.bashrc文件勾栗。這時候就自己新建home目錄和添加shell。
? ? ? #useradd test ? ? #添加用戶
? ? ? #passwd ?test ? ?#修改用戶密碼
? ? ? # mkdir /home/test ?#創(chuàng)建用戶目錄
? ? ? #chown test:test ?/home/test ? #修改用戶所屬者
? ? ?這時候用戶沒有添加shell盏筐, echo $SHELL查看下围俘。通過修改用戶shell為/bin/bash
? ? ?#usermod -m /bin/bash ?test
? ? ?如果沒有/home/test/.bashrc文件,可以拷貝其他用戶目錄下的.bashrc文件琢融。并修改所屬者界牡。
? ? # source ~/.bashrc ? #使.bashrc文件立即生效
如果每次登錄命令ll不可以使用,則配置需要添加.profile文件用來配置用戶環(huán)境漾抬,可以從其他用戶拷貝宿亡。內(nèi)容如下:
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi