service command not found
I'm trying to start ssh using:
service sshd startbut the service command can't be found, so it gives me an error:
zsh: command not found: serviceWhat should I do?
52 Answers
command not found typically results from 2 cases:
- an executable not having execute permissions for your user or group
- an executable not belonging to a folder listed in
PATHvariable , or the opposite -PATHvariable that does not contain the location of your executable.
As have been solved in the comments , your case is #2. For future readers, the solution is as such:
- open your shell's configuration file in any text editor. If your shell is
bashopen~/.bashrc, if your shell iszshopen~/.zshrc. Note that~refers to your home directory. - Add line
export PATH="$PATH:/usr/sbin". Note, that/usr/sbinis just an example, your location might be different. - Save the file, exit and run
source ~/.zshrcorsource ~/.bashrc. Note, that for shells such askshordashyou will need to use. ~/.bashrcsincesourcecommand isbashismand is not portable
I restarted docker using systemctl in place of service.
sudo systemctl restart docker 1