The solution for switching users into-bash4.1-$ in Linux __linux

Source: Internet
Author: User
Tags create directory

When switching users in Linux into-bash4.1-$, there are two scenarios where this behavior can occur.

Scene One : 1, create directory dir in root directory

2, useradd-d/dir Tom Create user Tom, specify their home directory as/dir, rather than its default home directory (/home/tom)

3, Su-tom switch to Tom User, appear-bash-4.1$

cause Analysis: If we do not change the user's home directory, usually, the new user specified directory should be/home, first look at the user Jinjin default home directory what files

Let's see what's in Tom's user's home directory.

Found in Tom's home directory is empty, lack of user login required environment profile. Bash_profile. BASHRC and so on, so why do you need such a file, which is related to the Linux mechanism, because every time you create a new user by Useradd under Linux, All profiles are copied from/etc/skel to the new user's home directory, typically by default in the new user's home directory, and the/etc/skel directory is primarily used by Useradd. When we created Tom's user, the system also appeared to be prompted not to copy the/etc/skel files to the directory.

Solution: by parsing, it's not hard to find out why a command becomes a bash format after a user switches, and you need to copy the/etc/skel user environment profile to the specified default directory (note/etc/skel/here.) The back of the point do not leak, because those files are hidden files, no dot can not be copied to the hidden files, so that in the cut to Tom users did not appear-bash-4,1$

Now look at Tom's home directory and have those environment profiles.

scene Two:1, create user Sara, home directory is the default home directory/home/sara

2, use usermod-d/tmp/sara Sara change user Sara's home directory

3, Su-sara appeared-bash4.1-$

VIM/ETC/PASSWD to see Sara's home directory already in/tmp/sara.

reason analysis: at this point the home directory of Sara is indeed already in/tmp/sara, but found that Sara folder is still under/home and not/tmp, the user cannot read the configuration file in their home directory when logged in.

This is why. View the usermod parameters and find that-m-d needs to be used together to move the existing Sara folder to the new directory.

Workaround: usermod with parameters when changing the user's home directory-d-m

At present, we encounter more is the second situation, you can try ~ ~




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.