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:
do 1000 at a time so that if your doodoo is deep you can avoid avoid "command-line too big" error
Unlike other alternatives, this command only relies on bash builtins and should also work on windows platforms with the bash executable.
Sparseness corresponds to the number 128 and can be adjusted. To print all possible digits instead of only 0 and 1 replace RANDOM%2 by RANDOM%10 or RANDOM%16 to add letters [A-F].
# put into .bashrc
function trash() {
if [ -z "$*" ] ; then
echo "Usage: trash filename"
else
local TRASH="${HOME}/.local/share/Trash"
if [ ! -d "$TRASH/files" ]; then mkdir -p "$TRASH/files"; fi
if [ ! -d "$TRASH/info" ]; then mkdir -p "$TRASH/info"; fi
local IFS_BKP=$IFS
IFS='
'
for FILE in $@ ; do
local BASE=$( basename "$FILE" )
local TRASH_NAME="$BASE"
local COUNTER=1
while [ -e "$TRASH/files/$TRASH_NAME" ]; do
COUNTER=`expr $COUNTER + 1`
TRASH_NAME="$BASE.$COUNTER"
done
local FULL_PATH=$( readlink -f "$FILE" )
local DATE=$( date +%Y-%m-%dT%H:%M:%S )
mv "$FULL_PATH" "$TRASH/files/$TRASH_NAME"
if [ $? -eq 0 ]; then
echo "[Trash Info]
Path=$FULL_PATH
DeletionDate=$DATE" > "$TRASH/info/$TRASH_NAME.trashinfo"
fi
done
IFS=$IFS_BKP
fi
}
Monitoring a log file with 'tail -f' is handy, but for emacs users monitoring the file with emacs is even better, because you can use all your familiar key bindings for copying regions, etc.
Use 'ctrl-@' to set a mark. See the first comment for a better explanation.
Super fast way to ftp/telnet/netcat/ssh/ping your loopback address for testing. The default route 0.0.0.0 is simply reduced to 0.
Execute commands serially on a list of hosts. Each ssh connection is made in the background so that if, after five seconds, it hasn't closed, it will be killed and the script will go on to the next system.
Maybe there's an easier way to set a timeout in the ssh options...
Generate a 18 character password from character set a-zA-Z0-9 from /dev/urandom, pipe the output to Python which prints the password on standard out and in crypt sha512 form.
This will check if a user is logged in using ssh and will log out the user automatically after the specified time in seconds without data retrieval on the server side.
Will work with bash and zsh so put it into your sourced shell file on the server side.
Be aware that users can change this themselves as it's just a envoronment variable.
Put this in your zshrc, source it, then run 'pkill -usr1 zsh' to source it in all open terminals. Also works with bash. More info: http://www.reddit.com/r/commandline/comments/12g76v/how_to_automatically_source_zshrc_in_all_open/
There is no need to use the shell or construct. Screen offers varius ways of detaching and reattaching. man screen and look for -[rRdD].
to create a named session: sdr moo
hide:
resume: sdr moo
Tries to avoid the fragile nature of scrapers by looking for user-input in the output as opposed to markup or headers on the web site.
Tries to reattach to screen, if it's not available, creates one.
created an alias "irc" for it, since sometimes i forget if there already is a screen session running with irssi, this way I avoid creating a new one by mistake.
I doubt this works with other than bash, but then again, I havent tried.
The 'yes' utility is very simple, it outputs a hell of a lot of 'y's to standard input.
The '!!' command means 'the last command'. So this one-lines inputs a lot of y's into the last command, aggressively agreeing to everything. For instance, when doing apt-get.
You may want to just use the shortcut "." instead of "source"