How can I change the text after the @-sign? I don't know what it means.
It says DESKTOP-HMEEP40
.
This DESKTOP-HMEEP40
string you ask about is probably the hostname retrieved by \h
in $PS1
. Ways to change it differ between OS-es/distros. With systemd
you do it by invoking
hostnamectl set-hostname new_name_here
The whole root@…
string is defined by PS1
shell variable:
PS1
Each time an interactive shell is ready to read a command, the value of this variable shall be subjected to parameter expansion and written to standard error. […]
(source)
Run printf '%s\n' "$PS1"
to see what the variable is in your case. It probably contains some special strings like \u
, \h
. The relevant fragment of Bash Reference Manual is here. You can change PS1
like (almost) any other variable:
PS1='whatever '
To make a permanent change define the variable in your .bashrc
file.
This search result may lead you to some interesting examples.
root@DESKTOP-HMEEP40:~#
(Prompt variable likely resembles: \u@\h:\w\$
)
root
: usernameDESKTOP-HMEP40
: hostname~
: current directory#
: typically specifies root/superuser, whereas $
is typically for all other accounts
The PS1
/prompt
variable is what determines the format of shell prompt, and it's format and layout depends on the OS and shell being utilized. It's normally found in the shell's config file or the user's profile config.
~/.bashrc
for bash, ~/.cshrc
for csh/tcsh, etc.~/.profile
or /etc/profile
, profile.ps1
, etc.
Syntax of the PS1
/prompt
variable will vary with each shell & OS:
w/o color
export PS1='\u@\h \w\$ '
\u
: username\h
: hostname\w
: working directory\$
: promptchars shell variablew/ color
export PS1='[\[\033[34m\]\u\[\033[0m\]\[\033[32m\]@\[\033[0m\]\[\033[34m\]\h\[\033[0m\]] \[\033[34m\]\w\[\033[0m\] \[\033[32m\]\$\[\033[0m\] '
bash: (Ubuntu)
w/o color
PS1='[${debian_chroot:+($debian_chroot)}\u@\h]:\w\$ '
\u
: username\h
: hostname\w
: working directory\$
: promptchars shell variablew/ color
PS1='[${debian_chroot:+($debian_chroot)}\[\033[38;5;039m\]\u\[\033[00m\]\[\033[38;5;154m\]@\[\033[00m\]\[\033[38;5;039m\]uvm\[\033[00m\]] \[\033[38;5;039m\]\w\[\033[00m\] \[\033[38;5;154m\]\$\[\033[00m\] '
powershell: (Microsoft)
w/o color
Function set-prompt {
"$ESC[$($executionContext.SessionState.Path.CurrentLocation)$('$' * ($nestedPromptLevel + 1)) $ESC[0m"
}
w/ color
Function set-prompt {
Param (
[Parameter(Position=0)]
[ValidateSet("Default","Test")]
$Action
)
switch ($Action) {
"Default" {
Function global:prompt {
if (test-path variable:/PSDebugContext) { '[DBG]: ' }
write-host " "
write-host ("$ESC[48;2;40;40;40m$ESC[38;2;170;210;0m$(Get-Location) $ESC[0m $ESC[0m")
if ( $host.UI.RawUI.WindowTitle -match "Administrator" ) {
$Host.UI.RawUI.ForegroundColor = 'Red'
$(if ($nestedpromptlevel -ge 1) {
write-host ('PS $$ ') -ForegroundColor Red -NoNewLine
} else {
write-host ('PS $ ') -ForegroundColor Red -NoNewLine
})
} else {
$(if ($nestedpromptlevel -ge 1) {
write-host ('PS $$ ') -ForegroundColor Blue -NoNewLine
} else {
write-host ('PS $ ') -ForegroundColor Blue -NoNewLine
})
}
return " "
}
}
}
}
set-prompt Default
tcsh (BSD)
w/o color
set prompt = "%N@%m:%~ %# "
%N
: effective username%m
: hostname%~
: working directory%#
: promptchars shell variablew/ color:
set prompt = "[%{\033[34m%}%N%{\033[0m%}%{\033[32m%}@%{\033[0m%}%{\033[34m%}%m%{\033[0m%}] %{\033[34m%}%~%{\033[0m%}%{\033[32m%}#%{\033[0m%} "
PS1
, as per Kamil Maciorowski's deleted answer.