Monday, April 10, 2023

How to fix "E: You don't have enough free space in /var/cache/apt/archives/."

If the root directory is tight and

apt-upgrade 

is giving you:

E: You don't have enough free space in /var/cache/apt/archives/

then you can move apt's cache somewhere else:

mv /var/cache/apt/ /home
ln -s /home/apt/ /var/cache/apt
 

later undo with:

rm /var/cache/apt
mv /home/apt /var/cache

--------------------------------------------------------

various housekeeping things

apt clean 

apt autoremove

journalctl --rotate

journalctl --vacuum-time=1s 

remove old logs

find /var/log -mtime +2 -type f -delete

rm /var/cache/locate/locatedb

-------------------------------------------------------

other things that may help actually squeeze the root filesystem 


find all the files larger than 50M on the / partition (ignoring sub-mounts!)
find / -mount -type f -size +50M -exec du -h {} \; | sort -n
 
find installed packages in size order 
dpkg-query --show --showformat='${Package;-50}\t${Installed-Size}\n' | sort -k 2 -n | grep -v deinstall | awk '{printf "%.3f MB \t %s\n", $2/(1024), $1}'


Tuesday, February 14, 2023

How to Change the Default Browser in Debian Linux

xdg-open https://lichess.org/training/kAngL

xdg-settings get default-web-browser

xdg-settings set default-web-browser firefox.desktop

xdg-open https://lichess.org/training/kAngL

xdg-settings set default-web-browser debian-sensible-browser.desktop



Thursday, January 19, 2023

To Move the Most Recent Files

This command will move the five most recent files in the ~/Downloads directory to the current directory

 

find ~/Downloads -maxdepth 1 -type f -printf '%T@ %p\n' | sort -rn | cut -d' ' -f2- | head -n 5 | xargs -I{} echo mv {} .

 

to do a dry run! remove echo to actually do it.

Tuesday, October 18, 2022

Batch Renaming Files with Wildcards

First make sure you've got your files version controlled, because this has a way of going horribly wrong and you want to be able to reset to your starting state when it does.

On debian 11, you want the rename package

sudo apt install rename

This provides the perl renamer. Check you've got the right one, because there are many different rename commands provided by different packages!

$ rename -V
/usr/bin/rename using File::Rename version 1.13, File::Rename::Options version 1.10

find a way to isolate all the files you want to rename using shell wildcards

$ ls account*

'accounts 2008-2009.ods'  'accounts 2011-2012.ods'  'accounts 2014-2015.ods'

Now come up with a perl/sed replacement expression that changes the spaces to dashes

$ rename 's/\ /-/' account*

$ ls account*
accounts-2008-2009.ods  accounts-2011-2012.ods  accounts-2014-2015.ods

 

Thursday, April 8, 2021

Using feh to move images from Desktop to Screensaver images directory

feh -FZ --no-jump-on-resort --draw-actions --draw-filename ~/Desktop -A "mv --backup=t %F /home/john/Desktop/unison/screensaver-images"
 

Package Suggestions for Debian Command Not Found

sudo apt-get install command-not-found
sudo update-command-not-found

Using ffmpeg to batch convert images from webp to png

for i in *.webp; do ffmpeg -i "$i" "${i%.*}.png"; done