8 commands to check cpu information on Linux

1. /proc/cpuinfo

The /proc/cpuinfo file contains details about individual cpu cores. Output its contents with less or cat.

$ less /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 23
model name      : Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz
stepping        : 10
microcode       : 0xa07
cpu MHz         : 1998.000
cache size      : 2048 KB
physical id     : 0
siblings        : 4
core id         : 0
cpu cores       : 4
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dtherm tpr_shadow vnmi flexpriority
bogomips        : 5303.14
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

Every processor or core is listed separately the various details about speed, cache size and model name are included in the description.

To count the number of processing units use grep with wc

$ cat /proc/cpuinfo | grep processor | wc -l
4
The number of processors shown by /proc/cpuinfo might not be the actual number of cores on the processor. For example a processor with 2 cores and hyperthreading would be reported as a processor with 4 cores.

To get the actual number of cores, check the core id for unique values

$ cat /proc/cpuinfo | grep 'core id'
core id         : 0
core id         : 2
core id         : 1
core id         : 3

So there are 4 different core ids. This indicates that there are 4 actual cores.

2. lscpu

lscpu is a small and quick command that does not need any options. It would simply print the cpu hardware details in a user-friendly format.

$ lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    1
Core(s) per socket:    4
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 23
Stepping:              10
CPU MHz:               1998.000
BogoMIPS:              5303.14
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              2048K
NUMA node0 CPU(s):     0-3

3. hardinfo

Hardinfo is a gtk based gui tool that generates reports about various hardware components. But it can also run from the command line only if there is no gui display available.

$ hardinfo | less

It would produce a large report about many hardware parts, by reading files from the /proc directory. The cpu information is towards the beginning of the report. The report can also be written to a text file.

Hardinfo also performs a few benchmark tests taking a few minutes before the report is displayed.

4. lshw

The lshw command can display limited information about the cpu. lshw by default shows information about various hardware parts, and the ‘-class’ option can be used to pickup information about a specific hardware part.

$ sudo lshw -class processor
  *-cpu                   
       description: CPU
       product: Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz
       vendor: Intel Corp.
       physical id: 0
       bus info: cpu@0
       version: Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz
       slot: LGA 775
       size: 1998MHz
       capacity: 4GHz
       width: 64 bits
       clock: 333MHz
       capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx x86-64 constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dtherm tpr_shadow vnmi flexpriority cpufreq

The vendor, model and speed of the processor are being shown correctly. However it is not possible to deduce the number of cores on the processor from the above output.

5. nproc

The nproc command just prints out the number of processing units available. Note that the number of processing units might not always be the same as number of cores.

$ nproc
4

6. dmidecode

The dmidecode command displays some information about the cpu, which includes the socket type, vendor name and various flags.

$ sudo dmidecode -t 4
# dmidecode 2.12
SMBIOS 2.4 present.

Handle 0x0000, DMI type 4, 35 bytes
Processor Information
        Socket Designation: LGA 775
        Type: Central Processor
        Family: Pentium D
        Manufacturer: Intel(R) Corporation
        ID: 7A 06 01 00 FF FB EB BF
        Signature: Type 0, Family 6, Model 23, Stepping 10
        Flags:
                FPU (Floating-point unit on-chip)
                VME (Virtual mode extension)
                DE (Debugging extension)
                PSE (Page size extension)
                TSC (Time stamp counter)
                MSR (Model specific registers)
                PAE (Physical address extension)
                MCE (Machine check exception)
                CX8 (CMPXCHG8 instruction supported)
                APIC (On-chip APIC hardware supported)
                SEP (Fast system call)
                MTRR (Memory type range registers)
                PGE (Page global enable)
                MCA (Machine check architecture)
                CMOV (Conditional move instruction supported)
                PAT (Page attribute table)
                PSE-36 (36-bit page size extension)
                CLFSH (CLFLUSH instruction supported)
                DS (Debug store)
                ACPI (ACPI supported)
                MMX (MMX technology supported)
                FXSR (FXSAVE and FXSTOR instructions supported)
                SSE (Streaming SIMD extensions)
                SSE2 (Streaming SIMD extensions 2)
                SS (Self-snoop)
                HTT (Multi-threading)
                TM (Thermal monitor supported)
                PBE (Pending break enabled)
        Version: Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz
        Voltage: 1.6 V
        External Clock: 333 MHz
        Max Speed: 4000 MHz
        Current Speed: 2666 MHz
        Status: Populated, Enabled
        Upgrade: Socket LGA775
        L1 Cache Handle: 0x0003
        L2 Cache Handle: 0x0001
        L3 Cache Handle: Not Provided
        Serial Number: Not Specified
        Asset Tag: Not Specified
        Part Number: Not Specified

