I am currently working on an embedded Linux system. For it to be similar to our other products I need to have it start a shell in a specified directory on boot, accessible using the serial port.For that I have this line in the inittab-script:::respawn:-/bin/shThis is working so far, only that the shell starts up with a pwd of /, instead of /mnt/flash.The only way I can come up with is to have it not start /bin/sh but instead a script like that:#!/bin/shcd /mnt/flash/bin/shIs there a way to do that in-line in the inittab without a second script?Edit: I need this to be a login script. This is what the - before the /bin/sh signifies. If I just run ::respawn:/bin/sh -c cd /mnt/flash;exec /bin/sh it does change the folder as expected, but I don't get a login shell which causes other problems.If I run it with ::respawn:-/bin/sh -c cd /mnt/flash;exec /bin/sh I get this error:/bin/sh: exec: line 1: -/bin/sh: not found
Start sh in a specified directory from inittab
shell;busybox;sysvinit;ash
You could give the shell some arguments, so that it starts slightly differently. eg./bin/sh -c cd /mnt/flash;exec /bin/shStarting with -c which will execute commands in following string.First command is the directory change, followed by exec which will start a new shell (in the same process) which is now starting in your desired directory. Update:If busybox shell is being used, there is a problem starting a login shell since busybox does not accept the -l option. Use the dot . command to source commands from your profile(s) before you do the exec eg/bin/sh -c cd /mnt/flash;. /etc/profile;exec /bin/sh