tutorials:bash
This is an old revision of the document!
Table of Contents
Bash
Sample configuration files and useful commands.
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@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" # 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 # Academia Sinica # maple export MAPLE='140.109.56.170' alias maple='ssh $MAPLE' # oak export OAK='140.109.56.171' alias oak='ssh $OAK'
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
Shell Scripts
Pack Up Directories
#!/bin/sh for x do echo "$x" tar -cf "$x.tar" "$x" gzip "$x.tar" done
tutorials/bash.1280509479.txt.gz · Last modified: 2010/07/31 01:04 by chkuo