so I was trying to set JAVA_HOME variable and some how I ended up facing this error every time I want to use terminal

Command 'poweroff' is available in the following places
* /sbin/poweroff
* /usr/sbin/poweroff
The command could not be located because '/sbin:/usr/sbin' is not included in the 
PATH environment variable.
This is most likely caused by the lack of administrative privileges associated with 
your user account.
poweroff: command not found

I can fix it with this command:

export PATH="/usr/bin:$PATH"

but every time I open new terminal I face the error again and I have to use this command again.

I would appreciate it if you could help. by the way I use Ubuntu 22.04.1 LTS

3 Answers 3


Although, since you accepted the question, it may be a stopgap that works for you, the better approach would be to fix the cause of the error. Unfortunately, in your question, you do not indicate how you set the JAVA_HOME variable. Somehow, you made changes somewhere that empty the PATH variable.

Thus, carefully inspect your .bashrc file. Anything that changes the PATH was added by yourself. By default, the PATH is not anymore modified in .bashrc. See /etc/skel/.bashrc for a default .bashrc file.


Go to your home directory, edit .bashrc

Add your line:

export PATH="/usr/bin:$PATH"

Now your path will be exported every time you start a new terminal instance.

You can, of course, add any other path you want, before $PATH

Good luck.


The PATH is typically set in /etc/environment. Here's my version:

$ cat /etc/environment

Now, I don't know what you did to set your JAVA_HOME, but there are some examples like https://stackoverflow.com/questions/47013303/ubuntu-java-environment-path-bash-etc-environment-permission-denied which explain how to add JAVA_HOME to /etc/environment. If you followed this, but replaced the >> by a >, instead of adding to the existing file, you overwrote it. Which means the PATH is missing now.

Re-adding the PATH definition from my example should fix most issues, unless you have some package installed that adds yet another path component.

The advantage of doing this in /etc/environment, instead of .profile or .bashrc, is that it works for all users, including users that run server processes, instead of just for you.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .