Command Line Cheatsheet

cd

quick return to previous directory

cd -
  • TIP: Using “cd -” consecutively, you can swap back and forth between two directories.

dpkg

backup package listing

dpkg --get-selections \* > package.list
  • NOTE: Delete the “\*” from the above line, if you don't want the listing to include “purged” packages

restore packages (on new machine or after reinstall)

dpkg --set-selections < package.list
dselect update
apt-get dselect-upgrade

place a hold on a package

echo "<package> hold" | dpkg --set-selections

prevent long package names from getting truncated

COLUMNS=160 dpkg -l

rebuild the "dselect" database, if something really goes wrong

perl -i.bak -pe 'if (/^Status: [^\s]+ ([^\s]+) ([^\s]+)/) { $_="Status: ".($2 eq "installed" ? "install" : "purge")." $1 $2\n"}' /var/lib/dpkg/status

duplicity

Duplicity is a backup utility which provides incremental, encrypted, network backups using the rsync algorithm, scp/ftp/rsync as a transfer mechanism, and support for gpg.

git

initial git setup

git config --global user.name "Tom Hoover"
git config --global user.email tom@hisword.net
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
git config --global alias.ci commit
git config --global alias.co checkout

start a new project

cd project
git init
git add .
git commit

create bare repository

cd ..             # must be outside project directory
git clone --bare ./project project.git
scp -r project.git example.com:public

push to public repository

git push ssh://example.com/home/username/public/project.git

     OR, you can add the following lines to your .gitconfig file, and then "git push example.com":

[remote "example.com"]
     url = ssh://example.com/home/username/public/project.git

screen

print a list of active screen sessions

screen -ls

attach to an active screen session

screen -DR

ssh

copy public key to "authorized_keys" on remote server

cat ~/.ssh/id_dsa.pub | ssh myname@mydomain.org "cat - >> .ssh/authorized_keys"

start mutt via ssh on remote server

ssh -X <host> -l <user> xterm -e mutt
 
computers/commandline.txt · Last modified: 2008/06/21 23:35 by tom
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki