I have a NAS drive from Western Digital. I can ssh into it, and when I log in, the first line that appears is:

BusyBox v1.20.2 (2014-10-30 15:28:59 CST) built-in shell (ash)

I don't like the default prompt that I get (echo $PS1 gives \u@\h \W \$). However, I can't find where this PS1 variable is set. My user is root and the only file in /home/root/ is .ash_history, and if I do a grep within the /etc/ directory, I get no results for PS1.

How can I find where the PS1 variable is set?

  • According to stackoverflow.com/a/2191917/1721265 the busybox ash is essentially dash - see linux.die.net/man/1/dash for documentation. – guntbert Mar 8 '19 at 22:34
  • What makes you think that the PS1 setting you don't like is set somewhere, rather than being the default? – Ed Grimm Mar 8 '19 at 23:03
  • Some systems drop root user directly to /. Check if you have /.profile for example. FHS says that root could have home in /root so also check /root/.profile - it would work if login applet was used. It doesn't look like a default bbox ash prompt, default prompt is \w \$ but it's possible that WD has modified bbox source code. – Arkadiusz Drabczyk Mar 9 '19 at 2:01

Ed Grimm's comment got me thinking of an obvious workaround – I didn't know there was such a thing as a "default". If there's just a default prompt, and no PS1 variable set anywhere, well no wonder I can't find the file where PS1 is set – it doesn't exist (yet).

So, I just created a .profile file within /home/root and set the PS1 variable to the format I desire. Now, when I log in to the NAS, this .profile file is automatically read and the prompt displays just how I want.

| improve this answer | |
  • This is definitely an answer! – guntbert Mar 12 '19 at 21:22
  • My .profile file was working just fine for me, until I ssh'd into my NAS today - the file had disappeared. I can only assume that a recent firmware update (which the NAS does automatically) deleted the file. Just something to keep in my mind in case anyone else encounters a similar situation to mine. – osullic Apr 24 '19 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.