...documenting with examples the tools and commands that make mlsamuelson productive...
man mlsamuelson? MAN is a Linux command that displays manual pages documenting commands. It's a wonderful tool, but I often miss having real-world examples, so I record them here.
| Title | Excerpt |
|---|---|
| SCP - secure copy protocol |
|
| SSH - secure shell |
|
| TAIL - view the tail end of a file |
|
| SFTP - secure file transfer protocol |
mkdir / lmkdir and rm / lrm hold to the same pattern
|
| FIND - locate files and directories |
|
| TREE approximation using FIND and SED |
|
| Search last N commands |
history 200 | grep 'mysql'in the last 200 commands entered, match/show any with mysql in them. !123if the command you want shows up in the history as line 123, this will run it (Your up arrow will thank you.) |
| cp -R and copying contents vs. copying directory |
cp -R foo/ faacopy contents of tmp directory to another_tmp directory resulting path: /faa/[foo's files] cp -r foo faacopy directory foo into directory faa resulting path: faa/foo/[foo's files] |
| PUSHD, POPD and DIRS - manage the directory stack |
pushdAdd the current directory to the directory stack. pushd ~/tmpAdd ~/tmp directory to the stack and cd there. dirs -vDisplay the directory stack. pushd +2Bring the directory at the 2 position to the front of the stack (0) and cd there. popdPop off (remove from stack) the top/current directory in the stack (position 0). popd -1Remove the directory at the 1 position in the stack. Or you could just use Poor man's recall: cd - |
| id, finger and hostname |
idreturns the user's identity hostname --longprint host's name, long form fingerdisplay info on logged in users finger joelookup information on user joe |
| Benchmark Apache with ab |
ab -n 50 http://my.example.commake 50 requests in an Apache Benchmark session and display results. gives you great stats like number of requests per second, time taken for tests, etc. a big help if you're tuning an opcode cache such as APC for PHP. |
| Search SVN logs |
svn log example.module | egrep 'example_menu' -B 2 -A 1display SVN log entries for the file example.module that include the string 'example_menu'. The -B 2 option tells egrep to display two lines of context before and -A 1 one line after the matched line. Things can be thrown off by long or short messages, but generally this works. |
| Title | Excerpt |
|---|---|
| CVS messages |
Resulting from an Update
Resulting from a Commit
|
| Title | Excerpt |
|---|---|
| Read log files through Drupal Devel's Execute PHP tool |
$out = shell_exec('tail -n 100 /path/to/apache/logs/php_error-log');output the last 100 lines from the log file. Also, using the PHP shell_exec() function you could run "ls" or "less" commands to verify that the proper files are in an environment for which you don't have file level access. Important note: shell_exec() is a powerful reason to keep PHP filter access restricted to only the most trusted users in your Drupal site - or disabled altogether if not needed. |
| Title | Excerpt |
|---|---|
| IF() - evaulate if conditions in MySQL statements |
an example: SELECT IF(a.phone_pref = 'home', a.home_phone, a.work_phone) AS phone |
| RLIKE - use Regex in MySQL SELECT statements |
match all rows where title starts with 'National' and ends with 'Weekly' with anything in between Matches Not |
| REPLACE() - replace text in database fields |
Replace strings in database fields. |
| Title | Excerpt |
|---|---|
| Write to PHP error log |
I always forget the second parameter in print_r, so recording this. error_log(print_r($my_array, TRUE), 0);does a print_r formatted entry to PHP's error log. Great for testing wne working with service calls... |
| Title | Excerpt |
|---|---|
| Search and Replace in Vim |
|
| Bookmarking in Vim |
|