If you are trying to use a command, fuser, that is used to identify process using lock file or socket file, and having the following error:
-bash: fuser: command not found
that means, your system doesn’t have the psmisc package installed. Usually, killall, fuser type of commands are under this package. CentOS 7 sometimes, do not install the package by default. To install it, run the following:
yum install psmisc -y
Once done, you should be able to use fuser command.
You can obviously use RSA public/private keypair to access servers without password, although, sometimes, it may be desirable to use ssh password on a command line and run a remote command on another server. This can be done using a tool called ‘sshpass’. You can create a simple bash script using sshpass, that can help you monitor and control multiple servers from a single location.
How to use ssh password in script
First install sshpass:
# yum install sshpass -y
Once done, you can use sshpass command as following:
# sshpass -p "SSH_Password" ssh -o StrictHostKeyChecking=no SSH_Username@remote-ssh-server "yourcommand"
Just replace, the password, username, remote-ssh-server and your command with your desired setup, and viola!
Note: If yum says, the following:
No package sshpass* available.
then you would need to install epel repository to install sshpass. To install epel, run the following:
# yum install epel* -y
How To Check if an IP is Available or Not in Bash
A quick trick I use is ‘ping’ command. PING will return 0 on success and 1 or above on failure while using it with -c 1 (Means only one ICMP packet). That makes it useful to use with a if condition shell code as following:
if ping -c 1 -w 5 192.168.2.1 >/dev/null
echo "IP Available"
echo "IP Not Available"
How to Check If A File Exists or Not in Bash Script
You can use if condition in bash script to do that. If conditions takes ‘-f’ to test if a file exists or not. Syntax would be the following:
$FILE = $1
if [ -f $FILE ]; then
echo "File Exists"
echo "File Do Not Exist"
Now, if your script only demands to check if the file do not exist, you can use a unary operator for negate the boolean value as following:
$FILE = $1
if[ ! -f $FILE ]; then
echo "File Do Not Exist"
Sometimes, for development purposes, you may want to restrict access to the folder, only to your IP, and deny others from accessing that folder. One way to do that is to use htaccess rules. A common rule, could be denying all the users and allowing your IP. To find out, your IP, you may visit the following:
Note the IP it has reported. Open the folder that you want to protect. Find the .htaccess file under the folder (If no file available, create one) and add the following:
deny from all
allow from <your IP goes here>
Replace the <your IP goes here> from the snippets with the IP you have noted from ifconfig.co. Now, your folder should be accessible only from your IP.
A common error I have seen users reporting using Laravel, is the following:
SQLSTATE: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
The error actually happens because Laravel 5.5 assumes you have MySQL 5.7.7 or above. While on MySQL 5.7.7 the key size was increased than the older versions.
How to fix laravel Specified key was too long
To fix this, find the AppServiceProvider.php file under app/Providers folder, and add the following line before start of the class:
Then, inside the boot() method under the class, add the following line:
If you restart your laravel migration or the query, it should work fine now.
Sometimes, you may want to run a screen command in a remote server. That makes it necessary to run the command inside the screen session while starting it.
How to start a screen session and run a command in one line
# screen -d -m sh -c "yourcommand"
From the man page of Screen:
-d -m : Start screen in “detached” mode. This creates a new session but doesn’t attach to it. This is useful for system startup scripts.
sh -c: Starts a shell and runs a command for you.
Starting from Cpanel 11.58, Cpanel is offering Free SSL, issued by ‘Cpanel INC’ for free of charge to the valid cpanel license owner. If you are using cpanel, login to your WHM >> Providers >> Enable Cpanel & from Options >> Check Allow AutoSSL to replace invalid or expiring non-AutoSSL certificates.
Now, running upcp should automatically install the free SSL for your cpanel server hostname. If it doesn’t, it is probably because your server IP and the hostname IP are resolving to wrong address. To understand and troubleshoot the problem, run the following script from command line:
This script checks and installs certificate for expired, invalid and self signed certificates for the server services. If you are seeing an error like the following:
[WARN] The system failed to acquire a signed certificate from the cPanel Store because of the following error: (XID 62hp6x) The system queried for a temporary file at “http://server91.mellowhost.com/.well-known/pki-validation/D92868E512FB02354F2498B94E67430B.txt”, but the web server responded with the following error: 404 (Not Found). A DNS (Domain Name System) or web server misconfiguration may exist.
It means, your hostname is resolving to the wrong IP. You would need to check if the hostname is resolving to an IP which has first virtualhost pointed to /var/www/html or not under /etc/apache2/conf/httpd.conf
You must upgrade to Litespeed “5.2.1 build 2 or later”, in order to upgrade to the next version of cPanel & WHM.
The error appears because Litespeed below 5.2.1 doesn’t have SSL compatibility with Cpanel 11.68. Although, this goes further, if you uninstall the plugin, and upcp will still fail to update the Cpanel/WHM. A workaround for this, is to install and uninstall the plugin through Litespeed auto installer. Here is how to do that:
Download Litespeed Auto Installer for Cpanel
# wget https://www.litespeedtech.com/packages/cpanel/lsws_whm_autoinstaller.sh
# chmod a+x lsws_whm_autoinstaller.sh
Install Litespeed for Cpanel/WHM using Auto Installer
# ./lsws_whm_autoinstaller.sh TRIAL 1 8080 username testpass1234 firstname.lastname@example.org 1 0
Uninstall Litespeed WHM Plugin
# /scripts/upcp --force
I had a client ticket today, with the following screenshot:
The error says, ‘server IP address could not be found’. This type of error means there is a DNS resolution error. There could be 3 possibilities:
- Client hasn’t updated the dns nameservers for the domain
- Host’s DNS server is down.
- Client’s DNS resolver isn’t working.
To check if the client has updated the proper dns nameservers, you can use intodns.com. It will also tell you if the host DNS is down or not. If both are ok, you should check if you are able to load other domains using your Internet, if not, it has things to do with the local DNS resolver of your desktop or the ISP. In my case, it was client who failed to update the nameservers of the domain. All that was required to update the nameservers with the server ones.