I maintain several servers, and recently added a DietPi based server to the line-up.
I have a terminal session open for each server while doing maintenance stuff / monitoring. I noticed that all servers where ‘labeled’ as the REMOTE user@host:dir, whereas the DietPi server was labeled as LOCAL user@host:dir
Making things a little bit confusing when switching tabs in the terminal to find the correct host.
So here is the instruction on how to change this on the DietPi host:
open a terminal session to your DietPi and login with the user you normally log into with
nano ~/.bashrc
add the following to the bottom of that file:
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
save and close the file
You should instantly see the tab-label change in your terminal session, otherwise a reconnect would certainly do the trick
Hope this helps.
BTW: I think this should be a nice want-to-have out of the box as this is what most linux distributions do (the ones I have anyway).
This is not touched. What you do in ~/.bashrc looks like your should have the same info doubled now. Also I’m not sure what you mean by “REMOTE” vs “LOCAL”. Can you paste a before/after command prompt?
Okay, so here we go with screenshots before and after. With REMOTE I mean other systems (VPS / DietPI), with LOCAL I mean the desktp I am using myself.
So in the image I have 3 servers (1,2,3) open in tabs and 1 (4) is my local machine / terminal session.
My local desktop is ruud-PEAQ, my username is ruud > ruud@ruud-PEAQ:~
As you can see before the change in .bashrc, tab 3 displays the same as tab 4
After the change, tab 3 holds the correct user / hostname (for the dietpi server session
Hence more interesting would be what the above command shows on the other servers where this change is not required. We use the default /etc/bash.bashrc from Debian, hence on all Debian systems this should be the same. Only other idea I have is that the OpenSSH server does some magic to adjust the terminal header which Dropbear does not.
Hi, sorry, not possible as this system is the only one I currently have and is in production (off-site). So I only have ssh access and switching would break that.
I will however (eventually) buy an additional one for backup / testing, but I decided that I first do a donation as I see and appreciate how much time you all spend in maintaining DietPi and managing / servicing the community
This is the default .bashrc for new users, which contains the code block along with some other colouring and stuff. The root users however gets a minimal variant from /usr/share/base-files/dot.bashrc.
Means if you login with another user, like dietpi, the adjusted terminal header should be there already, and the adjustment is hence only needed for root. And an alternative would be (if /root/.bashrc is still the original one):
Good find @MichaIng, just checked this and for ‘regular’ recreated users this is indeed the case.
But not for the dietpi user account.
So both root and dietpi have the minimal variant
So instruction is still valid and it also works with the cp line you provide (with the note that this will override any other changes in that file)
Ah you are right, I just found that our user creation script copies .bashrc and .profile from the root users home to the new user’s home . Probably we should skip that, or we should generate own skeleton files (the default one contains a bunch of at best redundant commands), or better enhance the global login script to set the PS1 and some other little enhancements we want, with some nice ls colouring and aliases added, like:
eval "$(dircolors)"
alias ls='ls -A --color=auto'
alias l='ls -lh'
alias ll='l -L'