Service not found error

it says " service will print a list of available services "

but when I try that I get
"-ash: service: not found"
their is no executable file name service in the filesystem.
I create my own image so what am I not including?

The service command on OpenWrt is a convenience wrapper around the usual init script machinery, it is defined as shell alias in /etc/profile. Maybe you customized your profile in the past without ever rebasing it.


this is weird.
the service part is not present in my profile file but it is present in /rom/etc/profile file.
how did that happen?

You have sysupgraded from an old version that did not yet contain the relevant part in /etc/profile. Sysupgrade with "keep settings" preserves /etc/profile. It makes sense to build all settings from scratch every now and then.

Services part was added in late 2016 with;a=commitdiff;h=d52676d1ea51bcfc947970085184fe4d18638ccd

/rom/etc/profile contains the current default, while /etc/profile contains old defaults with your personal modifications (or likely just the old default profile).

Easiest for you is to just copy the new version from /rom

Ps. If you do not have that code bit in /etc/profile, you may also have a wrong PATH, as PATH was reformed in late 2015...;a=commitdiff;h=d7023fc0bc4b66c44969276df9cbfe218f931250

from scratch?
you mean tell it to not keep the setting and then add them manually?
that would take a long time I think.
but thanks for the answer. I thought that the /etc/config file were only kept.
is there a list of files that are kept?

sysupgrade -l

(Lower-case "ell")

1 Like

No. /etc/config contains only the uci config files, but there are lots of other permanent config-like files.

Files in other places are kept if they are declared to be config files by some package (e.g. SSH keys for dropbear, personal package feeds for opkg, etc.) or by system (like /etc/profile, /etc/hosts, /etc/passwd).

See for system definitions.

I've created a user account to add an extra layer of security and blocked SSH by root. I now find that that /etc/profileisn't being sourced on su to root. I've tried creating /root/.profile and adding source /etc/profile but that doesn't get sourced either.

Can anyone advise how to get /etc/profile sourced after su into root?

It doesn’t source on login for me either. Some patches on the mailing list recently.

. profile should work.

I can manually...

source /etc/profile

...and that works, however your suggested

. profile

...doesn't work either manually nor when added to roots ~/.profile (for either of the above). I've tried searching through the posts in 2019 on openwrt-devel but couldn't find anything relevant. Is that the mailing list you refer to or is there another one? Do you have a link to the posts on patches you refer to please?

The messages I remember seem to be around

Also, I don't believe that sudo will start a shell unless that is the command you execute. The environment of the "calling" user is generally wiped intentionally. sudo -E will preserve the caller's environment on many systems. sudo env var=value command is another approach that works on many systems.

1 Like

try sudo -i

1 Like

Thanks for the pointer, will read through that.

I've not been using sudo at all, I'm just using su to switch to route as there are very often more than one command I wish to use.