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 ~] #