How to change Ubuntu's terminal name
Emily Wong
I've been reading about this topis here and tried the solution given to change the terminal name (refer to the picture on item number 1)
But none of them can change the terminal's name (item number 1).
user@linux:~$ gnome-terminal --title="SOME TITLE HERE"
user@linux:~$
user@linux:~$ PROMPT_COMMAND='echo -ne "\033]0;SOME TITLE HERE\007"'
user@linux:~$
user@linux:~$ echo -ne "\033]0;SOME TITLE HERE\007"
user@linux:~$ I know that item number 2 can be changed with PS1. But the title (item number 1) still didn't change even after I change the PS1
user@linux:~$ is fine. I don't want to change this, I just want to rename the terminal's title on the top (item number 1)
2 Answers
The feature gnome-terminal --title have been removed since Gnome v3
If you want to keep Gnome Terminal and change the Window title you will have to play with PS1, see below how to do it.
The Gnome 2 terminal has been forked as mate-terminal bundled in Ubuntu Mate. The
title option is still available with this versionsudo apt-get install mate-terminalWith Gnome Terminal, a way to set the window title will be to play with PS1
You can add a function to your
.bashrc file an call it to change the Window/Tab titlenano ~/.bashrc
Add the function
function set-title() { if [[ -z "$ORIG" ]]; then ORIG=$PS1 fi TITLE="\[\e]2;$*\a\]" PS1=${ORIG}${TITLE}
}source ~/.bashrc to reloadset-title Some new title to change the Window/Tab title
Limitation: when a program changes the PS1, the title may change too (example: ssh to another host will reset the custom title)
1hostnamectl set-hostname on 13.10+ desktop
This is the best way if you have systemd (13.10 onwards) and if cloud-init is not active (see below):
hostnamectl set-hostname 'new-hostname'It:
- does not require rebooting
- persists after reboots
More info at:
18.04 onwards: cloud-init
18.04 Introduced cloud-init which can control setting of the hostname so hostnamectl changes it won't stick after a reboot if cloud-init is installed. TODO: how to check if it is installed, is it installed by default on the desktop image or just server?
If you want hostnamectl changes to stay after a reboot, then you'll need to edit the cloud-init config files, disable cloud-init's hostname set/update module:
sudo sed -i 's/preserve_hostname: false/preserve_hostname: true/' /etc/cloud/cloud.cfgor disable cloud-init entirely:
sudo touch /etc/cloud/cloud-init.disabled