9

How do we want to represent commands that require sudo or root privileges. For example:

sudo ntpd -qg

or

by use of the "#" to represent a root prompt

see this question for an example:

While sudo is more explicit especially for those new to linux, and may therefore prevent comments stating that it doesn't work. The "#" is perhaps more concise. Alternatively, do we even need to favor/pick one over the other?

1

4 Answers 4

15

It is essential we use sudo. The vast majority of people will be using Debian, which uses sudo. Those who have installed different OSs will be intelligent enough to adapt the commands to suit them.

There is a massive exception to this. If someone says, "I'm using Arch", then change your answer appropriately.

1
  • I have to agree. Even though sudo is not always applicable, it is prudent to favour it to other alternatives, such as su or root login. People who understand the implications will understand what sudo does anyway.
    – user13
    Commented Jun 14, 2012 at 12:01
4

I vote against sudo. It is a software package that may be installed or not (on Arch it isn't by default, so you have to login as root or su).

On the other hand, I think that # is not clear enough (it also means comments in shell scripts). I would just add a boilerplate sentence to the answer something along the lines of

You need to be root to do that.

3

I vote to clearly and always use sudo when root privileges are needed.

2 reasons:

  • It clearly indicate the need to use root privileges (user is prompted for password)
  • It's much simpler to copy/paste multiple lines of script with sudo while with # you have to manage the delete nightmare.

Now when it comes to the - I don't have - sudo question yes the package is not installed in many cases but it's always 1 command away, it helps clearly separate the user "space" from the root "space" and it's a cute 4 letters command.

Additionally when sudo is missing the error message is clear about it while a pasted # leads to silently dropped commands (comment) which is way more disconcerting to newcomers.

1
  • It is one command away on many distros. In addition to installing sudo, you also have to add the user to the sudoers list.
    – haziz
    Commented Feb 14, 2014 at 22:35
0

I don't think we should favor one over the other.

People who know what that means will run the command as sudo. Those who don't will see an error along the lines of.

blah blah blah you need to be root blah blah blah

And they will try it again as sudo and it will work. For those who don't get the error they will comment and we will clarify the question.

So basically we should let the answerer choose what they prefer and then clarify if necessary.

0

You must log in to answer this question.

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