Category Archives: Linux

Detect a failing hard-disk on a Linux server

When there is an hard-disk failing issue generally the file system will be read-only. You would get errors like these: rm: cannot remove ‘error.log’: Read-only file system cannot create temp file for here-document: Read-only file system -bash: df: command not foundrm: cannot remove ‘error.log’: Read-only file system cannot create temp file for here-document: Read-only file […]

Certbot.errors.CertStorageError: expected to be a symlink

Example certbot error message: certbot.errors.CertStorageError: expected /etc/letsencrypt/live/www.website.com/cert.pem to be a symlink Renewal configuration file /etc/letsencrypt/renewal/www.website.com.conf is broken. Skipping.certbot.errors.CertStorageError: expected /etc/letsencrypt/live/www.website.com/cert.pem to be a symlink Renewal configuration file /etc/letsencrypt/renewal/www.website.com.conf is broken. Skipping. Solution is to re-create the symlinks for all .pem files: rm -f /etc/letsencrypt/live/www.website.com/*.pem ln -s /etc/letsencrypt/archive/www.website.com/cert1.pem /etc/letsencrypt/live/www.website.com/cert.pem ln -s /etc/letsencrypt/archive/www.website.com/chain1.pem /etc/letsencrypt/live/www.website.com/chain.pem ln -s /etc/letsencrypt/archive/www.website.com/fullchain1.pem […]

Example hard-disk error logs on a Linux server

Here is an example of logs related to a failing hard-disk: root@server:~# cat /var/log/syslog   Dec 3 02:35:54 server kernel: [6703851.044036] sd 0:2:0:0: [sda] tag#18 FAILED Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK Dec 3 02:35:54 server kernel: [6703851.044065] sd 0:2:0:0: [sda] tag#18 CDB: Write(10) 2a 00 31 20 31 00 00 01 00 00 Dec 3 02:35:54 server […]

Certbot renew error: Account at does not exist.

If you get this certbot error: – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – Processing /etc/letsencrypt/renewal/www.website.com.conf – – – – – – – […]

Exclude Packages from Apt-Get Upgrade on Debian Linux

To exclude/hold a package from apt-get upgrade type: apt-mark hold package_nameapt-mark hold package_name For example, to exclude MariaDB mysql packages type: apt-mark hold libmariadbclient18 mariadb-client-10.3 mariadb-client-core-10.3 mariadb-common mariadb-server mariadb-server-10.3 mariadb-server-core-10.3 mysql-commonapt-mark hold libmariadbclient18 mariadb-client-10.3 mariadb-client-core-10.3 mariadb-common mariadb-server mariadb-server-10.3 mariadb-server-core-10.3 mysql-common Here is an example output: libmariadbclient18 set on hold. mariadb-client-10.3 set on hold. mariadb-client-core-10.3 set […]

What to Select on GRUB-PC Configuration “Install Devices”

Today when I did an “apt-get dist-upgrade” I received this: Looks like GRUB-PC was updated and now it asks: What do you want to do about modified configuration file grub?What do you want to do about modified configuration file grub? I selected “Keep the local version currently installed”. Then it happeared another window asking this: […]

E: Could not get lock /var/lib/dpkg/lock

If you get the following error while doing apt-get upgrade: E: Could not get lock /var/lib/dpkg/lock – open (11: Resource temporarily unavailable) E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?E: Could not get lock /var/lib/dpkg/lock – open (11: Resource temporarily unavailable) E: Unable to lock the administration directory (/var/lib/dpkg/), is […]

Get the Output of a Program in a Variable in Bash

Do you need to get the output of a program in a variable in Bash? There are two simple ways to achieve that: var=`./run.sh params`var=`./run.sh params` Or alternatively you can use $(), i.e: var=$(./run.sh params)var=$(./run.sh params) Remember to not put spaces before or after the = operator. If you need to capture also error messages […]

Capture Multiple Line Output Into a Bash Variable

Lets say you have a bash script “run.sh” that outputs multiple lines, i.e: line1 line2 line3line1 line2 line3 You capture the script output in a bash variable like this: OUTPUT=$(/root/run.sh)OUTPUT=$(/root/run.sh) Now pay attention on how you echo the output: Echo Variable Without Double-Quotes If you echo the variable without the double-quotes: echo $OUTPUTecho $OUTPUT It […]

How to Extract Domain from URL in Bash

Using awk you can extract a domain name from an URL: echo http://example.com/index.php | awk -F[/:] ‘{print $4}’echo http://example.com/index.php | awk -F[/:] ‘{print $4}’ The output is: example.comexample.com