User Tools

Site Tools


tutorials:bash

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorials:bash [2010/08/05 09:52] chkuotutorials:bash [2012/11/23 13:59] (current) – [.bashrc (Ubuntu)] hsu
Line 4: Line 4:
 ===== Sample Configuration Files ===== ===== Sample Configuration Files =====
 ==== .bash_profile ==== ==== .bash_profile ====
-<file>+<file bash .bash_profile>
 # .bash_profile # .bash_profile
 # Get the aliases and functions # Get the aliases and functions
Line 12: Line 12:
 </file> </file>
  
-==== .bashrc ==== +==== .bashrc (Mac OS X) ==== 
-<file>+<file bash .bashrc>
 # .bashrc # .bashrc
 # User specific aliases and functions # User specific aliases and functions
Line 21: Line 21:
 # User specific environment and startup programs # User specific environment and startup programs
 export PATH="${PATH}:/usr/local/bin:~/bin:~/script" export PATH="${PATH}:/usr/local/bin:~/bin:~/script"
 +
 +# enable color support 
 +alias grep='grep --color=auto'
  
 # shell command alias # shell command alias
Line 31: Line 34:
 </file> </file>
  
-===== ssh key ===== 
-==== Generate key-pairs ==== 
-<code bash> 
-ssh-keygen -t 'rsa' -b 2048 
-</code>  
-==== Auto-authentication ==== 
-Append '~/.ssh/id_rsa.pub' to remote host '~/.ssh/authorized_keys' 
  
-===== Remote reboot ===== +# under home directory,  rename the initial .bashrc to .bashrc_v2 
-In the case that you need to reboot a machine remotely, login through ''ssh'' and use the following command: +mv .bashrc .bashrc_v2 
-<code bash> +# create anyother .bashrc file and paste the below script into it. 
-sudo shutdown -r now +nano .bashrc
-</code>+
  
 +==== .bashrc (Ubuntu) ====
 +<file bash .bashrc>
 +# .bashrc
 +# User specific aliases and functions
 +# set prompt, format = 'user@host[pwd]$ ', for example: 'chkuo@oak[~]$ '
 +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"
 +export PERL5LIB="${PERL5LIB}:/usr/local/bin"
 +
 +# enable color support of ls and also add handy aliases
 +if [ -x /usr/bin/dircolors ]; then
 +    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
 +    alias ls='ls --color=auto'
 +    #alias dir='dir --color=auto'
 +    #alias vdir='vdir --color=auto'
 +
 +    alias grep='grep --color=auto'
 +    alias fgrep='fgrep --color=auto'
 +    alias egrep='egrep --color=auto'
 +fi
 +
 +# some more ls aliases
 +alias l='ls -lF'
 +alias ll='ls -alF'
 +alias lm='ls -alF | more'
 +
 +# shell command alias
 +alias .='pwd'
 +alias ..='cd ..'
 +alias cd..='cd ..'
 +
 +# short cut 
 +alias pls='cd ~/plscript/'
 +alias sc='cd /scratch/$USER/'
 +
 +# ssh alias for connecting to other machines
 + # Academia Sinica
 + # hickory
 + export HICKORY='140.109.56.179'
 + alias hickory='ssh $HICKORY'
 +
 +</file>
  
 ===== Shell Scripts ===== ===== Shell Scripts =====
 ==== Pack Up Directories ==== ==== Pack Up Directories ====
-<file>+<file bash tz>
 #!/bin/sh #!/bin/sh
 for x for x
Line 58: Line 97:
 </file> </file>
  
 +
 +===== Disk permissions =====
 +Useful for checking eternal hard drive (in Mac OS X)
 +==== Check ====
 +<code bash>
 +sudo vsdbutil -c /Volumes/MyDrive
 +</code>
 +==== Enable ====
 +<code bash>
 +sudo vsdbutil -a /Volumes/MyDrive
 +</code>
  
tutorials/bash.1280973179.txt.gz · Last modified: by chkuo