7. cpuid

The cpuid command fetches CPUID information about Intel and AMD x86 processors.

The program can be installed with apt on ubuntu

$ sudo apt-get install cpuid

And here is sample output

$ cpuid

.....

Vendor ID: "GenuineIntel"; CPUID level 13

Intel-specific functions:
Version 0001067a:
Type 0 - Original OEM
Family 6 - Pentium Pro
Model 7 - Pentium III/Pentium III Xeon - external L2 cache
Stepping 10
Reserved 4

Extended brand string: "Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz"
CLFLUSH instruction cache line size: 8
Initial APIC ID: 2
Hyper threading siblings: 4

Feature flags bfebfbff:
FPU    Floating Point Unit
VME    Virtual 8086 Mode Enhancements
DE     Debugging Extensions
PSE    Page Size Extensions
TSC    Time Stamp Counter
MSR    Model Specific Registers
PAE    Physical Address Extension
MCE    Machine Check Exception
CX8    COMPXCHG8B Instruction
APIC   On-chip Advanced Programmable Interrupt Controller present and enabled
SEP    Fast System Call
MTRR   Memory Type Range Registers
PGE    PTE Global Flag
MCA    Machine Check Architecture
CMOV   Conditional Move and Compare Instructions
FGPAT  Page Attribute Table
PSE-36 36-bit Page Size Extension
CLFSH  CFLUSH instruction
DS     Debug store
ACPI   Thermal Monitor and Clock Ctrl
MMX    MMX instruction set
FXSR   Fast FP/MMX Streaming SIMD Extensions save/restore
SSE    Streaming SIMD Extensions instruction set
SSE2   SSE2 extensions
SS     Self Snoop
HT     Hyper Threading
TM     Thermal monitor
31     reserved

.....

8. inxi

Inxi is a script that uses other programs to generate a well structured easy to read report about various hardware components on the system. Check out the full tutorial on inxi.

$ sudo apt-get install inxi

Print out cpu/processor related information

$ inxi -C
CPU:       Quad core Intel Core2 Quad CPU Q8400 (-MCP-) cache: 2048 KB flags: (lm nx sse sse2 sse3 sse4_1 ssse3 vmx) 
           Clock Speeds: 1: 1998.00 MHz 2: 1998.00 MHz 3: 1998.00 MHz 4: 1998.00 MHz

PgAdmin client SMTPRecipientsRefused: 450, 4.1.8 : Sender address rejected: Domain not found

After the pg installation I tried to reset the pgadmin password but i had this problem:

