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:
Back up /etc directory with a name based on the current date and the hostname of the machine, then chown the file for the current user for use.
Using $_ in the chmod command saved a good bit of typing ? obviously the $_ will contain the path to the file we?re talking about, as it was the last argument to the previous command.
be careful where you execute this from
do a 'sudo ls' beforehand to prime sudo to not ask for your password
requires: a directory with borked permissions and a backup directory that has the correct permissions.
works with chown or chmod
I often use it at my work, on an ovh server with root ssh access and often have to change mod after having finished an operation.
This command, replace the user, group and mod by the one required by apache to work.
Set Permission to user and group
This will change the ownership of /../../somedirectory as well as all its subdirectories so they will be be owned by user2 - typically used when a directory is owned by root:root
In the example, uid 0 is root. foo:foo are the user:group you want to make owner and group. '.' is the "current directory and below." -print0 and -0 indicate that filenames and directories "are terminated by a null character instead of by whitespace."
Finds all files in /home owned by UID 1056 and changes to 2056.
Changing files ownership in a directory recursivley from a user to another
useful if you want to start running a svc as a non-privileged user instead of root.