Category Archives: Shell

File and folder permissions using Access Control Lists

Access Control Lists allow you to define user permissions on files in a fine grained way. For example, if Apache needs write permission on a folder – but you want to retain your own permissions for also writing to that folder from command line scripts – ACL is the answer. chmod +a For systems that [...]

Posted in Shell | Tagged , , | Leave a comment

Flush the DNS Cache in Snow Leopard OS X 10.6 and above

To clear your DNS cache typpe in terminal dscacheutil -flushcache

Posted in Shell | Tagged , | Leave a comment

OS X Terminal Colours

To enable file type/permission colours in your OSX terminal, create the file .bash_profile in your home directory and add: export CLICOLOR=1 export LSCOLORS=ExFxCxDxBxegedabagacad I have used the same file for my other linux systems.

Posted in Shell | Tagged , , , | Leave a comment

Enable VIM Syntax Highlighting, Smart Indents, Backspace Key and more…

In your home directory create the file .vimrc with the content: syntax on highlight Comment term=bold ctermfg=6 guifg=Cyan highlight Special term=bold ctermfg=6 guifg=Cyan   set showmode set tabstop=2 set shiftwidth=2 set expandtab set ruler set nowrap set smartindent set backspace=2 set nobackup I have used this file on Ubuntu and OS X. For a full [...]

Posted in Shell | Tagged , , , | Leave a comment

Basic VIM Commands

A few basic VIM commands: $ beginning of current line ^ end of current line ctrl + f forward one screen ctrl + b back one screen

Posted in Shell | Tagged , , | Leave a comment

ssh-agent session in terminal

exec ssh-agent bash

Posted in Shell | Tagged , , , | Leave a comment

GPG key command cheat sheet

gpg –gen-key   gpg –export -a "User Name" > public.key gpg –export-secret-key -a "User Name" > private.key   gpg –import public.key gpg –allow-secret-key-import –import private.key   gpg –delete-key "User Name" gpg –delete-secret-key "User Name"   gpg –list-keys gpg –list-secret-keys   gpg -e -u "Sender User Name" -r "Receiver User Name" somefile gpg -d mydata.tar.gpg

Posted in Shell | Leave a comment

Create a public/private key pair for SSH login

At the command line… ssh-keygen -t rsa tested: OS X 10.6.4 getting started with ssh guide

Posted in Shell | Leave a comment

Hiding and restoring bash echo in a script

To hide user input when running a script: echo "Enter the root password" stty_orig="stty -g" stty -echo read PASSWORD stty $stty_orig

Posted in Shell | Leave a comment

Bash terminal prompt and colours

In ~/.bashrc I have added PS1="\u@\h:\w $ " export LS_OPTIONS=’–color=auto’ eval `dircolors` alias ls=’ls $LS_OPTIONS’ This gives me bash shell auto colors and the user, hostname and present working directory on my command prompt. CentOS users: use the file ~/.bash_profile

Posted in Shell | Leave a comment