[error] [pid 12033] mod_wsgi.c(1631): [client SMTPRecipientsRefused: {u’info@xxxx.xx’: (450, ‘4.1.8 <no-reply@localhost>: Sender address
rejected: Domain not found’)}

i solved in this way:

vim /usr/lib/python2.7/site-packages/pgadmin4-web/config.py

MAIL_SERVER = ‘localhost’
MAIL_PORT = 25
MAIL_USE_SSL = False
MAIL_USE_TLS = False
MAIL_USERNAME = ”
MAIL_PASSWORD = ”
MAIL_DEBUG = False

# Flask-Security overrides Flask-Mail’s MAIL_DEFAULT_SENDER setting, so
# that should be set as such:
SECURITY_EMAIL_SENDER = ‘no-reply@localhost

 

I changed the SECURITY_EMAIL_SENDER into a my valid email

Restart httpd!

Install Soap for ISPConfig Centos 7 for Roundcubemail

Look up the following inside your script file

phpinfo();

If you can’t find Soap Client set to enabled like so: the way soap should appear in phpinfo()

run for Webstatic repository to install if it’s not present

yum install php70w-soap 

Do the following:

  1. Locate php.ini in your apache bin folder, I.e /etc/php.ini
  2. Remove the ; from the beginning of extension=php_soap.so it is present
  3. Restart your Apache server
  4. Look up your phpinfo(); again and check if you see a similar picture to the one above
  5. If you do, problem solved!

To use soap for this roundcube plugin

Assuming you have already installed Roundcube and ISPConfig 3, follow the instructions below. If not, please download and install Roundcube from http://www.roundcube.net/ and ISPConfig 3 from http://www.ispconfig.org/.

Step 1

  • Make sure you are using the latest stable ISPConfig.
  • Make sure you are using the latest stable Roundcube.
  • Read the requirements: Requirements

Step 2

Go to your ISPConfig panel and add a new remote user: Tab “System” > “Remote Users”

Tick the checkbox Remote Access and activate the following functions:

  • Client functions
  • Server functions
  • Mail user functions
  • Mail user filter functions
  • Mail alias functions
  • Mail forward functions
  • Mail fetchmail functions
  • Mail spamfilter user functions
  • Mail spamfilter policy functions
  • Mail spamfilter whitelist functions
  • Mail spamfilter blacklist functions

Step 3

Download the latest plugin package for Roundcube. You can either install the files from a ZIP archive or use a version management system, such as Git or Subversion (SVN). Using Git or SVN seems favorable since they feature commands to easily update the plugin package.

As a starting point for any variant, make sure you are located in the Roundcube root directory before executing the listed commands. Also, make sure not to miss the trailing ‘.’ (period) when copying the commands. It causes the plugin folders to be fetched to the current directory (and omits the creation of an undesired extra folder).

Install via Git

cd plugins
git clone https://github.com/w2c/ispconfig3_roundcube.git .

Update via Git

cd plugins
git pull origin master

Install via Subversion (SVN)

cd plugins
svn co https://github.com/w2c/ispconfig3_roundcube/trunk/ .

Update via Subversion (SVN)

cd plugins
svn up .

Install from archive

Download the most recent version from: https://github.com/w2c/ispconfig3_roundcube/archive/master.zip
Extract the content of the ispconfig3_roundcube-master folder in the ZIP file to the pluginsdirectory of your Roundcube installation.

Step 4

Copy the file ./ispconfig3_account/config/config.inc.php.dist to ./ispconfig3_account/config/config.inc.php.

Step 5

In the newly created config file (./ispconfig3_account/config/config.inc.php) replace the sample values with your individual settings:

$config['identity_limit'] = false;
$config['remote_soap_user'] = '{REMOTE USERNAME}';
$config['remote_soap_pass'] = '{REMOTE PASSWORD}';
$config['soap_url'] = 'https://{YOUR SERVER}:8080/remote/';
$config['soap_validate_cert'] = true;

Change the port (set to “8080” by default) if necessary. If your ISPConfig installation is using a self-signed server certificate (= not issued by a public CA, such as Letsencrypt), you might have to set soap_validate_cert to false. Otherwise, if the certificate is not trusted, you will see the error message “Soap Error: Could not connect to host“.

For example, if your username is “Santa”, your password is “Claus”, your server’s domain is “christmas.com” (or you can use an IP address). If your ISPConfig panel can be accessed via port 1111 and you are using TLS with a trusted certificate, your configuration would be:

$config['identity_limit'] = false;
$config['remote_soap_user'] = 'Santa';
$config['remote_soap_pass'] = 'Claus';
$config['soap_url'] = 'https://christmas.com:1111/remote/';
$config['soap_validate_cert'] = true;

Step 6

In the config file of Roundcube look for this line:

// List of active plugins (in plugins/ directory)
$config['plugins'] = array();

If there are already plugins listed, add the following to the array:

, "jqueryui", "ispconfig3_account", "ispconfig3_autoreply", "ispconfig3_autoselect", "ispconfig3_pass", "ispconfig3_spam", "ispconfig3_fetchmail", "ispconfig3_filter", "ispconfig3_forward", "ispconfig3_wblist"

!! The jqueryui plugin has to be listed prior to the ISPConfig3 plugins !! !! If you are just using one server for mail, do not activate the autoselect plugin !!

Otherwise, if there are no plugins yet, replace the line with the following:

// List of active plugins (in plugins/ directory)
$config['plugins'] = array("jqueryui", "ispconfig3_account", "ispconfig3_autoreply", "ispconfig3_autoselect", "ispconfig3_pass", "ispconfig3_spam", "ispconfig3_fetchmail", "ispconfig3_filter", "ispconfig3_forward", "ispconfig3_wblist");

Any plugins you want to be inactive, have to be removed from this line. For instance, if you do not wish to have “ispconfig3_pass” (password changer) enabled, you have to omit it. The entire line would then look like this:

// List of active plugins (in plugins/ directory)
$config['plugins'] = array("jqueryui", "ispconfig3_account", "ispconfig3_autoreply", "ispconfig3_autoselect", "ispconfig3_spam", "ispconfig3_fetchmail", "ispconfig3_filter", "ispconfig3_forward", "ispconfig3_wblist");

Step 7

A new tab named “Accounts” should now be visible on your settings page in Roundcube, displaying all plugins enabled in step 6.

PS: If you encounter any issue, look here: Troubleshooting / FAQ

Clone this wiki locally

Upgrade Php Centos 7

This is solution for CentOS 6.x and 7.x:

yum install epel-release

then install Remi repo, for Centos 6.x:

rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-6.rpm

and for Centos 7.x:

rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
or for webstatic
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

check which PHP packages installed:

yum list installed php*

remove current PHP:

yum remove php*

install same packages as were installed for 7.0 using PHP 7.2, for example:

yum install --enablerepo=remi-php72 php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo
or for webstatic
yum install php72w php72w-cli php72w-common php72w-gd php72w-intl php72w-mbstring php72w-mcrypt php72w-mysql php72w-pdo php72w-pear php72w-process php72w-xml

check version of PHP installed:

php -v

You don’t need to PHP 7.0 and 7.2 coexist on Your server. If You got a problem using PHP 7.2 You can always reinstall older PHP 7.0. If not sure it will work for You on production server, try it on virtual machine first. But it worked for me on many production servers. PHP is not critical OS component, so server will never fail if PHP changed. It’s just Your web app which may fail when change to 7.2, but as I wrote it’s unlikely and You may reinstall older version if it happens.

I forgot about php.ini. If You want to keep Your php.ini customizations in another PHP version, make a copy of php.ini before running yum remove php*. After PHP reinstall diff saved_php.ini php.ini and look what is need to be merged.

PHP database access simple example

I have the following mysql query in php:

<?php
$con=mysqli_connect("localhost","root","password", "my_db");
//Check connection
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$query = "SELECT Balance FROM my_table ORDER BY ID DESC LIMIT 1";
$result = mysqli_query($con, $query);

echo $result;
?>

The echo $result does not work and I get a catchable fatal error that mysqli_query cannot be converted into string.

How do I echo my query result?

I believe that is because result is an object and it is expecting a string. Try looking into the fetch command. I believe it would go something like

while($row = mysql_fetch_assoc($result)){
      $stringTest = $row['balance'];
      echo $stringTest;
}

Something like that!

from here