CLI Best Way to Copy Dotfiles I've seen a lot of convoluted solutions floating around regarding how to copy files starting with .. The problem everyone is trying to avoid is that when you run something like: cp -r A/.* B/ The above command starts copying everything the entire "A" directory (.) and then from the parent directory
CLI Become an SSH Ninja: SSH Tips and Tricks [http://instacod.es/90274] OpenSSH [http://www.openssh.com/] has some pretty cool tricks up its sleeve beyond it's "Clark Kent"-esque ability to provide a secure command line interface on a remote system. Here are some of its more "Superman"-type abilities: * Public-Key Authentication * Learn to Love Your .ssh/
E-Mail Make sSMTP Non-Blocking for PHP If you're trying to send e-mail from PHP (in Drupal or not) using sSMTP you'll find any page sending an e-mail out stalling for several seconds while sSMTP logs in and sends the e-mail out. It's a serious performance hit and can make using your website rather annoying. If you're
CLI Use Redirection Instead of Temp Files There are certain commands that really want to read input in from a file, like diff. However, if what you're trying to manipulate or use with one of these commands is actually output from another command usually you'd have to write this information out to a file before reading it
Apache Redirect Web Traffic to Another Sub-domain (e.g. www) or HTTP to HTTPS Using the mod_rewrite module you can configure Apache to redirect web traffic from one sub-domain to another. Usually used to redirect a bare domain ( http://xensoft.com) to the www sub-domain (http://www.xensoft.com). First make sure you're loading the mod_rewrite module in your httpd.conf or
Best Practices Boot on Power Restore with a Mac Mini When Using Linux [http://www.amazon.com/gp/product/B007477COO/ref=as_li_ss_il?ie=UTF8&camp=1789&creative=390957&creativeASIN=B007477COO&linkCode=as2&tag=xen02-20] Apr 4, 2014 4 min read CLI Adding a Little Color to Recursive diffs I have routine need to recursively diff two large directory trees with small changes sprinkled throughout. After staring at pages and pages of one diffed file after another it becomes easy to lose track of what two files' differences I'm looking at. An easy way to keep track of things Regex On-line Regex Checker and Visualizer This is a pretty cool tool [http://regex101.com]. Type in a Regular Expression and the text you're trying to match against and it'll show you what matches as well as explain the the expression. RPM Use yum to Only Install Security Relevant Fixes If you use yum to manage your server's packages and you're trying to keep things stable then only installing security relevant fixes makes a lot of sense. The yum-plugin-security package adds a plugin that makes keeping track of these things a snap: yum -y install yum-plugin-security Then you can list Best Practices Expand Shortened URLs Here's a requested article. Have you ever run into a shortened URL and have no idea where on the World Wide Web it will take you? There are URL expansion services that will untangle the web of possible redirects and show you ultimately where the shortened URL will take you: CLI A Couple Ways to Return a Random Number on the Command Line Lets explore a couple ways to get random numbers on the command line. > Anyone who attempts to generate random numbers by deterministic means is, of course, living in a state of sin. John von Neumann $RANDOM Bash Internal $RANDOM is an internal Bash function (not a constant) that returns a CLI Re-call Command Line Arguments in BASH BASH's history expansion character, ! has many features, including !: for choosing a specific argument (or range of arguments) from the history. The gist is any number after !: is the number of the argument you want, with !:1 being the first argument and !:0 being the command. echo one two three one CLI Use Multiple CPU Cores(Parallelize) with Single Threaded Linux Commands Note: If things are not working as described below check the version information for parallel. parallel --version WARNING: YOU ARE USING --tollef. IF THINGS ARE ACTING WEIRD USE --gnu. ... Either add --gnu to all your parallel commands, or edit /etc/parallel/config and make sure it lists --gnu and not Bash Advanced BASH Variable Usage Basic Variable Usage * $VARIABLE * ${VARIABLE} BASH variables are case sensitive, e.g. $VARIABLE is not the same as $variable. The curly bracket syntax allows the variable name to be delimited from trailing characters that otherwise might be interpreted as part of the variable name: VARIABLE=end echo "The opposite of Perl What does "use strict;" in Perl do? What does use strict; in Perl really get you? By default three things, which can be specified separately or turned off separately: # All on by default when using use strict; use strict "vars"; use strict "subs"; use strict "refs"; # One or more can be turned off if need be no CLI The Dangers of Copying and Pasting Commands from the Internet What you see on a webpage isn't necessarily what you get when you copy something off it. Watch out for extra hidden logic, especially in "example commands" you might copy directly over to a prompt. The command below demonstrates the point, and is safe to run. It just doesn't do Page 1 of 1
CLI Adding a Little Color to Recursive diffs I have routine need to recursively diff two large directory trees with small changes sprinkled throughout. After staring at pages and pages of one diffed file after another it becomes easy to lose track of what two files' differences I'm looking at. An easy way to keep track of things
Regex On-line Regex Checker and Visualizer This is a pretty cool tool [http://regex101.com]. Type in a Regular Expression and the text you're trying to match against and it'll show you what matches as well as explain the the expression.
RPM Use yum to Only Install Security Relevant Fixes If you use yum to manage your server's packages and you're trying to keep things stable then only installing security relevant fixes makes a lot of sense. The yum-plugin-security package adds a plugin that makes keeping track of these things a snap: yum -y install yum-plugin-security Then you can list
Best Practices Expand Shortened URLs Here's a requested article. Have you ever run into a shortened URL and have no idea where on the World Wide Web it will take you? There are URL expansion services that will untangle the web of possible redirects and show you ultimately where the shortened URL will take you:
CLI A Couple Ways to Return a Random Number on the Command Line Lets explore a couple ways to get random numbers on the command line. > Anyone who attempts to generate random numbers by deterministic means is, of course, living in a state of sin. John von Neumann $RANDOM Bash Internal $RANDOM is an internal Bash function (not a constant) that returns a
CLI Re-call Command Line Arguments in BASH BASH's history expansion character, ! has many features, including !: for choosing a specific argument (or range of arguments) from the history. The gist is any number after !: is the number of the argument you want, with !:1 being the first argument and !:0 being the command. echo one two three one
CLI Use Multiple CPU Cores(Parallelize) with Single Threaded Linux Commands Note: If things are not working as described below check the version information for parallel. parallel --version WARNING: YOU ARE USING --tollef. IF THINGS ARE ACTING WEIRD USE --gnu. ... Either add --gnu to all your parallel commands, or edit /etc/parallel/config and make sure it lists --gnu and not
Bash Advanced BASH Variable Usage Basic Variable Usage * $VARIABLE * ${VARIABLE} BASH variables are case sensitive, e.g. $VARIABLE is not the same as $variable. The curly bracket syntax allows the variable name to be delimited from trailing characters that otherwise might be interpreted as part of the variable name: VARIABLE=end echo "The opposite of
Perl What does "use strict;" in Perl do? What does use strict; in Perl really get you? By default three things, which can be specified separately or turned off separately: # All on by default when using use strict; use strict "vars"; use strict "subs"; use strict "refs"; # One or more can be turned off if need be no
CLI The Dangers of Copying and Pasting Commands from the Internet What you see on a webpage isn't necessarily what you get when you copy something off it. Watch out for extra hidden logic, especially in "example commands" you might copy directly over to a prompt. The command below demonstrates the point, and is safe to run. It just doesn't do