Commands tagged tcp (15)

What's this? is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands

Check These Out

Schedule Nice Background Commands That Won't Die on Logout - Alternative to nohup and at
Check out the usage of 'trap', you may not have seen this one much. This command provides a way to schedule commands at certain times by running them after sleep finishes sleeping. In the example 'sleep 2h' sleeps for 2 hours. What is cool about this command is that it uses the 'trap' builtin bash command to remove the SIGHUP trap that normally exits all processes started by the shell upon logout. The 'trap 1' command then restores the normal SIGHUP behaviour. It also uses the 'nice -n 19' command which causes the sleep process to be run with minimal CPU. Further, it runs all the commands within the 2nd parentheses in the background. This is sweet cuz you can fire off as many of these as you want. Very helpful for shell scripts.

Removing images by size
Removes all png files whose geometry is not 280x190 pixels

Find the package that installed a command

connect via ssh using mac address
Instead of looking for the right ip address, just pick whatever address you like and set a static ip mapping.

Sort file greater than a specified size in human readeable format including their path and typed by color, running from current directory
1. find file greater than 10 MB 2. direct it to xargs 3. xargs pass them as argument to ls

sed /pat/!d without using sed (no RE; limited to shell patterns aka globbing)
POSIX requires this "string truncating" functionality. might as well use it, at least for very small tasks where invoking sed and using RE is overkill.

calculate the total size of files in specified directory (in Megabytes)
the command will calculate the size of hidden files

Use xdg-open to avoid hard coding browser commands
I rarely use the system menu to start applications. I use keyboard shortcuts instead. Keyboard shortcuts are convenient time savers. To configure the shortcuts I use gconf-editor or CompizConfig Settings Manager (if I have Compiz turned on). Lately I've been using Chromium as my browser. Since Chromium is under heavy development it occasionally becomes unusable and I have to switch back to Firefox. I was hard-coding the browser command in my keyboard shortcuts. This became problematic with frequent browser hopping. I now use the xdg-open command when defining my keyboard shortcuts. xdg-open opens a file or URL in the user's preferred application. In the metacity keybinging_commands I have xdg-open where I used to have firefox Now when switching browsers I don't have to update each keyboard binding command I just change my default browser in Ubuntu by clicking through the menu: System / Preferences / Preferred Applications / Web Browser. xdg-open is more convenient for this browser hopper.

Get AWS temporary credentials ready to export based on a MFA virtual appliance
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: `awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'` You must adapt the command line to include: * $MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials

Recursively execute command on directories (.svn, permissions, etc)
The above command will set the GID bit on all directories named .svn in the current directory recursively. This makes the group ownership of all .svn folders be the group ownership for all files created in that folder, no matter the user. This is useful for me as the subversion working directory on my server is also the live website and needs to be auto committed to subversion every so often via cron as well as worked on by multiple users. Setting the GID bit on the .svn folders makes sure we don't have a mix of .svn metadata created by a slew of different users.

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.


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: