apt-get install deborphan -y && \
apt-get autoremove --purge libx11-.* lxde-.* raspberrypi-artwork xkb-data omxplayer penguinspuzzle sgml-base xml-core alsa-.* cifs-.* samba-.* fonts-.* desktop-* gnome-.* && \
apt-get autoremove --purge $(deborphan) && \
apt-get autoremove --purge && \
apt-get autoclean
(this is worth looking at http://www.stefan-seelmann.de/wiki/rasperrypi-homeserver, which is basically this:
apt-get purge --auto-remove scratch debian-reference-en dillo idle3 python3-tk idle python-pygame python-tk lightdm gnome-themes-standard gnome-icon-theme raspberrypi-artwork gvfs-backends gvfs-fuse desktop-base lxpolkit netsurf-gtk zenity xdg-utils mupdf gtk2-engines alsa-utils lxde lxtask menu-xdg gksu midori xserver-xorg xinit xserver-xorg-video-fbdev libraspberrypi-dev libraspberrypi-doc dbus-x11 libx11-6 libx11-data libx11-xcb1 x11-common x11-utils lxde-icon-theme gconf-service gconf2-common python-rpi.gpio
)
Warning: this will probably break something. If you need sound, don't remove the "alsa" packages
sudo apt-get --yes purge xserver-common x11-xfs-utils x11-xserver-utils xinit libsmbclient blt gvfs gvfs-backends gvfs-daemons gvfs-fuse idle idle-python2.7 idle-python3.2 idle3 libaudio2 libice6 liblightdm-gobject-1-0 libobrender27 libpulse0 libqt4-svg libqtgui4 libsdl-image1.2 libsdl-mixer1.2 libsdl-ttf2.0-0 libsdl1.2debian libsm6 libsmpeg0 libwebkitgtk-1.0-0 libwebkitgtk-3.0-0 libxaw7 libxklavier16 libxmu6 libxss1 libxt6 libxtst6 lightdm lightdm-gtk-greeter lxde lxde-core midori nano obconf openbox python-pygame python-tk python3-tk scratch tk8.5 wpagui x11-common x11-utils x11-xkb-utils xinit xserver-common xserver-xorg xserver-xorg-core xserver-xorg-input-all xserver-xorg-input-evdev xserver-xorg-input-synaptics xserver-xorg-video-fbdev zenity xserver* x11-common x11-utils x11-xkb-utils x11-xserver-utils xarchiver xauth xkb-data console-setup xinit lightdm libx{composite,cb,cursor,damage,dmcp,ext,font,ft,i,inerama,kbfile,klavier,mu,pm,randr,render,res,t,xf86}* lxde* lx{input,menu-data,panel,polkit,randr,session,session-edit,shortcut,task,terminal} obconf openbox gtk* libgtk* alsa* nano python-pygame python-tk python3-tk scratch tsconf desktop-file-utils cifs-utils samba-common smbclient
The above, plus (Warning, not really tested, may break stuff (eg my wireless broke after doing this))
sudo apt purge cups-bsd cups-client fuse gettext-base ghostscript gnome-accessibility-themes gnome-themes-standard-data libasound2 libasyncns0 libcaca0 libcupsimage2 libfile-copy-recursive-perl libflac8 libfm-data libfuse2 libgs9 libgs9-common libid3tag0 libijs-0.35 libjbig2dec0 libmad0 libmtdev1 libogg0 libpaper-utils libpaper1 libpciaccess0 libportmidi0 libsamplerate0 libsndfile1 libutempter0 libvorbis0a libvorbisenc2 libvorbisfile3 libvte-common libwnck-common poppler-data tcl8.5 update-inetd xbitmaps zenity-common aspell aspell-en console-setup-linux cups-common dconf-gsettings-backend dconf-service dictionaries-common fontconfig fontconfig-config gconf2-common glib-networking glib-networking-common glib-networking-services gsettings-desktop-schemas gsfonts hicolor-icon-theme iso-codes libaspell15 libatk1.0-0 libatk1.0-data libavahi-client3 libavahi-common-data libavahi-common3 libavahi-glib1 libbluetooth3 libck-connector0 libcups2 libdatrie1 libdrm2 libenchant1c2a libexif12 libfontconfig1 libfontenc1 libgconf-2-4 libgdk-pixbuf2.0-common libglapi-mesa libjasper1 liblcms2-2 libltdl7 libmng1 liborc-0.4-0 libpam-ck-connector libpixman-1-0 libpolkit-agent-1-0 libthai-data libthai0 netsurf-common sgml-base xml-core
apt-get purge
might delete these for you:
sudo rm -r /usr/lib/xorg/modules/linux /usr/lib/xorg/modules/extensions /usr/lib/xorg/modules /usr/lib/xorg rm -r ~/Desktop rm -r ~/python_games
It's a good idea to regenerate the ssh keys rather than use the ones on the image.
sudo rm /etc/ssh/ssh_host_* && sudo dpkg-reconfigure openssh-server
You may need to clear out the old keys in .ssh/know_hosts
on the client:
ssh-keygen -R [IP]
sudo apt-get install git-core sudo wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update && sudo chmod +x /usr/bin/rpi-update sudo rpi-update sudo shutdown -r now
see https://github.com/Hexxeh/rpi-update for more info