{"id":267,"date":"2018-05-29T07:05:28","date_gmt":"2018-05-29T06:05:28","guid":{"rendered":"https:\/\/blog.van-daag.nl\/?p=267"},"modified":"2018-06-13T20:08:04","modified_gmt":"2018-06-13T19:08:04","slug":"raspberry-pi-cleanup-script","status":"publish","type":"post","link":"https:\/\/van-daag.nl\/?p=267","title":{"rendered":"Raspberry pi cleanup script"},"content":{"rendered":"<p>Create with the following command in your raspberry pi the script.<\/p>\n<pre class=\"lang:default decode:true\">sudo nano cleanup.sh<\/pre>\n<p>Paste below the text and with\u00a0<strong>CTRL + X\u00a0<\/strong>close nano<\/p>\n<pre title=\"Cleanup.sh\" class=\"lang:sh decode:true\">#!\/bin\/bash\r\n \r\nOLDCONF=$(dpkg -l|grep \"^rc\"|awk '{print $2}')\r\nCURKERNEL=$(uname -r|sed 's\/-*[a-z]\/\/g'|sed 's\/-386\/\/g')\r\nLINUXPKG=\"linux-(image|headers|ubuntu-modules|restricted-modules)\"\r\nMETALINUXPKG=\"linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)\"\r\nOLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL)\r\nYELLOW=\"\\033[1;33m\"\r\nRED=\"\\033[0;31m\"\r\nENDCOLOR=\"\\033[0m\"\r\n \r\nif [ $USER != root ]; then\r\necho -e $RED\"Error: must be root\"\r\necho -e $YELLOW\"Exiting...\"$ENDCOLOR\r\nexit 0\r\nfi\r\n \r\necho -e $YELLOW\"Cleaning apt cache...\"$ENDCOLOR\r\naptitude clean\r\n \r\necho -e $YELLOW\"Removing old config files...\"$ENDCOLOR\r\nsudo aptitude purge $OLDCONF\r\n \r\necho -e $YELLOW\"Removing old kernels...\"$ENDCOLOR\r\nsudo aptitude purge $OLDKERNELS\r\n \r\necho -e $YELLOW\"Emptying every trashes...\"$ENDCOLOR\r\nrm -rf \/home\/*\/.local\/share\/Trash\/*\/** &amp;&gt; \/dev\/null\r\nrm -rf \/root\/.local\/share\/Trash\/*\/** &amp;&gt; \/dev\/null\r\n \r\necho -e $YELLOW\"Script Finished!\"$ENDCOLOR<\/pre>\n<p>To run the script. First:<\/p>\n<pre class=\"lang:default decode:true \">sudo chmod 777 cleanup.sh<\/pre>\n<p>Start the cleanup:<\/p>\n<pre class=\"lang:default decode:true \">Sudo .\/cleanup.sh<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Create with the following command in your raspberry pi the script. sudo nano cleanup.sh Paste below the text and with\u00a0CTRL + X\u00a0close nano #!\/bin\/bash OLDCONF=$(dpkg -l|grep &#8220;^rc&#8221;|awk &#8216;{print $2}&#8217;) CURKERNEL=$(uname -r|sed &#8216;s\/-*[a-z]\/\/g&#8217;|sed &#8216;s\/-386\/\/g&#8217;) LINUXPKG=&#8221;linux-(image|headers|ubuntu-modules|restricted-modules)&#8221; METALINUXPKG=&#8221;linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)&#8221; OLDKERNELS=$(dpkg -l|awk &#8216;{print $2}&#8217;|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL) YELLOW=&#8221;\\033[1;33m&#8221; RED=&#8221;\\033[0;31m&#8221; ENDCOLOR=&#8221;\\033[0m&#8221; if [ $USER != root ]; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,29,13],"tags":[],"class_list":["post-267","post","type-post","status-publish","format-standard","hentry","category-hardware","category-linux","category-raspberry"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/van-daag.nl\/index.php?rest_route=\/wp\/v2\/posts\/267","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/van-daag.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/van-daag.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/van-daag.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/van-daag.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=267"}],"version-history":[{"count":4,"href":"https:\/\/van-daag.nl\/index.php?rest_route=\/wp\/v2\/posts\/267\/revisions"}],"predecessor-version":[{"id":281,"href":"https:\/\/van-daag.nl\/index.php?rest_route=\/wp\/v2\/posts\/267\/revisions\/281"}],"wp:attachment":[{"href":"https:\/\/van-daag.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/van-daag.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/van-daag.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}