Solution for shell not displaying the user name path in CentOS

Source: Internet
Author: User

Solution for shell not displaying the user name path in CentOS

In CentOS, shell-bash-4.1 $ solution to not display the user name path

Problem description:

Add a new user under CentOS. After logging in, the shell script information is as follows:

Instead of the username @ hostname combination we often see, it looks uncomfortable.

The reason is that when you create a user, if the-M parameter is specified and the user's home directory is not created, the system will not, automatically copy the user environment variable files under the/etc/skel directory to the user's home directory, which causes these files to not exist.-bash-4.1 # is a problem. Just copy them manually.

Solution 1,Not verified

[Root @ gong3307] # ls-a/etc/skel/
... Bash_logout.bash_profile.bashrc

Run cp-a/etc/skel/* To go to the home directory.

Solution 2,Verified, this method is valid

-Bash-4.1 #

The above is the status before the resolution

The method is as follows:

1. Input in Terminal:

[Plain]

Vi ~ /. Bash_profile

2. If no. bash_profile exists, you can add it by yourself. Add the following content to the file:

[Plain]

Export PS1 = '[\ u @ \ h \ W] \ $'

Note: 'is a character in English.

3. Enter the following command to make the change take effect:

[Plain]

Source ~ /. Bash_profile

In this way, the shell will display the familiar username @ hostname format, as shown below:

[Root @ nginx_back ~] #

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.