On Ubuntu server, when I run lspci command, I get the error
root@first-vm:~# lspci
-bash: lspci: command not found
root@first-vm:~#
To fix this error, install the package pciutils
apt install -y pciutils
See lspci
On Ubuntu server, when I run lspci command, I get the error
root@first-vm:~# lspci
-bash: lspci: command not found
root@first-vm:~#
To fix this error, install the package pciutils
apt install -y pciutils
See lspci
To install Caddy Webserver on CentOS 7, run
yum install yum-plugin-copr yum copr enable @caddy/caddy yum install caddy
Enable caddy start on boot
systemctl enable caddy
To start caddy, run
systemctl start caddy
Caddy configuration file available at
/etc/caddy/Caddyfile
See Caddy
On a CloudLinux Server, websites stopped working with the error message “Service Unavailable”. On checking error_log in /usr/local/apache/logs, found following error message
[Fri Jul 09 15:32:37.884950 2021] [lsapi:error] [pid 1639593:tid 47853204383488] [client 207.46.13.54:46915] mod_lsapi: [host ronnie.serverok.in] [req GET / HTTP/1.1] Connect to backend failed: connect to lsphp failed: 110
The problem was due to the server got booted using the default CentOS kernel instead of CloudLinux Kernel.
[root@server ~]# uname -a Linux server.serverok.in 3.10.0-1062.9.1.el7.x86_64 #1 SMP Thu May 27 10:10:44 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux [root@server ~]#
If you were using Cloudlinux kernel, “uname -a” command will show kernel with “lve” in the name. Example 3.10.0-962.3.2.lve1.5.56.el7.x86_64
To see the list of kernels available, run
awk -F\' '$1=="menuentry " {print i++ " = "$2}' /etc/grub2.cfg
Example
[root@server ~]# awk -F\' '$1=="menuentry " {print i++ " = "$2}' /etc/grub2.cfg 0 = CloudLinux (3.10.0-962.3.2.lve1.5.56.el7.x86_64) 7.9 (Boris Yegorov) 1 = CloudLinux (3.10.0-1062.9.1.el7.x86_64) 7.9 (Boris Yegorov) 2 = CloudLinux (3.10.0-962.3.2.lve1.5.27.el7.x86_64) 7.9 (Boris Yegorov) 3 = CloudLinux (0-rescue-21361cf887984f57a840ce7ea6a3f75c) 7.9 (Boris Yegorov) [root@server ~]#
To set default kernel, run
grub2-set-default 0
This will set kernel entry to the first entry.
Verify default kernel with
grub2-editenv list
Example
[root@server ~]# grub2-editenv list saved_entry=0 [root@server ~]#
Reboot the server with
reboot
Once rebooted, verify the server is booted with CloudLinux kernel.
The tr command is used to translate text.
Example
root@ok:~# echo "serverok" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ SERVEROK root@ok:~#
You can also use
root@ok:~# echo "serverok" | tr "a-z" "A-Z" SERVEROK root@ok:~#
To change specific chars
root@ok:~# echo "serverok" | tr "sok" "SOK" ServerOK root@ok:~#
To delete char, use -d option
root@ok:~# echo "serverok" | tr -d "ok" server root@ok:~#
See Linux Commands
I have Ubuntu 20.04 computer with skype installed. When I update software using apt update, I get an error
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://repo.skype.com/deb stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 1F3045A5DF7587C3 W: Failed to fetch https://repo.skype.com/deb/dists/stable/InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 1F3045A5DF7587C3 W: Some index files failed to download. They have been ignored, or old ones used instead.
To fix this error, delete the key
sudo apt-key del 1F3045A5DF7587C3
Add the key again with
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1F3045A5DF7587C3
Now you can update software with
sudo apt update sudo apt upgrade -y
See Skype
When i create an lxc container on the Ubuntu server, I get an error
root@instance-20210627-0830:~# lxc-create -t download -n ok Setting up the GPG keyring ERROR: Unable to fetch GPG key from keyserver lxc-create: ok: lxccontainer.c: create_run_template: 1616 Failed to create container from template lxc-create: ok: tools/lxc_create.c: main: 319 Failed to create container ok root@instance-20210627-0830:~#
To fix this, you can run
export DOWNLOAD_KEYSERVER="keyserver.ubuntu.com"
To make it permanent, add it to .bashrc
vi ~/.bashrc
At the end of the file, add
export DOWNLOAD_KEYSERVER="keyserver.ubuntu.com"
You can specify DOWNLOAD_KEYSERVER environment variable for the command with
DOWNLOAD_KEYSERVER="keyserver.ubuntu.com" lxc-create -t download -n mycontainer -- -d ubuntu -r focal -a amd64
Use –keyserver command line argument
lxc-create -t download -n mycontainer -- -d ubuntu -r focal -a amd64 --keyserver hkp://keyserver.ubuntu.com
See lxc
When installing PHP OAuth, I get the following error
configure: error: Couldn't find pcre.h, try installing the libpcre development/headers package ERROR: `/tmp/pear/temp/oauth/configure --with-php-config=/usr/bin/php-config' failed
To fix, install libpcre3-dev
apt install libpcre3-dev
See Errors
On CyberPanel server, FTP was not working. I checked the server with “netstat -lntp” command. No service was listening on port 21. Started pure-ftpd with command
systemctl start pure-ftpd-mysql
To start pure-ftpd on boot, run
systemctl enable pure-ftpd-mysql
Now FTP service started listening on port 21, but login to the FTP server failed with an error “Login authentication failed”.
pure-ftpd on CyberPanel server uses MySQL authentication. We need to configure pure-ftpd to use the “users” table in “cyberpanel” database.
Edit file
vi /etc/pure-ftpd/db/mysql.conf
In this file, you need to add MySQL login details
MYSQLUser MYSQLPassword MYSQLDatabase cyberpanel MYSQLCrypt md5
If you don’t have a MySQL user, create one with
GRANT ALL PRIVILEGES ON *.* TO 'ftpadmin'@'localhost' IDENTIFIED BY 'USER_PASSWORD_HERE' WITH GRANT OPTION; GRANT PROXY ON ''@'' TO 'ftpadmin'@'localhost' WITH GRANT OPTION;
Here is the example config
MYSQLSocket /var/run/mysqld/mysqld.sock MYSQLUser ftpadmin MYSQLPassword MYSQL_USER_PW_HERE MYSQLDatabase cyberpanel MYSQLCrypt md5 MYSQLGetPW SELECT Password FROM users WHERE User='\L' MYSQLGetUID SELECT Uid FROM users WHERE User='\L' MYSQLGetGID SELECT Gid FROM users WHERE User='\L' MYSQLGetDir SELECT Dir FROM users WHERE User='\L'
If you don’t have MySQL auth enabled, enable it with
ln -s /etc/pure-ftpd/conf/MySQLConfigFile /etc/pure-ftpd/auth/30mysql
Restart pure-ftp-mysql with
systemctl restart pure-ftpd-mysql
See CyberPanel
cut is a Linux command that can be used to cut a line of text with a specific delimiter. I want to cut lines separated by multiple spaces like
Since the fields are separated by multiple spaces, I can’t just use cut -d’ ‘ command. What you can do is combine multiple spaces into one using tr command.
tr -s ' '
Here is the command I used to get all database name with Sleep connections
mysqladmin processlist | grep "Sleep" | tr -s ' ' | cut -d' ' -f8
Another solution is to use awk command.
mysqladmin processlist | grep "Sleep" | awk '{print $8}'
See cut
Webuzo hosting control panel has the option for selecting web servers Apache or Nginx. On a server using Nginx, after uploading the WordPress site and restoring the database, the website home page worked. When I clicked on any web page, I get a 404 Page not found error.
To fix this, you need to add an extra configuration for Nginx. Login to Webuzo control panel.
Click on Extra Configuration.
On this page, select the domain name that you need 404 error fixed. On Webservers dropdown select Nginx.
Create a file permlink.conf on your computer with the following content
try_files $uri $uri/ /index.php?$args;
Browse and upload this file in the Webuzo control panel. This will fix the 404 error for the WordPress site.
Webuzo will create a configuration file at
/usr/local/apps/nginx/etc/conf.d/YOUR-DOMAIN.TLD/permlink.conf
rdesktop is an open-source client for connecting to windows using Windows Remote Desktop Services.
To install rdesktop on CentOS/Fedora run
yum install rdesktop
To install rdesktop on Ubuntu/Debian servers, run
apt install rdesktop
To connect a server with rdesktop
rdesktop -u administrator SERVER_IP
sshpass is used to non interactively log in to remote SSH server and execute commands. It can use a password from a file, environment variable, or from a command-line argument.
To install sshpass on RHEL/CentOS, run
yum install sshpass
On Debian/Ubuntu
apt install sshpass
Example
boby@sok-01:~$ sshpass ssh -o StrictHostKeyChecking=no -p 3333 root@ok.serverok.in "uptime" 02:16:14 up 470 days, 10:41, 0 users, load average: 0.07, 0.04, 0.04 boby@sok-01:~$
Take MySQL backup on a remote server
sshpass ssh -o StrictHostKeyChecking=no -p 3333 root@ok.serverok.in "mysqldump serverok_wp > /root/serverok_wp.sql"
Command-line options for sshpass are
root@sok-01:~# sshpass Usage: sshpass [-f|-d|-p|-e] [-hV] command parameters -f filename Take password to use from file -d number Use number as file descriptor for getting password -p password Provide password as argument (security unwise) -e Password is passed as env-var "SSHPASS" With no parameters - password will be taken from stdin -P prompt Which string should sshpass search for to detect a password prompt -v Be verbose about what you're doing -h Show help (this screen) -V Print version information At most one of -f, -d, -p or -e should be used root@sok-01:~#
To login to password using a password in the command line, use
sshpass -p PASSWORD_HERE ssh USER@SERVER_IP
To use a password from a file, use
echo 'PASSWORD_HERE' > pw_file chmod 0400 pw_file sshpass -f pw_file ssh USER@SERVER_IP
Using password-less authentication using an RSA key is much more secure. But sshpass can be used in places where you can’t use RSA key.
See SSH