3

I am using Ubuntu 12.04 and I was doing through a terminal tutorial. There was explained about echo command and he mentioned something about adding your name to the sudoers file using echo >>. I am just wondering what it was? Can anyone tell me how to do it?

Radu Rădeanu
  • 166,822
  • 48
  • 327
  • 400
Jatttt
  • 2,287
  • 12
  • 31
  • 43
  • I went to /bin and typed ls and the first file was bash so i think i should type echo jatin >> bash but i am not sure so just asking? :| – Jatttt Feb 22 '14 at 20:13
  • 1
    Please, don't ever do this! – Braiam Feb 22 '14 at 20:24
  • 1) do not _ever_ try to `echo` something `>> /bin/bash` that will break your shell. 2) Do not _ever_ use `echo` to modify `sudoers`, use `visudo` instead. If you found a guide telling you to use `echo` for this, change guides and ignore anything else it recommends. – terdon Mar 19 '14 at 00:40

1 Answers1

3

Not Recommended:

First login as root using the following command:

sudo -i

Then type:

echo "username ALL=(ALL) ALL" >> /etc/sudoers

Change username with your user name.

It will add the username to sudoers file. But doing this may lock out you from sudo.

Recommended:

If you want to edit your /etc/sudoers use visudo

sudo visudo

You can use /etc/sudoers.d instead of modifying /etc/sudoers.

For more see here.

g_p
  • 18,154
  • 6
  • 56
  • 69