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?
Asked
Active
Viewed 1.9k times
3

Radu Rădeanu
- 169,590

Jatttt
- 2,327
- 12
- 32
- 43
1 Answers
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.
-
-
1
-
1Downvoted because the way you have suggested to use sudo simply won't work in this context (it is the redirect
>>
that needs elevated permissions) – steeldriver Feb 22 '14 at 20:30 -
-
Although that will work, the "problem" is that sudo will not allow redirect directly. You can use tee or sudo bash -c "echo >> ..." – Panther Feb 22 '14 at 22:15
echo
something>> /bin/bash
that will break your shell. 2) Do not ever useecho
to modifysudoers
, usevisudo
instead. If you found a guide telling you to useecho
for this, change guides and ignore anything else it recommends.