In the ALTLinux terminal, the username and path are not displayed. Instead of the username, the shell name is shown. When switching to another user, everything displays correctly. I checked the /etc/passwd file and the parameters for both users are identical. How can I fix this issue?
In ALTLinux terminal, the problem with displaying the username and path instead of the shell name is usually related to incorrect configuration of the PS1 variable or missing configuration in the ~/.bashrc file. This can be fixed by properly configuring the PS1 variable in the shell configuration file or restoring standard settings from system templates.
Contents
- Causes of the problem
- Checking shell configuration
- Solution through PS1 configuration
- Restoring default settings
- Additional checks
Causes of the problem
The main reason why in ALTLinux terminal the shell name (for example, bash-4.4$ or -bash-4.4$) is displayed instead of the username and path is that the PS1 environment variable is not properly configured.
PS1 is the variable that defines the appearance of the command line in bash. When it is not set or has an incorrect value, the shell uses a minimal default format that only displays information about the shell itself.
As explained on Super User, this is a typical situation when PS1 is not defined in shell configuration files. On Unix & Linux Stack Exchange, it is noted that the problem may also be related to incorrect file permissions for /etc/profile.
Checking shell configuration
First, you should check the current shell configuration settings for the problematic user:
- Check if the
~/.bashrcfile exists:
ls -la ~/.bashrc
- If the file exists, check its contents:
cat ~/.bashrc
- Check the current value of the PS1 variable:
echo $PS1
- Check which configuration files are loaded when the shell starts:
bash -l -c "echo 'Loaded configs:' && echo 'BASH_ENV: '$BASH_ENV && echo 'PROFILE: '$PROFILE && echo 'BASHRC: '$BASHRC"
As noted by Linux School Tech, PS1 is usually configured in .bashrc or .bash_profile files to ensure persistent command line settings.
Solution through PS1 configuration
The main solution to the problem is to properly configure the PS1 variable in the shell configuration file.
Basic configuration
Add the following lines to the ~/.bashrc file for a standard command line appearance:
# Standard format: username@host:path$
export PS1='\u@\h:\w\$ '
Extended configuration with colors
For a more visible and informative command line, you can use an extended format with colors:
# Colored command line with additional information
export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
Saving settings
After making changes to ~/.bashrc, apply them:
source ~/.bashrc
Or close and reopen the terminal.
As explained in ArchWiki, for a dynamic command line, you can use special escape sequences:
\u- username\h- hostname\w- current working directory\W- only the current directory name\$- $ symbol for regular users, # for root
Restoring default settings
If you suspect that the problem is related to a corrupted .bashrc file, you can restore it from system templates:
- Copy the standard
.bashrcfrom/etc/skel:
cp /etc/skel/.bashrc ~/
- Apply the changes:
source ~/.bashrc
As recommended on Reddit, the command cp /etc/skel/.bashrc ~ solves the problem not only with command line display but also with other standard settings that might have been accidentally deleted.
Additional checks
If standard methods didn’t help, perform the following additional checks:
Checking permissions
Make sure the user has read permissions for configuration files:
ls -la ~/.bashrc
ls -la /etc/profile
The correct permissions for .bashrc should be -rw-r--r--.
Checking the SHELL variable
Make sure the SHELL variable points to the correct shell:
echo $SHELL
It should return /bin/bash or a similar value.
Checking for conflicts
Check if there are conflicting settings in other files:
grep -r "PS1" ~/.profile ~/.bash_profile ~/.bash_login 2>/dev/null || echo "PS1 configs not found"
Manual PS1 setting
For a quick check, you can manually set PS1 temporarily:
export PS1='\u@\h:\w\$ '
If after this the command line displays correctly, then the problem is in the configuration files.
As noted by TecAdmin, to save settings, you need to add them to the appropriate configuration file and restart the shell or run source.
Sources
- Why does my Linux prompt show a $, instead of the login name and path? - Super User
- What happened to my shell? It’s not displaying username@hostname:/path/to/working/directory anymore - Reddit
- Why is there no name showing at the command line? - Ask Ubuntu
- Linux bash prompt not show username and hostname - Unix Linux Community
- Instead of username bash-4.2$ is displayed. How can I resolved that? - Unix & Linux Stack Exchange
- My terminal shows bash-5.1$ instead of my user name, Why ? - Reddit
- shell prompt did not show directory - Super User
- How to Change / Set up bash custom prompt (PS1) in Linux - nixCraft
- export PS1 for customizing shell prompt - Ask Ubuntu
- Bash/Prompt customization - ArchWiki
Conclusion
-
Main cause of the problem is the absence or incorrect configuration of the PS1 variable in shell configuration files, usually in ~/.bashrc.
-
Solution add
export PS1='\u@\h:\w\$ 'to ~/.bashrc and runsource ~/.bashrcor restart the terminal. -
Alternative approach - restore the standard .bashrc from the system template with the command
cp /etc/skel/.bashrc ~. -
Permission check make sure the user has read permissions for configuration files and that the SHELL variable points to the correct shell.
-
Prevention regularly check backups of important configuration files to avoid losing settings when accidentally editing.