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.
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:
do it, disown it and exit without time for a mess
sudo when you mean it
ps aux | grep $USER
Creates a temporary ram partition
to make a 3gb partition (Defaults to 1gb)
This command will ask for remote sudo password before executing a remote command.
you will be sad after you run a command and find out it needs root, so you should run it again but with prefix sudo.
so this line is to make it simple. just 'sudo !!'
Example: remote install an application(wine).
sshpass -p 'mypssword' ssh -t firstname.lastname@example.org "echo 'mypassword' | sudo -S apt-get install wine"
Tested on Ubuntu.
If you want to carry on your aliases while using sudo, put this into a file which will be parsed when logging in.
shorthand for sudo save
Calls sudo tee like all the other lines, but also automatically reloads the file.
Optionally you can add
command Wq :execute ':W' | :q
command WQ :Wq
to make quitting easier
probably just like 1204, but uses tee as a filter (+ I actually understand how this one works)
Should run with sudo
Will limit the amount of CPU time Grooveshark the greedy yet useful Adobe Air app will have.
Leaves the UI lagging a little, but crucially does not ruin the audio.
a simple command in order to make iptables rules permanent, run @ sudo!
Destination IPs will become invisible to source IPs!
Run program as root by SSH key forwarding instead of sudoers.
Put this alias line in .bashrc or wherever you like. Alias arguments might need extra escaping.
You might wonder about security. But you'd block out root login as much as possible of course. In sshd_config you put this:
Match Address 127.0.0.1
"The -b (background) option tells sudo to run the given command in the background." -- after it asks you for the password in the foreground.
Take advantage of sudo keeping you authenticated for ~15 minutes.
The command is a little longer, but it does not require X (it can run on a headless server).
Need package: gksu
Launching gui app in background that needs sudo, won't work great with our old
friendly style of launching:
sudo gedit /etc/passwd &
because this would put sudo in background !
Using gksudo as demonstrated, would popup a gui sudo window.
May be this is a common knowledge, but not knowing this
frustrated me during my newbie year.
By default sudo 'remembers' password for a few minutes, so that you do not need to re-enter password for a series of sudo commands that might follow within a short time duration.
However, sometime you might want sudo to instantly 'forget' the password.
(Next sudo command will need you to reenter the password)
Credit: I first learned this while listening to one of the 'tuxradar' podcast.
Like the http://www.commandlinefu.com/commands/view/6327/open-file-with-sudo-when-there-is-no-write-permission, but works (in zsh; my commandlinefu is not strong enough to understand why bash don't like it) with vim options, like -O, and many input files.
There could be other mistakes.