linux

TMUX - Terminal Multiplexer

TMux is the shit. Use it more. alternative to SCREEN though I'm not sure for better or worse. I like that tmux splits screens horizontally and vertically and into quadrants.

Ref: http://rdegges.com/tools-i-use-tmux
Ref: https://github.com/henrik/dotfiles/blob/master/tmux.conf
Ref: http://cheasy.org/tmux.pdf - Good summary

GNU Screen: Working With Scrollback Buffer

GNU Screen is a UNIX tool that allows multiple console applications to be run, each in its own “window”, from the same terminal. In a single Screen session, you can run interactive shells, mail programs, SSH sessions, and other console based applications, and you can easily switch between these using hotkeys. You can even split up the Screen display so that multiple Screen windows can be viewed at the same time.

NRG2ISO

Code to convert an nrg file to an iso.

Download, compile, run. Drag into /usr/bin and it's runnable everywhere, like on okeanids.

Reference: http://gregory.kokanosky.free.fr/v4/linux/nrg2iso.en.html

TODO: Post downloadable bin files for various *nix based OS's.

Installing ODBC for PHP on Linux

Running Fedora/RHEL.

  • yum install unixODBC* - Grab the dev packages
  • yum install freetds* - Grab the dev packages
  • recompile PHP source with pre_configure file
    • ensure that you specify flag --with-unixODBC=/usr

Configure an /etc/odbc.ini with something similar to the following:

17 [dsn_aws_shamrockdb]
18 Driver = /usr/lib/libtdsodbc.so
19 Description = shamrock aws database
20 Trace = No
21 Server = 123.123.123.123 #IP address, remove this comment
22 Port = 1433

nc

Listening Machine

nc -l 1234 > something.file

Sending Machine

cat somethingelse.file | nc [ip address] [port]

Using sed and Bash While Loops

#!/bin/sh
#
# This file was made exclusively to work in conjuction with other scripts to mirror the online store.
#
# Goes through each filename fed from the command line and does the following.
# 1. Replace '..' with '/' because wget rewrites all the "mirrored" domains.
# 2. Replace 'https://' with '/' because certain resources point to https and it was a pain to set it up locally
# 3. Replace 'action="http://' with 'action="/' because we didn't want to really post to internet. Note the quotation is correct
#

Sending Email Via Command or Shell

$ mutt -s "Test mail" -a /tmp/file.tar.gz user@email.com < /tmp/mailmessage.txt

  • user@email.com - is the recipient
  • /tmp/mailmessage.txt - is the main body of the e-mail (read message from the file "mailmessage.txt")
  • /tmp/file.tar.gz - is an attachment (with option -a)
  • "Test mail" - is a subject line (option -s)

Resource: http://www.cyberciti.biz/tips/sending-mail-with-attachment.html

GAWK-ness!

Kill Stuff

ps -ef | gawk '/php|lead/ { print $2 }' | xargs kill

List processes list, grab anything that contains "php" or "lead" and print the PID (second column as signified by $2), pass through to xargs to kill.

ps -ef | gawk '/php|lead/ { print $n }'
//is functionally equivalent to
ps -ef | egrep "php|lead"
//as print $n prints all columns.
//second command comes with cool colors if your terminal is configured proper.
//first command - no colors

#kill process

Recursive FTP with NcFTP for Linux

One of my biggest peeves with traditional command line FTP tools is NOT being able to recursively put directories.

Welcome NcFTP.

yum install ncftp
ncftp -u username hostname/IP address
put -R *

Reference: http://www.linux.com/archive/feed/52714

SVN

SVN

Installation
yum install trac

Creating Repository
svnadmin create repo_name
svnadmin create --fs-type fsfs repo_name

Working With Repository
svn checkout file:///lci/svnroot/toolbox toolbox
svn import test file:///lci/svnroot/test --message "any message"
svn commit

Reference: http://www.cs.ubc.ca/~vailen/svn_howto.htm
Reference ebook: http://svnbook.red-bean.com/

Enable Syntax Highlighting for root in vim

One of the most annoying things I couldn't figure out for the longest time was why syntax highlighting WORKED for users I created, but not for root. After reading an article, the fix was pretty simple.

Assuming syntax highlighting (syntax on) was placed in the global /etc/vimrc file instead of the local user's ~/.vimrc, you simply need to add an alias for vim.

Open up /root/.bashrc and add:

alias vi="vim"

Saving yourself from logging out and back in for the change to take effect, do this:

source /root/.bashrc

Disabling root SSH Access

I won't get into the arguments of why this is or isn't a good thing to do. I've already decided for myself that any machine I create, root ssh access will be denied.

For my distro, Fedora, you can find this file: /etc/ssh/sshd_config. Find this line and uncomment it.

PermitRootLogin no

Configure and Verify That .htaccess Works

For an hour, the bane of my existence last night as I was trying to configure Drupal on my personal server to get Clean URLs to work. Apache was NOT reading my .htaccess file.

Testing .htaccess
Create an .htaccess file in the directory you need it working for. Type random stuff in. Reload the page and see if you get a config error. If your page still shows up, Apache is ignoring it.

Configuring Apache

Creating Private Key, CSR, Self-signed CRT, and Converting CRTs using OpenSSL

OpenSSL, used in conjunction with Apache via the mod_ssl module, makes securing your site with SSL easy.
I use the naming convention suggested by the referenced article because it makes more sense. Prior to that, I was just using "key" and "server" and that was very confusing. Of course, I didn't know what I was doing either.

Creating Key
openssl genrsa -des3 -out www.dreamingbinary.com.key 2048

Syndicate content