12/18/18

Can't delete a symbolic link to a Linux directory!!

I've come across this issue once where I wanted to delete a symbolically linked directory (named foo for this example) on a CentOS box using the "rm" command, and I got this error message:

rm: cannot remove `foo/': Is a directory

which was a little frustrating although simple enough to resolve.

The mistake that led to generating this error message is that I used the autocomplete line by using the tab key to finish off the name of the directory, which is fine for most purposes, but in this particular instance of removing a symbolic link, it introduced an undesirable factor which is the forward slash tacked to the end of the directory name.
So the typed command looked like this: rm foo/ instead of just this rm foo

Basically, the RM command in bash refused to unlink the symbolic link because it saw it as a directory with content within.

So just in case someone else comes across this same issue, all you need to do is remove the trailing slash from the end of your command and the rm command will successfully remove your symbolically linked directory without any fuss.

Another approach is to use the "unlink" command followed by the name of your symbolic link and it'll also work just fine. Just note that the "unlink" command also will generate an error if it sees a trailing slash after the directory name.

So the correct syntax for removing a symbolically linked directory is this:

rm foo

Or

unlink foo

8/1/18

Delete Postfix queued emails From/To specific user


mailq | tail -n +2 | awk 'BEGIN { RS = "" } / user@domain\.com$/ { print $1 }' | tr -d '*!' | postsuper -d -

Or, if using sudo, just add sudo to the part immediately preceding "postsuper":


mailq | tail -n +2 | awk 'BEGIN { RS = "" } / user@domain\.com$/ { print $1 }' | tr -d '*!' | sudo postsuper -d -


Note: This command line was run on a CentOS 6.10 box with Postfix version 2.6.6

3/6/18

Import PEM cert or key into your keystore

Easiest way I know to import a PEM format cert or key file into your Java keystore involves two steps.

1- Convert your PEM format certificate into DER format by using the following command syntax:
openssl x509 -outform der -in yourcert.pem -out yourcert.der

2- Import your resulting DER format certificate into your "cacerts" keystore using this syntax:
keytool -import -alias youralias -keystore cacerts -file yourcert.der

Quick HTTP to HTTPS - Apache2

There are several methods for redirecting your Apache-based website visitors who might type your servers URL using the plain (non-secure) HT...