2

When I'm logged in as root, I can display colors, but not when I switch to another user.

The command ls --color=auto only displays colors once when logged as normal user.

I searched a lot and did a couple things other users recommended like:

echo $TERM

which returns:

xterm-256color

I also changed the .bashrc file in /home/ubuntu as root, I uncommented the #force_color_prompt=yes line to force_color_prompt=yes, but then I switched the normal user su steam and tried ls and everything is still white.

Here is my prompt when I'm logged as root and when I switch user:

My prompt when I'm logged as root and when I switch user

I saw that this system has only 1 directory inside the /home/ directory (it's home/ubuntu), which confuses me because I thought it was supposed to have one directory for each user. I suspect that this must be causing my problem: the root user shows colored prompt, but the standard user doesn't, because the standard user can't access the .bashrc file inside the home/ubuntu directory,

3 Answers3

2

I think I figured out what the problem was. When I was setting up my system, I created a user with useradd, which just creates an user without any home folder; you have to do it manually.

I created a test user with the command adduser and it's kinda different, but it created its own directory, and, when I disconnected and connected again with ssh test@<ip address>, the prompt showed all colors normally.

user1 was sharing the same directory as the root, but it hadn't any permission to access the /home/ directory where .bashrc is located.

1

This is typically set in a default .bashrc file. You can restore your .bashrc file to a factory default one:

cp --backup=t /etc/skel/.bashrc ~

This command first creates a backup of your current .bashrc before overwriting it with a default one. If you need to do this for a different user, then supply the full path of the target user's home directory, and change the owner of the copy to the target user.

If you are proficient with .bashrc, you may instead inspect the file /etc/skel/.bashrc to learn on how to implement this in your personal file.

vanadium
  • 97,564
0

You edited your .bashrc as root and you need to change the ownership back to its original user. Try:

chown [OPTIONS] USER[:GROUP] FILE(s)

By the way, don't do that as root, go back to a normal user and use that command with sudo as, for example:

sudo chown jimmy .bashrc

If that didn't work you can try what this user suggested. If this also doesn't work, maybe you're having problems when listing with ls. In this case, try this instead.