I am unable to run any command on debian, I am getting the above error.
Though when I use sudo same commands works.
Can someone please explain this behavior?
41 Answer
It is likely that the root user on your system is set up with a different default $PATH compared to that of non-root users.
The default paths are specified in /etc/profile, /etc/login.defs, /etc/login.conf or some other file either read by the shell, or by the login command. It differs from system to system.
The ufw command might, for example, live in /usr/sbin/. This directory usually contains tools that only root have any use for (many of them might even require root privileges, such as ufw, which is a firewall configuration tool).
There is no real need to have that directory in the $PATH of ordinary users.