[sudo-workers] Add an accurate error message for "sudo cd"

Andrea Monaco andrea.monaco at autistici.org
Mon Oct 11 08:18:14 MDT 2021


Hello,


as we all know, the command "sudo cd" usually doesn't work, because cd
is often implemented as a shell builtin.

This is pretty obvious to an experienced user, but I remember being
quite puzzled as a beginner, before searching the web for an
explanation. I think that this happens to many people.

Therefore I propose adding an explicit message, whenever there's (1) a
command not found and (2) the first token is "cd".

Something like this:

  $ sudo cd /root
  sudo: cd: command not found
  sudo: "cd" is often implemented as a shell builtin and thus not
  available to sudo. Maybe you want to switch to a root shell with "sudo -s"?



Let me know,

Andrea Monaco




More information about the sudo-workers mailing list