Categories
Linux

How to remove all cover art from MP3s.

Open a terminal window and go to your MP3 folder. Run the following command (you might have to install eyeD3 first for our linux distribution.) :

eyeD3 *.mp3 --remove-all-images
Categories
Linux Red Hat Ubuntu

Bash: remove trailing slash from a variable

Suppose you have a variable containing a directorypath:

#!/bin/bash
directorytouse="/home/myhome/whateverdirectory/"

If you try to test in your bash script if the directory exists, then it will fail because of the trailing slash:

if [ ! -d "${directorytouse} ] 
then
    echo -e "directory does not exist!"
fi

The easiest way to remove this / if it is present is to use shell parameter expansion:

if [ ! -d "${directorytouse%/}" ]
then
    echo -e "directory does not exist!"
fi

This will get rid of the trailing slash if there is one. If there is no trailing slash present, then nothing will happen.

Categories
Linux Red Hat Ubuntu

Vi (or Vim) session no longer responding?

If your Vi or Vim session is hanging and is not responding to anything, then it might be because you pressed CTRL+S accidentally (out of habbit). To fix this, just press CTRL+Q to unblock the session.

Categories
Dell XPS15 Laptop Linux Ubuntu

No wifi or no external monitor on Dell XPS-15

If your wifi card is not available after booting your Dell XPS-15 laptop (with Ubuntu 20.04 or 22.04), or your external monitor refuses to display anything, please try the following:

start up your laptop without your power supply plugged in, connect with wifi, and/or your external monitor and only then plug in your power supply.

This fix works everytime for me.

Categories
Linux

Ubuntu: reset monitor settings to default

If you want to reset your monitor settings to default through the terminal (your second screen is broken and the settings are ‘shown’ there and you don’t want to restart your laptop), you can use the following command:

xrandr -s 0
Categories
Linux Ubuntu

Ubuntu Server – CTRL-ALT-DEL

If you press CTRL-ALT-DEL on a Ubuntu Server the server will be shut down without asking any confirmation or password. This is of course not a good idea.

To disable this, enter the following commands as root:

systemctl mask ctrl-alt-del.target
systemctl daemon-reload
Categories
Databases DBeaver MySQL

DBeaver: refresh data not showing

If you try to refresh the data in a table while using DBeaver, and no changes are shown, it could be that you are in transactional mode.

To fix this, click on the menu ‘Database’ and select ‘Transaction mode’. Select ‘Auto-commit’ and ‘Serializable’.

Categories
Linux

Linux: using tmux to start server processes

If you want to start a process or command on a linux server and want to return later to check if it ran ok, or if it is still running, then the tmux tool is very handy.

Tmux can do many more things (like split a terminal window in multiple panes), but that is outside the scope of this article.

To start a new session on your server (once you are connected to the server with ssh), type:

tmux new -s mysession

where ‘mysession’ is the name you want to use

Now start whatever command you want.

If you want to leave your session, but keep everything running so you can check back at a later time, press Ctrl-b d.

To list all detached sessions, use the following command:

tmux ls

No you can reattach to a session using the following command:

tmux attach -t mysession

Categories
Backup Linux MySQL

MySQL: backup your databases

I have put an interesting bash script to backup your database on my git page. You can find it here on https://github.com/afeys/backupmysql/.

Feel free to use and modify it however you please. If you add interesting functionality, or find any annoying bugs, then some feedback through github would be nice.

You can use this script interactively by just typing ./backupmysql.sh in the scripts folder, or you can find out about all the parameters it accepts by using the -h switch.

The script also allows you to create config files with all necessary info to backup a database and then run or schedule it with

/home/backupadmin/scripts/backupmysql.sh -c /home/backupadmin/configs/mycompanydatabase.config > /var/log/backupdatabase.log

Where mycompanydatabase.config is a textfile containing something like this:

databasehost = 10.10.10.1
databaseuser = backupuser
databasepassword = myverysecretdatabasepassword
backupmode = DATA
targetdirectory = /mnt/backupserver/backups/databases
tempdirectory = /tmp
comment = daily backup

Categories
Linux MySQL PHP

MySQL: get value of last auto-increment field

If you use an auto increment field (autonumbering) in your database table, you can find the last generated number by performing the following query :

select last_insert_id();

This will get the last id for the current connection. If you close the connection you can’t get the number again, and it will only return the last number for *your* connection. It is kept on a per-connection basis.