Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

marked as duplicate by bodhi.zazen, Florian Diesch, Warren Hill, terdon, souravc Mar 19 at 14:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
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 at 20:13
1  
Please, don't ever do this! –  Braiam Feb 22 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 at 0:40

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
Realy realy thank you but how can a standard user do it –  Jatttt Feb 22 at 20:16
1  
Only users having root privileged can do it,standard users can't. –  g_p Feb 22 at 20:23
1  
Downvoted 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 at 20:30
    
@steeldriver Now it will work –  Radu Rădeanu Feb 22 at 20:38
    
Although that will work, the "problem" is that sudo will not allow redirect directly. You can use tee or sudo bash -c "echo >> ..." –  bodhi.zazen Feb 22 at 22:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.