4

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?

osullic
  • 235
  • 1
  • 8
  • According to https://stackoverflow.com/a/2191917/1721265 the `busybox` `ash` is essentially `dash` - see http://linux.die.net/man/1/dash for documentation. – guntbert Mar 08 '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 08 '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 09 '19 at 02:01

1 Answers1

3

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.

guntbert
  • 1,597
  • 1
  • 17
  • 23
osullic
  • 235
  • 1
  • 8
  • 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 08:58
  • 1
    My /root/.profile is not executed when I start 'ash'. Any hints anyone? – Ingo Baab May 21 '22 at 03:39