Originally Posted by bonowax
...How 'bout 'sh rc.local'?... That's different from './rc.local' isn't it?...
No it isn't different at all.
(full path) or cd /etc/rc.d/ ; ./rc.local
(relative path) [first way]
is the same as doing sh /etc/rc.d/rc.local
(full path) or cd /etc/rc.d/ ; sh ./rc.local
(relative path) [second way]
in order for the first to work (without sh
) the file or script to execute ("rc.local" in this case) must have the execute permission
, the x
$ ls -l /etc/rc.d/rc.local
-rwxr-xr-x 1 root root 614 2006-07-26 16:38 /etc/rc.d/rc.local
If the file or script to execute doesn't have the execute permission, though you want to execute it once for any reason, you can do so with sh
before it, as the second way.
When you call a file or script in the first way, whatever shell
you use, commonly bash
, checks the first line in the file for a program to execute it
$ head -1 /etc/rc.d/rc.local
That's how if /etc/rc.d/rc.local
has the execute permission it gets done by a call to /bin/sh
, which is the same as the sh
you can put before it
I hope that helped more than confused ye