{"id":4789,"date":"2017-04-09T18:48:07","date_gmt":"2017-04-09T18:48:07","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=4789"},"modified":"2021-10-06T15:01:52","modified_gmt":"2021-10-06T15:01:52","slug":"ubuntu-server-updating","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/ubuntu-server-updating\/","title":{"rendered":"Ubuntu server updating"},"content":{"rendered":"<p>Every month (at least) I check my Ubuntu servers for updates and every month (at least) I forget how I clean old installs etc. <\/p>\n<p>The following is a list of commands that I use regularly. This post is not meant to be a comprehensive description of these Linux\/Ubuntu commands, more a checklist for updating my servers.<\/p>\n<p><strong>df or df \/boot<\/strong><\/p>\n<p>When I log into my servers and see updates available the first thing I tend to do is run <em>df<\/em> and check the \/boot usage\/space available (obviously I could jump straight to the next command in my list, but I sort of like knowing what space I have available). I&#8217;ve tried carrying out an update in the past with next to no space available and sadly end up spending way too long trying to clear up partially installed components and\/or clear disc space. <\/p>\n<p>Alternatively, if you only want to view the \/boot usage\/space &#8211; which is really what we&#8217;re after here, just use <em>df \/boot<\/em>.<\/p>\n<p><strong>sudo apt-get autoremove<\/strong><\/p>\n<p>apt-get is the Ubuntu based package manager (well, it&#8217;s actually originally from Debian), we&#8217;ll need to run it as the su. The options supplied will remove old packages and configurations files and all unused packages. <\/p>\n<p>Why is the above useful? Well as we add updates to Ubuntu, it&#8217;s not unusual to find previous releases sat on our machine in the \/boot area (I assume this is so we could roll back a release). Once you&#8217;re happy with your latest updates (or as I do, prior to the next update), run this command <em>sudo apt-get autoremove<\/em> to clear out these unused packages and free up disc space.<\/p>\n<p><strong>sudo apt-get update<\/strong><\/p>\n<p>The update option will retrieve a new list of packages available. This doesn&#8217;t install new versions of software but will ensure all package index files are upto date.<\/p>\n<p><strong>sudo apt-get upgrade<\/strong><\/p>\n<p>Now its time to upgrade we run <em>sudo apt-get upgrade<\/em>. This will look to clear out old packages if required, but doesn&#8217;t seem to do a more comprehensive removal, unlike purge and autoremove.<\/p>\n<p>This command uses information from <em>apt-get update<\/em> to know about new versions of packages on the machine.<\/p>\n<p><strong>sudo apt-get dist-upgrade<\/strong><\/p>\n<p>If we want upgrade dependencies etc. this can be used instead of the straight <em>upgrade<\/em>.<\/p>\n<p><strong>sudo reboot now<\/strong><\/p>\n<p>Time to restart the server. This will obviously reboot the machine instantly (now).<\/p>\n<p><strong>uname -r<\/strong><\/p>\n<p>I don&#8217;t tend to use this during my &#8220;update&#8221; process, but if I want to know what version of the Linux kernel I&#8217;m running, using <em>uname -r<\/em> will tell me. This does become important if (as has happened to me) I cannot autoremove old kernels. Obviously when targeting specific kernels you need to know which one is current, or to put it another way, which one to <strong>not remove<\/strong>.<\/p>\n<p>So for example, at the time of this post my current kernel is<\/p>\n<p>4.4.0-72-generic<\/p>\n<p><strong>dpkg -l | grep linux-image<\/strong><\/p>\n<p>If you want to see what kernels exist on your machine, use <em>dpkg -l | grep linux-image<\/em>. This will (in conjunction with <em>uname -r<\/em>) allow us to target a purge of each kernel individually, using the following command.<\/p>\n<p><strong>sudo apt-get -y purge linux-image-?.?.?-??-generic<\/strong><\/p>\n<p>Obviously replace ?.?.?-?? with the version you wish to remove. This will then remove that specific package.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Every month (at least) I check my Ubuntu servers for updates and every month (at least) I forget how I clean old installs etc. The following is a list of commands that I use regularly. This post is not meant to be a comprehensive description of these Linux\/Ubuntu commands, more a checklist for updating my [&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":[58,140],"tags":[],"class_list":["post-4789","post","type-post","status-publish","format-standard","hentry","category-linux","category-ubuntu"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/4789","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=4789"}],"version-history":[{"count":5,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/4789\/revisions"}],"predecessor-version":[{"id":8945,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/4789\/revisions\/8945"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=4789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=4789"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=4789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}