Thursday, February 21, 2008

Handy Find Command


Find all files on a given filesystem, capturing some nice attributes about them:

find / -xdev | xargs stat -c "%n %a %u %g" | sort > file.txt

Tuesday, February 19, 2008

VIM: Finding Lines With Bytes In CC 81 Or More


To find and highlight all lines containing characters in card column (CC) 81 and greater, use the following search:

/^.\{81,}

Thursday, February 14, 2008

Some Networking Benchmark Tools


-- iperf
-- NetPIPE
-- ttcp

Tuesday, February 12, 2008

Loopback Mount of ISO Example


mount -o loop -t iso9660 isoimagefile.iso /mnt/iso9660image

Converting Unix Man Pages To Text


Generally, this kind of thing will work:

zcat /usr/share/man/man1/chmod.1.gz | nroff -man | col -bx > chmod-1-man.txt
zcat /usr/share/man/man8/e2fsck.8.gz | nroff -man | col -bx > e2fsck-8-man.txt
zcat /usr/share/man/man8/fdisk.8.gz | nroff -man | col -bx > fdisk-8-man.txt

Handy "rdesktop" Command From Linux


rdesktop -u <windows_user_name> -g 90% <ip_address>

Sunday, February 10, 2008

SSH Tunneling Example (X Forwarding)


Machine A is a machine with an active X-Window server and the necessary SSH client software. Machine B is a Linux machine with SSHD running that we have root access to. Machine C is also a Linux machine that we have an account on. From A, we are going to create an SSH tunnel through B which accesses C and displays X-Window client applications back on A via the tunnel. Do something like this:

ssh -X -l root -L 22:<C_IP_ADDRESS>:22 -N <B_IP_ADDRESS>

-- Supply the root password for B when prompted.
-- Supply the correct login/password for C when prompted.
-- Port 22 is the default port for SSH.
-- Execute an X-Window client application on C to test. Maybe "xeyes" or "xclock".
-- If there are problems, open up the privileges for the X-Window server on A with an "xhost +"

SSH Tunneling Example (RDP)


Machine A is an XP machine with Cygwin installed, including the necessary SSH client related software. Machine A also has the remote desktop protocol (RDP) client software installed. Machine B is a Linux machine with SSHD running that we have have root access to. Machine C is an XP machine that allows incoming RDP sessions provided the client has the correct credentials. To use A to take over C via an SSH tunnel through B, do something like this from a Cygwin shell on A:

ssh -l root -L 55555:<C_IP_ADDRESS>:3389 -N <B_IP_ADDRESS>

-- Supply the root password for B when prompted.
-- Then, use the RDP client on A to connect to C via localhost:55555.
-- Supply the correct login data items for C.
-- Port 3389 is the default RDP port.
-- On an XP machine, the RDP client software is "mstsc.exe"

Thursday, February 07, 2008

Some ClearCase Operations


Assumptions:

-- "cleartool" is in $PATH and aliased to "ct"
-- /admin-vob is the Unix path for special admin version object base (VOB)
-- "main_view" is a default view with the following config spec:

element * CHECKEDOUT
element * /main/LATEST

Operations:

# Creating a branch type that is available to all VOBS
# associated with the admin VOB

$ ct setview main_view
$ cd /admin-vob
$ ct mkbrtype -global -c "<comment>" <branch_name>

# Creating a label type that is available to all VOBS
# associated with the admin VOB

$ ct setview main_view
$ cd /admin-vob
$ ct mklbtype -global -c "<comment>" <label_name>

# Applying a label types to stuff recursively (already in a view):

$ ct mklabel -recurse -c "<comment>" <label_name> <start path>

# Applying a label type to an individual element (directory):

$ ct mklabel -c "A Directory" MY_LABEL /vob-at-hand/a/b/c/d

# Applying a label type to an individual element (file):

$ ct mklabel -c "A File" MY_LABEL /vob-at-hand/a/b/c/d/random.xml

# Locking a branch type that is available to all VOBS
# associated with the admin VOB

$ ct setview main_view
$ cd /admin-vob
$ ct lock -replace brtype:<branch_name_to_lock>

# Locking a label type that is available to all VOBS
# associated with the admin VOB

$ ct setview main_view
$ cd /admin-vob
$ ct lock -replace lbtype:<LABEL_TO_LOCK>
# Rename a branch type that is available to all VOBS
# associated with the admin VOB

$ ct setview main_view
$ cd /admin-vob
$ ct rename brtype:<src_branch_name> brtype:<tgt_branch_name>

# NOTE: Of course, any views that were looking for the old
branch tag need to have their config specs fixed.

# Rename a label type that is available to all VOBS
# associated with the admin VOB

$ ct setview main_view
$ cd /admin-vob
$ ct rename lbtype:<SRC_LABEL> lbtype:<TGT_LABEL>

# Create a ClearCase dynamic view in view storage.

$ cd /view-storage
$ umask 002
$ ct mkview -tag <view_name> <view_name>.vws

# Removing a ClearCase dynamic view:

$ cd /view-storage
$ ct rmview -force <view_tag.vws>

# NOTE: should ensure that there are no checkouts in view
# before removal.

# Listing the visible elements (sorted) from within a view:
$ ct ls -r -s -visible . | sort

Wednesday, February 06, 2008

Solaris Package Manager Tips


On a Solaris machine, which packages are present?

/usr/bin/pkginfo -x

Given a package name, which files are related?

/usr/sbin/pkgchk -l <package name>

Given a package name, display package information:

/usr/bin/pkginfo -l <package name>

Given a file name, display related package information:

/usr/sbin/pkgchk -l -p /usr/bin/ls

Monday, February 04, 2008

RPM Tips


Given a file, which package is it in?

# rpm -q -f <file>

Given a package name, which files are related?

# rpm -ql <package>

Given a package name, display package information:

# rpm -qi <package>

Dump all package names:

# rpm -qa | sort | more

Dump all package information:

# rpm -qai

Search uninstalled RPMs for a file:

# ls -1 *.rpm | xargs rpm --query --filesbypkg --package | grep <search_pattern>

Note: The tip above was adapted from the Nov 2008 Linux Journal "Tech Tip" by Dashamir Hoxha on page 31.

Sunday, February 03, 2008

Using Old Micron PCs For Rsync (via SSH) Targets


At a high level, here is what I did to configure three(3) old Micron boxen (Pentium 3, 500MHz, 64MB RAM, 13.5GB) to serve exclusively as rsync targets for production data:

1) Burnt a debian (etch) 4.0r2-i386 "netinst" CD.
2) Booted CD with "netcfg/disable_dhcp=true" option so that I could conduct static network configuration during the install.
3) Used following partition sizes: 800MB (/), 256MB (swap), and 12.6GB (/data).
4) Installed the minimal set of software I could get away with using the non-expert path.
5) Took CD out, rebooted.
6) apt-get install openssh-server (I used the "netinst" CD to satisfy this)
7) apt-get install rsync
8) Rebooted.

Note: I had to setup the BIOS to not halt on detecting a missing keyboard since the intention is to use them like that (no head either).

Saturday, February 02, 2008

Rsync Example


Using rsync to execute an initial copy of data from the SOURCE to TARGET machine via a SSH transport:

rsync -avx --numeric-ids --progress -e ssh /data/ root@<TARGET_IP_ADDRESS>:/data

Using rsync to maintain synchronization after the initial copy:

rsync -avx --numeric-ids --progress --delete -e ssh /data/ root@<TARGET_IP_ADDRESS>:/data

-- The "--delete" option has been added to delete files from the TARGET that have been deleted from the SOURCE since the initial rsync.

-- The "--dry-run" or "-n" option can be added to reveal what rsync intends to do.

-- The trailing "/" on the SOURCE directory is intentionally there and keeps that directory from being created under the TARGET subdirectory.

Friday, February 01, 2008

Quick Symmetric Encryption / Decryption


To encrypt:

gpg -c < cleartext > ciphertext

-- This will prompt for a passphrase.

To decrypt:

gpg < ciphertext > cleartext

-- This will prompt for a passphrase.
-- Use the same passphrase as was used for the encryption.