Dear All,

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

Cheers,

Recommended Answers

All 2 Replies

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.

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.