Skip to content

Instantly share code, notes, and snippets.



Last active Sep 28, 2020
What would you like to do?
Clean up the Raspbian default build for the Raspberry Pi

Remove unused packages on Raspberry Pi

(this is worth looking at, 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


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-get --yes purge cups-bsd cups-client fonts-droid fuse gettext-base ghostscript gnome-accessibility-themes gnome-themes-standard-data libasound2 libasprintf0c2 libasyncns0 libaudit0 libcaca0 libcupsimage2 libfile-copy-recursive-perl libflac8 libfm-data libfuse2 libgif4 libgs9 libgs9-common libid3tag0 libijs-0.35 libjbig2dec0 libjson0 libmad0 libmenu-cache1 libmikmod2 libmtdev1 libogg0 libopenjpeg2 libpaper-utils libpaper1 libpciaccess0 libpoppler19 libportmidi0 libqt4-network libqt4-xml libqtdbus4 libsamplerate0 libsndfile1 libutempter0 libvorbis0a libvorbisenc2 libvorbisfile3 libvte-common libwebp2 libwnck-common poppler-data python-numpy python-support 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 libbluray1 libcdio-cdda1 libcdio-paranoia1 libcdio13 libck-connector0 libcolord1 libcups2 libdatrie1 libdconf0 libdrm2 libenchant1c2a libexif12 libfontconfig1 libfontenc1 libgconf-2-4 libgdk-pixbuf2.0-common libgdu0 libglapi-mesa libgnome-keyring-common libgnome-keyring0 libgphoto2-port0 libhunspell-1.3-0 libicu48 libjasper1 libjpeg8 liblcms1 liblcms2-2 libltdl7 libmng1 libnettle4 liborc-0.4-0 libpam-ck-connector libpixman-1-0 libpolkit-agent-1-0 libpolkit-backend-1-0 libproxy0 libqtcore4 libthai-data libthai0 libtiff4 netsurf-common sgml-base ttf-dejavu-core xml-core

If you don't want GPIO

sudo apt-get purge python-rpi.gpio

Clean out any remaining stuff

sudo apt-get --yes autoremove
sudo apt-get --yes autoclean
sudo apt-get --yes clean

remove unneeded directories

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

do an update/upgrade:

sudo apt-get --yes update
sudo apt-get --yes upgrade

Regen ssh keys

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]

RPI update

sudo apt-get install git-core
sudo wget -O /usr/bin/rpi-update && sudo chmod +x /usr/bin/rpi-update
sudo rpi-update
sudo shutdown -r now

see for more info

Change user

Change the pi user to one better suited to you. Mount the SD card in another linux box:

sudo shutdown -h now

put SD card in another linux host

dmesg | tail
sudo mount /dev/sdx2 /mnt/tmp

and perform the following:

sudo vi /mnt/tmp/etc/passwd
sudo vi /mnt/tmp/etc/group
sudo vi /mnt/tmp/etc/shadow
sudo vi /mnt/tmp/etc/gshadow
sudo vi /mnt/tmp/etc/sudoers

sudo mv /mnt/tmp/home/pi /mnt/tmp/home/[username]

umount and put back in your pi:

sudo umount /mnt/tmp

This comment has been minimized.

Copy link

@Eyjafjallajokull Eyjafjallajokull commented Aug 10, 2020

After all this, I still had bluetooth daemon running. Killed by purging bluez package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.