Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
It depens on the way I've been logged into the system :-D
normal user: me@pts/1 foldername $
root user: root@pts/1 foldername $
and remotely, me@hal9000 foldername $
The title of the xterm / konsole will also display the tty, host, and full path name. (only the last folder is shown in the prompt)
if [ "$TERM" = "xterm" -o "$TERM" = "xrvt" -o "$TERM" = "$SCREEN" ]; then
## Only update the title in an xterm.
# PS1_TITLE='\[\e]2;\u@\H \w\a\e[32;1m\]>\[\e[0m\]'
if [ -z "$SSH_CONNECTION" ]; then
# local, don't display host, but tty device.
PS1_TTY="`tty | sed -e 's/\/dev\///'`"
if [ "`id -u`" = "0" ]; then
# Red root prompt
# Green user prompt
unset -v PS1_TTY
# SSH connection, different color and display host.
if [ "`id -u`" = "0" ]; then
# Red/gray root prompt
# green/gray user prompt
PS1_PATH='\[\033[1;34m\]\W' # show dir in blue
PS1="$PS1_TITLE$PS1_USER$PS1_AT$PS1_HOST$PS1_RESET $PS1_PATH \\$ $PS1_RESET"
unset -v PS1_TITLE PS1_USER PS1_AT PS1_HOST PS1_PATH PS1_RESET
#PS1='\033]2;\w\007\[\033[1;32m\]\u@\h \[\033[1;34m\]\W \$ \[\033[0m\]'
# Other magical prompts:
export PS1 PS2 PS4
Distribution: openSuSE 42.1_64+Tumbleweed-KDE, Mint 17.3
Hey, interested noobs (like me)
Note, that PS1 (the control-string for your prompt) can be set at differing places for different users on your system. Here is what I could make out (without actual access to my system):
/etc/bashrc is used to set the prompt for the "true" consoles reached via <Alt><Crtl><Function key 1 through 6>
/root/bashrc is used to set the prompt for root with graphical login (under KDE)
/home/user/bashrc is used to set the prompt for user (your user-id here)
Please note, that some systems place a "." (without the "'s) in leading position of bashrc, thus generating .bashrc (dot-bashrc), which might be hidden in the file manager (activate "show hidden files") and to the ls-command (that's a small "L") so use the -a option (ls -a).
I do not know where PS2, PS3 ... PSN are set and what they are good for, exactly. Any takers?
@moderators (and gurus): checking and editing this post directly as necessary for errors and improvements is welcome.
PS2 is your secondary prompt, if you enter commands on multiple lines. for example, if statements, or while loops. (they require a 'counterpart'; a command that ends the statement)
PS4 is used if you enable "set -x", which shows all commands being executed.
from the bash manual you'll see what files are used. (just type "G" to skip to the end) files in /etc/ are usually global, and affect everyone using bash. files in your home directory overrule these global settings.
if you run bash from a login session (or bash -l), /etc/profile will be read, and from your home direcory: ~/.bash_profile, or ~/.profile.
In slackware, there is a /etc/profile.d/ directory where all *excutable scripts* are being executed by /etc/profile too. Some distributions don't have this, but you could add a few lines at the end of /etc/profile very easy:
# Append any additional sh scripts found in /etc/profile.d/:
for file in /etc/profile.d/*.sh ; do
if [ -x $file ]; then
...guess once, by bash prompt color script is located at /etc/profile.d/bash-prompt-color.sh this affects all users.
a script can be made executable with this command: chmod +x <insert filename here>
Cool stuff guys, but one quick question...
Mine is the standard pibby@localhost thing and I am wondering how I change the "localhost" part. For instance TrickyKid has drew@trickykid. Local host is so boring, I hope there is a way to change that.
Thanks in advance for any help you can offer
Well, you could either change your actual hostname, or just use some of these tricks posted here. I am not positive about Mandrake, but I know in Slack there is a HOSTNAME file in /etc that you can edit to change it from localhost. I actually used netconfig, but I think thats a Slack-specific script.