954,228 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How do I display the pathname to the BASH shell?

Dear All,

How do I display the pathname to the BASH shell of the Linux Terminal?

Cheers,

turbomen
Junior Poster
113 posts since Feb 2009
Reputation Points: 10
Solved Threads: 0
 

If you simply wish to display what directory you're currently in, use the print working directory command:

$ pwd

If you wish for the prompt to always contain the current directory, you will need to edit the value of PS1 in .bashrc (located in your home directory) to contain \w. To view the current value of PS1:

$ echo $PS1

You can edit this value with vi (or your favorite editor):

$ vi ~/.bashrc

Locate and add \w to the value of PS1, for example:

PS1="\u@\h:\w$ "

Which would make the bash prompt look something like:

keith@localhost:~/current/dir$

There is much more detailed information on editing .bashrc around the web. I hope this helps.

keithdn
Newbie Poster
1 post since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

The path to the shell that is currently running in a terminal can be found in the 'SHELL' environment variable.

You can run 'echo $SHELL', which, on my machine, prints out '/bin/bash'.

Is this what you're looking for?

IsharaComix
Junior Poster in Training
97 posts since Feb 2010
Reputation Points: 95
Solved Threads: 23
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: