bash

Useful commands and sample configuration files.

ssh key

Generate key-pairs

ssh-keygen -t 'rsa' -b 2048

Auto-authentication

Append '~/.ssh/id_rsa.pub' to remote host '~/.ssh/authorized_keys'

Remote reboot

In the case that you need to reboot a machine remotely, login through ssh and use the following command:

sudo shutdown -r now

Disk permissions

Useful for checking eternal hard drive (in Mac OS X)

Check

sudo vsdbutil -c /Volumes/MyDrive

Enable

sudo vsdbutil -a /Volumes/MyDrive

Shell Scripts

Pack Up Directories

#!/bin/sh
for x
do
	echo "$x"
	tar -cf "$x.tar" "$x"
	gzip "$x.tar"
done

Sample Configuration Files

.bash_profile

# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

.bashrc

# .bashrc
# User specific aliases and functions
# set prompt, format = 'user@host[pwd]$ ', for example: 'chkuo@bobcat[~]$ '
PS1='\[\e[1;34m\]\u\[\e[0m\]\[\e[1;33m\]@\[\e[0m\]\[\e[1;31m\]\h\[\e[0m\][\w]\[\e[1;32m\]\$\[\e[0m\] '
 
# User specific environment and startup programs
export PATH="${PATH}:/usr/local/bin:~/bin:~/script"
 
# shell command alias
alias .='pwd'
alias ..='cd ..'
alias cd..='cd ..'
alias l='ls -lFG'
alias lm='ls -lFG | more'
alias ll='ls -alFG | more'
 
# short cut to active project directory
alias pls='cd ~/plscript/'
alias sc='cd /scratch/$USER/'
 
# ssh alias for connecting to other machines
  # University of Arizona
    # HPC ICE (cluster)
    export ICE='ice.hpc.arizona.edu'
    alias ice='ssh $ICE'
    # HPC Marin (shared memory)
    export MARIN='marin.hpc.arizona.edu'
    alias marin='ssh $MARIN'
 
  # Yale University
    # Ochman/Moran lab server
    export APHID='aphidhouse.west.yale.edu'
    alias aphid='ssh $APHID'
 
computer/bash.txt · Last modified: 2010/07/05 02:02 by chkuo
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki