<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>linux Archives - Alexandros Georgiou</title>
	<atom:link href="https://www.alexgeorgiou.gr/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.alexgeorgiou.gr/tag/linux/</link>
	<description>Balancing brackets for a living</description>
	<lastBuildDate>Sat, 05 Apr 2025 09:22:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://www.alexgeorgiou.gr/wp-content/uploads/2021/07/cropped-alexgeorgiou-icon-32x32.png</url>
	<title>linux Archives - Alexandros Georgiou</title>
	<link>https://www.alexgeorgiou.gr/tag/linux/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>🖴 Clean up all your Caches before taking a Full System Backup of your Linux machine</title>
		<link>https://www.alexgeorgiou.gr/cleanup-before-full-system-image-backup/</link>
					<comments>https://www.alexgeorgiou.gr/cleanup-before-full-system-image-backup/#comments</comments>
		
		<dc:creator><![CDATA[alexg]]></dc:creator>
		<pubDate>Sat, 05 Apr 2025 09:17:27 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ssd]]></category>
		<category><![CDATA[trim]]></category>
		<guid isPermaLink="false">https://www.alexgeorgiou.gr/?p=1834</guid>

					<description><![CDATA[<p>How to cleanup unnecessary data on Linux before taking a full-system image backup of your disk.</p>
<p>The post <a href="https://www.alexgeorgiou.gr/cleanup-before-full-system-image-backup/">🖴 Clean up all your Caches before taking a Full System Backup of your Linux machine</a> appeared first on <a href="https://www.alexgeorgiou.gr">Alexandros Georgiou</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Over the years I have learned the importance of taking backups:</p>



<ul class="wp-block-list">
<li>Less downtime</li>



<li>Less stress</li>



<li>Less loss of work</li>
</ul>



<p>I have set my calendar to periodically take various types backups.</p>



<p>Yes, <a href="https://gist.github.com/nooges/817e5f4afa7be612863a7270222c36ff" target="_blank" rel="noreferrer noopener">taking backups is hard</a>, takes time and practice to do correctly, requires constant vigilance, and is an annoyance. But the stress I used to undergo every time the system breaks, is something I don&#8217;t want to experience ever again. As I grow older, the impact of this amount of stress on my health is noticeable.</p>



<h2 class="wp-block-heading">Types of backups</h2>



<p>I have different types of backups.</p>



<ul class="wp-block-list">
<li><a href="https://www.alexgeorgiou.gr/poor-mans-guide-backup-wordpress-droplets/">Daily backups of my WordPress sites.</a> These are done by cron, but I check on them weekly.</li>



<li>Weekly backups of my git repositories to a Raspberry Pi and to an online droplet. I have a script that pushes all the master branches from all the repositories to a dedicated backup upstream.</li>



<li>Monthly full disk backups of my dev machine.</li>
</ul>



<p>This article is about the last type of backup. These protect me mostly against situations where something goes horribly wrong at the system level, or even in the case of a disk failure.</p>



<p>File systems often contain a lot of unnecessary clutter: caches, temporary files, old Docker images, unused Snap or Flatpak apps, and more. Backing up this bloat not only slows down the process, but also increases storage requirements and backup times unnecessarily.</p>



<p>In this article, I&#8217;ll walk you through my script that minimizes the amount of data that needs to be copied before taking a full disk backup.</p>



<p>The advantages of cleaning up caches before a backup are obvious:</p>



<ul class="wp-block-list">
<li><strong>Smaller backups</strong>: Removing cache and orphaned files significantly reduces the size of the disk backup. Typically a few gigabytes are saved every time.</li>



<li><strong>Faster backup time</strong>: Especially with SSDs, where the more blocks are TRIMMED, the faster the disk copies and compresses.</li>
</ul>



<p>Here’s a breakdown of what each step of my cleanup script does:</p>



<h3 class="wp-block-heading">Time to take out the trash</h3>



<p>First, install a tool that cleans the trash (if not already installed) and then clean the trash:</p>



<pre class="wp-block-code"><code>sudo apt install trash-cli -y &amp;&amp; trash-empty -f</code></pre>



<h3 class="wp-block-heading">Clean up any dev projects</h3>



<p>In my case, I have a lot of projects that are managed (and cleaned) with <code>grunt</code> or <code>flutter</code>. So I iterate over all of them and clean them. I also invoke the <code>git</code> garbage collector on my repositories:</p>



<pre class="wp-block-code"><code>gitdir="/home/alexg/workspace"
cd $gitdir

for p in grunt-project-1 grunt-project-2 grunt-project-3; do
    pushd "${gitdir}/${p}" &amp;&amp; grunt clean &amp;&amp; git gc --aggressive &amp;&amp; popd
done

for p in flutter-project-1 flutter-project-2 flutter-project-3; do
    pushd "${gitdir}/${p}" &amp;&amp; flutter clean &amp;&amp; git gc --aggressive &amp;&amp; popd
done</code></pre>



<h3 class="wp-block-heading">Clear package manager caches</h3>



<pre class="wp-block-code"><code>npm cache clean --force
composer clear-cache
pip cache purge</code></pre>



<p>These commands free up space by clearing the cache used by popular package managers: Node (<code>npm</code>), PHP (<code>composer</code>), and Python (<code>pip</code>).</p>



<h3 class="wp-block-heading">Docker cleanup</h3>



<pre class="wp-block-code"><code>docker system prune -a --volumes -f
docker image prune</code></pre>



<p>Removes all unused Docker containers, networks, images, and volumes. This can recover <em>gigabytes</em> of space.</p>



<h3 class="wp-block-heading">APT package manager cleanup</h3>



<pre class="wp-block-code"><code>sudo apt autoremove -y
sudo apt autoclean -y
sudo apt clean</code></pre>



<p>Cleans up unused packages and downloaded <code>.deb</code> files from system updates.</p>



<h3 class="wp-block-heading">System journal cleanup</h3>



<pre class="wp-block-code"><code>sudo journalctl --vacuum-time=2weeks</code></pre>



<p>Truncates system logs to only retain entries from the last 2 weeks. Can save a few gigabytes.</p>



<h3 class="wp-block-heading">Remove temporary and cache files</h3>



<pre class="wp-block-code"><code>rm -rf /tmp/*
find ~ -type d -name "__pycache__" -exec rm -rf {} +
rm -rf ~/.cache/fontconfig/*
sudo fc-cache -rv
rm -rf ~/.cache/thumbnails/*
rm -rf ~/.cache/{mozilla/firefox,google-chrome,chromium}/*
find /var/tmp -type f -atime +10 -delete
sudo rm -rf /var/cache/*
</code></pre>



<p>These commands remove temporary files and caches from various locations including Python bytecode caches, font cache, browser caches, and more.</p>



<h3 class="wp-block-heading">Remove unused applications</h3>



<pre class="wp-block-code"><code>flatpak uninstall --unused
sudo snap list --all | awk '/disabled/{print $1, $3}' | while read snapname revision; do sudo snap remove "$snapname" --revision="$revision"; done</code></pre>



<p>Removes unused Flatpak apps and old Snap package revisions.</p>



<h3 class="wp-block-heading">Final user-level cleanup</h3>



<pre class="wp-block-code"><code>rm -rf ~/.wine/drive_c/windows/temp/*
find ~/.cache -type f -atime +10 -delete
tracker reset --hard ; tracker daemon --stop</code></pre>



<p>Cleans Wine temporary files, aged cache files, and resets GNOME&#8217;s Tracker file indexer.</p>



<h3 class="wp-block-heading">TRIM your SSD</h3>



<pre class="wp-block-code"><code>sudo fstrim / --verbose</code></pre>



<p>Issues a TRIM command to the SSD, letting it know which blocks are no longer in use. When taking a full backup, these empty blocks will be read at lightning-fast speed, and will be compressed significantly with <code>gzip</code> since these are entire disk blocks of zeroes.</p>



<h3 class="wp-block-heading">Zero out your mechanical disk</h3>



<p>If you are using a mechanical disk you can skip this step, but it may be useful to zero out your empty space:</p>



<pre class="wp-block-code"><code>cat /dev/zero >~/zero ; rm zero</code></pre>



<h2 class="wp-block-heading">Full system backup to an external mechanical disk, using live USB</h2>



<p>Once the system is cleaned, it’s time to create a full disk image. This should be done from a Live USB environment, with the system disk unmounted, to ensure a consistent snapshot. Here’s how I do it:</p>



<pre class="wp-block-code"><code>umount /dev/sdX
sudo dd if=/dev/sdX status=progress conv=sync,noerror | gzip > /mnt/backup/system-backup-$(date +%F).img.gz</code></pre>



<ul class="wp-block-list">
<li>Replace <code>sdX</code> with your actual device (e.g., <code>/dev/sda</code>).</li>



<li><code>status=progress</code>: Show live progress during the backup.</li>



<li><code>conv=sync,noerror</code>: Ensures that read errors don’t abort the process and fills blocks with zeroes if needed.</li>
</ul>



<h2 class="wp-block-heading">Consistency is key</h2>



<p>I have set a recurring reminder in my calendar to do this monthly.</p>



<p>I keep the last few backups and delete the oldest one every time.</p>



<p>Yes, it takes time, but it helps me sleep easier.</p>
<p>The post <a href="https://www.alexgeorgiou.gr/cleanup-before-full-system-image-backup/">🖴 Clean up all your Caches before taking a Full System Backup of your Linux machine</a> appeared first on <a href="https://www.alexgeorgiou.gr">Alexandros Georgiou</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.alexgeorgiou.gr/cleanup-before-full-system-image-backup/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>🪔 Open terminal with shell here in Geany</title>
		<link>https://www.alexgeorgiou.gr/geany-terminal-shell-here-directory/</link>
					<comments>https://www.alexgeorgiou.gr/geany-terminal-shell-here-directory/#respond</comments>
		
		<dc:creator><![CDATA[alexg]]></dc:creator>
		<pubDate>Tue, 24 Jan 2017 19:20:10 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Geany]]></category>
		<category><![CDATA[gnome-terminal]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[working directory]]></category>
		<guid isPermaLink="false">http://www.alexgeorgiou.gr/?p=182</guid>

					<description><![CDATA[<p>How to open a shell here, in the directory of the file you're currently editing in Geany.</p>
<p>The post <a href="https://www.alexgeorgiou.gr/geany-terminal-shell-here-directory/">🪔 Open terminal with shell here in Geany</a> appeared first on <a href="https://www.alexgeorgiou.gr">Alexandros Georgiou</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><em>How to open a shell in the directory of the file you&#8217;re currently editing in Geany.</em></p>
<h2>Shell here!</h2>
<p>Apologies if you were expecting something WordPress-related. This article is NOT about WordPress. It&#8217;s about opening a shell here and now, in the directory of the file you&#8217;re currently editing.</p>
<p><a href="https://www.geany.org/" target="_blank" rel="noopener">Geany</a> is the perfect IDE for any type of coding that is not your main development. I use it all the time for scripting, configuring, building, tooling, installing, uninstalling, and generally nerding out.</p>
<h2>Geany, open <del>sesame</del> err, shell!</h2>
<p>Go to <em>Tools</em> and then to <em>Plugin Manager</em>. Enable the <em>File Browser</em>. The file browser will appear as a new tab on the left-hand-side of the screen, along with <em>Symbols</em> and <em>Documents</em>. Now you can observe your file in its native habitat, the directory.</p>
<p>Now if you go to <em>Edit</em> and then select <em>Plugin Preferences</em>, you should see a field titled <em>External Open Command</em> which defaults to</p>
<pre>nautilus "%d"</pre>
<p>If you&#8217;re on Ubuntu, you&#8217;re probably using <code>gnome-terminal</code> as your terminal emulator. Change the line to</p>
<pre>gnome-terminal --working-directory="%d"</pre>
<p><img fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-185" src="http://www.alexgeorgiou.gr/wp-content/uploads/2017/01/geany-settings.png" alt="In Geany, if you go to Edit and then select Plugin Preferences, you should see a field titled External Open Command." width="482" height="425" srcset="https://www.alexgeorgiou.gr/wp-content/uploads/2017/01/geany-settings.png 482w, https://www.alexgeorgiou.gr/wp-content/uploads/2017/01/geany-settings-300x265.png 300w" sizes="(max-width: 599px) calc(100vw - 50px), (max-width: 767px) calc(100vw - 70px), (max-width: 991px) 429px, (max-width: 1199px) 637px, 354px" /></p>
<p>Also click on <em>Follow the path of the current file</em>. It makes sure that the <em>File Browser</em> shows you the directory of the current file as you switch between editor tabs.</p>
<p>Now, when you right-click on a file, and choose <em>Open Externally</em>, you will get a new shell in the directory where that file resides.</p>
<h2>But I miss nautilus!</h2>
<p>If you&#8217;re missing the ability to open <code>nautilus</code>, just remember that once you have a terminal open, you can always issue this command:</p>
<pre>nautilus .</pre>
<p>(Note the dot, which is the current directory.)</p>
<p>If you know of a better/faster way that doesn&#8217;t involve writing a plugin, please comment. I&#8217;d like to know.</p>
<p>&nbsp;</p>
<p>The post <a href="https://www.alexgeorgiou.gr/geany-terminal-shell-here-directory/">🪔 Open terminal with shell here in Geany</a> appeared first on <a href="https://www.alexgeorgiou.gr">Alexandros Georgiou</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.alexgeorgiou.gr/geany-terminal-shell-here-directory/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
