Monday, November 10, 2008

Linux Tasks and Processes

To list Process Status (ps):
$ ps -ef     # --everyone, --full
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 Nov01 ?        00:00:00 init [3]
root         2     1  0 Nov01 ?        00:00:00 [migration/0]
root         3     1  0 Nov01 ?        00:00:00 [ksoftirqd/0]

$ ps -al     # --all (same as -e), --long
      PID    PPID    PGID     WINPID  TTY  UID    STIME COMMAND
     4516       1    4516       4516    ? 117771   Nov  4 /usr/bin/mintty
     5280    4516    5280       4412    2 117771   Nov  4 /usr/bin/bash
     5444    5280    5444        456    2 117771   Nov  4 /usr/bin/ssh
     6480       1    6480       6480    ? 117771   Nov  8 /usr/bin/mintty

Saturday, November 8, 2008

My Favorite Bash Settings

.bash_profile

# source the system wide bashrc if it exists
if [ -e /etc/bash.bashrc ] ; then
  source /etc/bash.bashrc
fi

# source the users bashrc if it exists
if [ -e "${HOME}/.bashrc" ] ; then
  source "${HOME}/.bashrc"
fi

# Set PATH so it includes Android SDK Tools
if [ -d "/cygdrive/c/sdk/android-sdk-windows/tools" ] ; then
    PATH=${PATH}:/cygdrive/c/sdk/android-sdk-windows/tools
fi

# Set Prompt to 'username@hostname:pwd\n'
export PS1="\[\e[0;33m\]\u\[\e[0m\]@\[\e[31m\]\h\[\e[39m\]:\w\n$ \[\e]2;\h:${PWD}\a\]"

.bashrc

# Default to human readable figures
alias df='df -h'
alias du='du -h'

# Misc :)
alias less='less -r'                          # raw control characters
alias whence='type -a'                        # where, of a sort
alias grep='grep --color'                     # show differences in color
alias grep='grep --color --exclude-dir=.svn'  # and exclude '.svn' folder
alias rm='rm -i'

# Some shortcuts for different directory listings
if [[ "$(uname)" = "Linux" ]]; then
  alias ls='ls -hF --color=tty'                 # classify files in colour
  alias dir='ls --color=auto --format=vertical'
  alias vdir='ls --color=auto --format=long'
fi
alias ll='ls -l'                              # long list
alias la='ls -A'                              # all but . and ..
alias l='ls -CF'                              #

# Programs and Binaries shortcuts
alias emacs=/cygdrive/c/bin/emacs-23.2/bin/runemacs
alias firefox="cygstart /cygdrive/c/Program\ Files/Mozilla\ Firefox/firefox.exe"
alias mysql="cygstart /cygdrive/c/xampp/mysql/bin/mysql.exe"
alias mysqldump='/cygdrive/c/xampp/mysql/bin/mysqldump.exe'
alias php="/cygdrive/c/xampp/php/php.exe"
alias junction='/cygdrive/c/bin/junction.exe'

# Customized per workstation
alias xampp_start=/cygdrive/c/xampp/xampp_start.exe
alias xampp_stop=/cygdrive/c/xampp/xampp_stop.exe
alias xampp_restart=/cygdrive/c/xampp/xampp_restart.exe
alias todo="emacs ~/docs/secure/todos.org"