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/
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.
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
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:
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.
There are 12 alternatives - vote for the best!
If you can do better, submit your command here.
You must be signed in to comment.
uh-oh!
Better to use: visudo
I'm curious why it's better to use visudo? Like I said, new to linux, wanting to learn what is good.
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.
You should use visudo, or atleast substitute "$(echo whoami)" for 'loginname' ;-)
I'm sorry -- $(who am i | awk '{print $1}') would work better...
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!
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.
root is a design error
@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.