NeuroAgent

How to Fix Username Display in ALTLinux Terminal

Solution for fixing username and path display issues in ALTLinux terminal. Configure PS1 variable in ~/.bashrc. Restore default shell settings.

Question

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?

NeuroAgent

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

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:

  1. Check if the ~/.bashrc file exists:
bash
ls -la ~/.bashrc
  1. If the file exists, check its contents:
bash
cat ~/.bashrc
  1. Check the current value of the PS1 variable:
bash
echo $PS1
  1. Check which configuration files are loaded when the shell starts:
bash
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:

bash
# 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:

bash
# 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:

bash
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:

  1. Copy the standard .bashrc from /etc/skel:
bash
cp /etc/skel/.bashrc ~/
  1. Apply the changes:
bash
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:

bash
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:

bash
echo $SHELL

It should return /bin/bash or a similar value.

Checking for conflicts

Check if there are conflicting settings in other files:

bash
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:

bash
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

  1. Why does my Linux prompt show a $, instead of the login name and path? - Super User
  2. What happened to my shell? It’s not displaying username@hostname:/path/to/working/directory anymore - Reddit
  3. Why is there no name showing at the command line? - Ask Ubuntu
  4. Linux bash prompt not show username and hostname - Unix Linux Community
  5. Instead of username bash-4.2$ is displayed. How can I resolved that? - Unix & Linux Stack Exchange
  6. My terminal shows bash-5.1$ instead of my user name, Why ? - Reddit
  7. shell prompt did not show directory - Super User
  8. How to Change / Set up bash custom prompt (PS1) in Linux - nixCraft
  9. export PS1 for customizing shell prompt - Ask Ubuntu
  10. Bash/Prompt customization - ArchWiki

Conclusion

  1. Main cause of the problem is the absence or incorrect configuration of the PS1 variable in shell configuration files, usually in ~/.bashrc.

  2. Solution add export PS1='\u@\h:\w\$ ' to ~/.bashrc and run source ~/.bashrc or restart the terminal.

  3. Alternative approach - restore the standard .bashrc from the system template with the command cp /etc/skel/.bashrc ~.

  4. Permission check make sure the user has read permissions for configuration files and that the SHELL variable points to the correct shell.

  5. Prevention regularly check backups of important configuration files to avoid losing settings when accidentally editing.