1

I'm using ubuntu 14.04 LTS and i have successfully configured a telnet server. When i logging into telnet server i always get the path(int the terminal) as

username@hostname:~/Folder_Name$

I really want to know when do i get the path like this ,

[username@hostname Folder_Name]$

CodeIt
  • 1,849

3 Answers3

3

The latter prompt that you have seen is the default on Red Hat-based systems, such as Red Hat Enterprise Linux, CentOS, and Fedora. The former is the default on Debian-based systems such as Debian itself and Ubuntu.

The default Red Hat PS1 prompt is:

export PS1="[\u@\h \W]\\$ "

You can of course change the prompt to whatever you wish. I prefer the Red Hat-style but with the complete path shown instead of simply the last directory component.

export PS1="[\u@\h \w]\\$ "

And of course you should never be using telnet on anything, but using ssh instead.

2

That’s pretty easy. Just look at man 1 bash: Whereas the default prompt uses \w (“the current working directory, with $HOME abbreviated with a tilde (uses the value of the PROMPT_DIRTRIM variable)”), there’s also \W: “the basename of the current working directory, with $HOME abbreviated with a tilde”

To get what you want, use this:

export PS1="[\u@\h \W]$ "
user219095
  • 65,551
2

What you're after is the bash PS1 variable. To get what you want, you need to export this variable from .bashrc, which is executed on login.

The PS1 you want should look like this:

export PS1="[\u@\h \W]$ "

place that in .bashrc in your home directory. Or just run it as a command from the shell if you want it just temporarily.

If you want colors on there, here's the one that I've used for years, slightly modified to suit your question:

export PS1='[\[\033[1;33m\]\u\[\033[1;35m\]@\[\033[1;32m\]\h\[\033[0;36m\]\W\[\033[1;37m\]]\$ \[\033[0;37m\]'

Disclaimer: Everyone but me thinks the above is ugly.


On a related note: You should avoid telnetting into your machine, as telnet is very insecure. I highly recommend using ssh instead.

Jarmund
  • 6,277
  • 5
  • 38
  • 60