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'
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.1280973179.txt.gz · Last modified: 2010/08/05 09:52 by chkuo