When copying a large file on Linux transfer hangs at the end… And you want to f**king kill someone.

There’s an annoying bug in almost every Linux distribution I’ve worked with. When your copying a large file to usb device (pendrive etc.) it hangs at the end (I mean it haaaaaaaaaaaaangs).

I’ve found a solution that works on Elementary and Ubuntu (at least).

Simply paste this two commands in your terminal:

sudo sh -c 'echo $((48*1024*1024)) > /proc/sys/vm/dirty_bytes'
sudo sh -c 'echo $((16*1024*1024)) > /proc/sys/vm/dirty_background_bytes'

Add this to some kind of startup script and forget about transfer problems…

How to watch file count in a directory (Linux/macOS)?

If you want to monitor file count in some directory simply use this:

watch "ls -A | wc -l"

You can also mask specific files using asterisk char:

watch "ls sess* -A | wc -l"

If you get Argument list too long error, please change command syntax to this:

watch "ls -U | grep -c '^sess'"

How to unfreeze KDE’s plasmashell?

I’m using Debian 9.4 and this freaking KDE5 is freezing very often! What you can do when your desktop stops responding? Restart computer? Use ALT+CTRL+F1…12? Nah! There’s a better solution!

Simply edit your  ~/.bash_aliases:

nano ~/.bash_aliases

And append to it:

alias restart-plasma='kquitapp5 plasmashell && kstart plasmashell'

Now whenever your plasma desktop starts trolling you, go to your console and type restart-plasma voilàDezombified!

PS. Use tilda to open console in every shitty situation you’ll get into! Simply press F12 and you’ll get nice Quake like terminal.

Feel like a ninja
Feel like a Linux ninja

Quick optimization of jpeg files in a directory (Linux bash)

Firstly install jpegoptim.

You can do this on Debian like systems using apt:

sudo apt-get update && sudo apt-get install jpegoptim

Then go to directory with jpeg files and use this command:

find . -name '*.jpg' -exec jpegoptim -m70 -o -f --strip-all {} \;

It will find all jpg files recursively and optimize with following settings:

  • m70 stands for jpeg quality (about 70 – 80 should be fine but lossy)
  • o is for overwrite
  • f is for force
  • strip-all removes all EXIF and other textual data from files