Ubuntu: How do I know if a command needs to be run as root?



Question:

It is not always clearly written in the manual, is there any way to find it ?

Sometimes some commands that must be executed as root, returns a weird error message and this is also not always clear.


Solution:1

I usually tell from reading (properly written) manuals when I see two things attached to the command to be run, these are:

  • #, and
  • sudo

these usually indicate that that file will only operate using root privileges. The # usually means the root account is in use, and the other (sudo) means the user should be in the sudoers group so they can use the sudo command.

The other not so obvious indicator is the ownership of the said file, which will only be seen if we run ls -l command on the file, and of course the location of the file in question. This is usually a good give away that it needs to be run as root. Any location outside user home usually needs elevated privileges to run or manipulate.


Solution:2

Also, the simple and safe solution is not running anything as root. When you get an error message looking like this:

E: Could not open lock file /some/path/to/file - open (13: Permission denied)  

It means the command needs root privileges.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »