Category: Linux

  • lspci

    lspci command is used to list PCI devices on your computer.

    To see all lspci command-line options

    root@first-vm:~# lspci help
    Usage: lspci []
    
    Basic display modes:
    -mm		Produce machine-readable output (single -m for an obsolete format)
    -t		Show bus tree
    
    Display options:
    -v		Be verbose (-vv or -vvv for higher verbosity)
    -k		Show kernel drivers handling each device
    -x		Show hex-dump of the standard part of the config space
    -xxx		Show hex-dump of the whole config space (dangerous; root only)
    -xxxx		Show hex-dump of the 4096-byte extended config space (root only)
    -b		Bus-centric view (addresses and IRQ's as seen by the bus)
    -D		Always show domain numbers
    -P		Display bridge path in addition to bus and device number
    -PP		Display bus path in addition to bus and device number
    
    Resolving of device ID's to names:
    -n		Show numeric ID's
    -nn		Show both textual and numeric ID's (names & numbers)
    -q		Query the PCI ID database for unknown ID's via DNS
    -qq		As above, but re-query locally cached entries
    -Q		Query the PCI ID database for all ID's via DNS
    
    Selection of devices:
    -s [[[[]:]]:][][.[]]	Show only devices in selected slots
    -d []:[][:]		Show only devices with specified ID's
    
    Other options:
    -i 	Use specified ID database instead of /usr/share/misc/pci.ids.gz
    -p 	Look up kernel modules in a given file instead of default modules.pcimap
    -M		Enable `bus mapping' mode (dangerous; root only)
    
    PCI access options:
    -A 	Use the specified PCI access method (see `-A help' for a list)
    -O =	Set PCI access parameter (see `-O help' for a list)
    -G		Enable PCI access debugging
    -H 	Use direct hardware access ( = 1 or 2)
    -F 	Read PCI configuration dump from a given file
    root@first-vm:~# 
    

    To list all PCI devices

    root@first-vm:~# lspci
    00:00.0 Host bridge: Intel Corporation Core Processor DMI (rev 11)
    00:03.0 PCI bridge: Intel Corporation Core Processor PCI Express Root Port 1 (rev 11)
    00:08.0 System peripheral: Intel Corporation Core Processor System Management Registers (rev 11)
    00:08.1 System peripheral: Intel Corporation Core Processor Semaphore and Scratchpad Registers (rev 11)
    00:08.2 System peripheral: Intel Corporation Core Processor System Control and Status Registers (rev 11)
    00:08.3 System peripheral: Intel Corporation Core Processor Miscellaneous Registers (rev 11)
    00:10.0 System peripheral: Intel Corporation Core Processor QPI Link (rev 11)
    00:10.1 System peripheral: Intel Corporation Core Processor QPI Routing and Protocol Registers (rev 11)
    00:1a.0 USB controller: Intel Corporation 5 Series/3400 Series Chipset USB2 Enhanced Host Controller (rev 05)
    00:1c.0 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 1 (rev 05)
    00:1d.0 USB controller: Intel Corporation 5 Series/3400 Series Chipset USB2 Enhanced Host Controller (rev 05)
    00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev a5)
    00:1f.0 ISA bridge: Intel Corporation 3420 Chipset LPC Interface Controller (rev 05)
    00:1f.2 SATA controller: Intel Corporation 5 Series/3400 Series Chipset 6 port SATA AHCI Controller (rev 05)
    01:00.0 Serial Attached SCSI controller: Broadcom / LSI SAS2008 PCI-Express Fusion-MPT SAS-2 [Falcon] (rev 02)
    02:00.0 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme II BCM5716 Gigabit Ethernet (rev 20)
    02:00.1 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme II BCM5716 Gigabit Ethernet (rev 20)
    03:03.0 VGA compatible controller: Matrox Electronics Systems Ltd. MGA G200eW WPCM450 (rev 0a)
    ff:00.0 Host bridge: Intel Corporation Core Processor QuickPath Architecture Generic Non-Core Registers (rev 04)
    ff:00.1 Host bridge: Intel Corporation Core Processor QuickPath Architecture System Address Decoder (rev 04)
    ff:02.0 Host bridge: Intel Corporation Core Processor QPI Link 0 (rev 04)
    ff:02.1 Host bridge: Intel Corporation Core Processor QPI Physical 0 (rev 04)
    ff:03.0 Host bridge: Intel Corporation Core Processor Integrated Memory Controller (rev 04)
    ff:03.1 Host bridge: Intel Corporation Core Processor Integrated Memory Controller Target Address Decoder (rev 04)
    ff:03.2 Host bridge: Intel Corporation Core Processor Integrated Memory Controller Test Registers (rev 04)
    ff:03.4 Host bridge: Intel Corporation Core Processor Integrated Memory Controller Test Registers (rev 04)
    ff:04.0 Host bridge: Intel Corporation Core Processor Integrated Memory Controller Channel 0 Control Registers (rev 04)
    ff:04.1 Host bridge: Intel Corporation Core Processor Integrated Memory Controller Channel 0 Address Registers (rev 04)
    ff:04.2 Host bridge: Intel Corporation Core Processor Integrated Memory Controller Channel 0 Rank Registers (rev 04)
    ff:04.3 Host bridge: Intel Corporation Core Processor Integrated Memory Controller Channel 0 Thermal Control Registers (rev 04)
    ff:05.0 Host bridge: Intel Corporation Core Processor Integrated Memory Controller Channel 1 Control Registers (rev 04)
    ff:05.1 Host bridge: Intel Corporation Core Processor Integrated Memory Controller Channel 1 Address Registers (rev 04)
    ff:05.2 Host bridge: Intel Corporation Core Processor Integrated Memory Controller Channel 1 Rank Registers (rev 04)
    ff:05.3 Host bridge: Intel Corporation Core Processor Integrated Memory Controller Channel 1 Thermal Control Registers (rev 04)
    root@first-vm:~# 
    

    To get detailed list

    lspci -knn
    

    bash: lspci: command not found

  • bash: lspci: command not found

    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

  • Install Caddy Webserver on CentOS 7

    Install Caddy Webserver on CentOS 7

    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

  • Connect to backend failed: connect to lsphp failed: 110

    Connect to backend failed: connect to lsphp failed: 110

    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.

  • Linux tr command (translate)

    Linux tr command (translate)

    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

  • Skype public key is not available

    Skype public key is not available

    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

  • lxc error Unable to fetch GPG key from keyserver

    lxc error Unable to fetch GPG key from keyserver

    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"
    

    Method 2

    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
    

    Method 3

    Use –keyserver command line argument

    lxc-create -t download -n mycontainer -- -d ubuntu -r focal -a amd64 --keyserver hkp://keyserver.ubuntu.com
    

    See lxc

  • configure: error: Couldn’t find pcre.h, try installing the libpcre

    configure: error: Couldn’t find pcre.h, try installing the libpcre

    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

  • CyberPanel FTP not working on Ubuntu Server

    CyberPanel FTP not working on Ubuntu Server

    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

  • How to cut lines separated by multiple spaces?

    How to cut lines separated by multiple spaces?

    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

    cut multiple space

    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

  • How to fix WordPress 404 error in Webuzo

    How to fix WordPress 404 error in Webuzo

    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.

    Webuzo Extra configuration

    Click on Extra Configuration.

    webuzo

    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
    
  • How to install and use rdesktop

    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