1

I have a problem with my terminal in Ubuntu server 20.04. I would like to color the syntax in my terminal, but after I restart the server, it's back to the normal uncolored syntax. I edited .bashrc and uncommented this line:

force_color_promp=yes

I then and restarted .bashrc with the command source .bashrc, but as I wrote earlier, after restart it returns to the previous non colored syntax.

I don't use ssh to connect to the server. I'm working on it through the console, and I don't have a .bash_login file. I am trying to find a different configuration file.

terdon
  • 100,812
Dany
  • 79
  • 1
  • 6
  • 1
    How are you running your Ubuntu Server? Via the console or via ssh or some other way? I suspect that .bashrc is not involved or not last when setting the environment for your terminal. So you should identify some other configuration file and make the modification there. – sudodus Aug 05 '22 at 13:05
  • 1
    Are you using a login shell or an interactive non-login shell (i.e. does echo $0 say -bash or just bash?) Do you have a ~/.bash_login file? Please [edit] your question to include these details. – steeldriver Aug 05 '22 at 13:06
  • I don't use ssh to connect to the server. Im works in it through the console I don't have a .bash_login file. I am trying to find a different configuration file – Dany Aug 05 '22 at 14:45
  • 1
    I don't see a reason to use sudo here at all. – mook765 Aug 05 '22 at 16:20
  • @Dany, I'm testing an Ubuntu Kinetic Server (to be released as 22.10), and after Force_color_prompt=yes and saving it, there is a coloured prompt for me after reboot. I'm not sure about 20.04 LTS, but something seems to be different. You can check your ~.profile and /etc/profile. Maybe there is a problem with the ownership of your ~/.bashrc because you used sudo with it. Please check that, as hinted by mook765. – sudodus Aug 05 '22 at 16:24
  • @sudodus problem solved i found a problem, the files .bash_logout .profile were empty, thanks for your help and good intentions – Dany Aug 05 '22 at 17:37
  • @Dany, Congratulations :-) Please tell us about your solution, it can help other users with the same or a similar problem. – sudodus Aug 05 '22 at 18:18
  • @sudodus Thanks :) , I've already added an answer to the my question – Dany Aug 05 '22 at 18:58
  • @Dany, Great description :-) However, it would be even better if you create an 'answer' and put your solution steps there. After a couple of days you can 'accept' it (click on the tick mark). That will indicate that your question has an accepted solution (and would be worthwhile to visit for other users :-) – sudodus Aug 06 '22 at 07:50
  • Yes, please don't post solutions as part of the question. I have deleted your solution because i) it was posted as part of the question and ii) it is a very, very bad solution! NEVER edit your user's configuration files with sudo! – terdon Aug 07 '22 at 13:40

1 Answers1

0

The file .bashrc is not relevant to your case. When you log into your server from the console, you are starting an interactive login shell and that kind of shell ignores ~/.bashrc and instead reads ~/.profile.

So, to make the changes you want persistent, you need to make your edits in ~/.profile and not ~/.bashrc. See here for a more in-depth explanation of what files are read in what types of shell:

terdon
  • 100,812