Hide

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.


If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Hide

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Add a line for your username in the /etc/sudoers file, allowing you to sudo in Fedora

Terminal - Add a line for your username in the /etc/sudoers file, allowing you to sudo in Fedora
echo 'loginname ALL=(ALL) ALL' >> /etc/sudoers
2009-03-19 13:23:43
User: refrax
Functions: echo
-14
Add a line for your username in the /etc/sudoers file, allowing you to sudo in Fedora

I am new to linux, and I was trying to figure out why I could not sudo with my username in Fedora 10. This command, when run as root, will add a line to the sudoers file allowing the loginname supplied to sudo. The above line will require a password when you sudo, if you wish to sudo without password, use:

echo 'loginname ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

instead. you have to run this command as su, and this is just an easier way of using visudo, just adds it right from the terminal.

Alternatives

There are 2 alternatives - vote for the best!

Terminal - Alternatives

Know a better way?

If you can do better, submit your command here.

What others think

uh-oh!

Better to use: visudo

Comment by mpb 300 weeks ago

I'm curious why it's better to use visudo? Like I said, new to linux, wanting to learn what is good.

Comment by refrax 300 weeks ago

Visudo checks for correct syntax, so you can be sure your sudoers file will work:

root@kvirasim:14:39:0:/home/alanceil> visudo

[editing...]

>>> /etc/sudoers: syntax error near line 2

What now?

From the manpage:

visudo edits the sudoers file in a safe fashion, analogous to vipw(8). visudo locks the sudoers file against multiple simultaneous edits, provides basic sanity checks, and checks

for parse errors. If the sudoers file is currently being edited you will receive a message to try again later.

Comment by Alanceil 300 weeks ago

You should use visudo, or atleast substitute "$(echo whoami)" for 'loginname' ;-)

Comment by ozymandias 300 weeks ago

I'm sorry -- $(who am i | awk '{print $1}') would work better...

Comment by ozymandias 300 weeks ago

Use 'visudo' and nothing but 'visudo' (not 'awk', not 'echo', etc).

If you don't have visudo, install it; if you still can't access it, then (and only then) you might resort to hacks--or rebuild your computer from the ground up!

Comment by alexandersafir 299 weeks and 6 days ago

ok, well, no don't do that. sudo is an administrative tool, but that's what ubuntu has taught.. be root and do it all.

There is a reason why windows fails giving the user administrative rights, and why root is a different user in Linux, and other users have less rights (the monolithic hiracy)

visudo is good, but knowing your system is better.

I voted down not because the method was wrong, but the idea was wrong.

Comment by JesusSuperstar 299 weeks and 6 days ago

root is a design error

Comment by maht 299 weeks and 6 days ago

@koukos Sudo is not a wrong idea. Sudo has been around long before Ubuntu. Mac OS X, for example, has been using sudo since day one, further by disabling root entirely (as does Ubuntu). Most major distributions and Unix derivatives ship sudo. Just because Ubuntu has made sudo popular doesn't make it a problem. Sudo has many advantages over just plain 'su - root':

1) It logs the actions of who is performing the command.

2) You can enforce granular control over who has access to what command and what hosts.

3) It creates a mindset of using least privilege, and preventing root logins.

@maht I'll argue that with you. While the paradigm of an all-powerful user 'root', then everyone else is unfortunate, it's been addressed through the wheel group, sudo, and RBAC. Unix today is 100x better than it was 20 years ago. The root account now means more than it did.

For @refrax who submitted the command, as people have already mentioned, 'visudo' is the tool you want to use, so you can check syntax errors. If a tool exists for editing a configuration file, then the tool should be used. 'visudo' is it.

Comment by atoponce 299 weeks and 6 days ago

Your point of view

You must be signed in to comment.

Related sites and podcasts