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

Useful Linux commands

from here

# 1. redo last command but as root
sudo !!

# 2. open an editor to run a command
ctrl+x+e

# 3. create a super fast ram disk
mkdir -p /mnt/ram
mount -t tmpfs tmpfs /mnt/ram -o size=8192M

# 4. don't add command to history (note the leading space)
 ls -l

# 5. fix a really long command that you messed up
fc

# 6. tunnel with ssh (local port 3337 -> remote host's 127.0.0.1 on port 6379)
ssh -L 3337:127.0.0.1:6379 root@emkc.org -N

# 7. quickly create folders
mkdir -p folder/{sub1,sub2}/{sub1,sub2,sub3}

# 8. intercept stdout and log to file
cat file | tee -a log | cat > /dev/null

# bonus: exit terminal but leave all processes running
disown -a && exit

# A. Delete all emails from bash
cat /dev/null > /var/spool/mail/root

# 11. Show PID program over port 5432
netstat -vanp tcp | grep 5432

# 12. Show PID program over port 5432
lsof -i tcp:5432

# 13. Stop postgres database on mac.sarch data folder
su postgres
/Library/PostgreSQL/9.5/bin/pg_ctl -D  /Library/PostgreSQL/9.5/data stop

How To Install pgAdmin 4 on CentOS 7 / RHEL 7 & Fedora 29 / Fedora 28

Install pgAdmin 4

Once you have PostgreSQL repository configured on your system, run the following command to install pgAdmin 4.

### RHEL / CentOS ###

yum -y install pgadmin4

### Fedora ###

dnf -y install pgadmin4

Configure pgAdmin 4

We would need to do a few configuration changes prior to accessing the pgAdmin 4.

Copy the pgAdmin 4 sample configuration.

cp /etc/httpd/conf.d/pgadmin4.conf.sample /etc/httpd/conf.d/pgadmin4.conf

Create a pgAdmin log and data directories.

mkdir /var/log/pgadmin4/
mkdir /var/lib/pgadmin4/

Create/Edit config_local.py file.

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

Add the following settings. A

LOG_FILE = '/var/log/pgadmin4/pgadmin4.log'
SQLITE_PATH = '/var/lib/pgadmin4/pgadmin4.db'
SESSION_DB_PATH = '/var/lib/pgadmin4/sessions'
STORAGE_DIR = '/var/lib/pgadmin4/storage'

after the existing one:

import os
DATA_DIR = os.path.realpath(os.path.expanduser(u'~/.pgadmin/'))

Change permissions of directories so that Apache can write data into it. B

chown -R apache:apache /var/lib/pgadmin4/*
chown -R apache:apache /var/log/pgadmin4/*

Run the following command to create a user account for the pgAdmin 4 web interface. C

python /usr/lib/python2.7/site-packages/pgadmin4-web/setup.py

Output:

NOTE: Configuring authentication for SERVER mode.

Enter the email address and password to use for the initial pgAdmin user account:

Email address: admin@itzgeek.local
Password: xxxxxxxxx
Retype password: xxxxxxxxx
pgAdmin 4 - Application Initialisation
======================================

Restart the Apache web service.

systemctl restart httpd

My https configuration file for Apache

For CentOS 7:

<VirtualHost *:80>
        ServerName pg.saic.it
        Redirect permanent / https://pg.saic.it/pgadmin4/
</VirtualHost>
<VirtualHost *:443>
        ServerName pg.saic.it
        LoadModule wsgi_module modules/mod_wsgi.so
        SSLEngine on
        SSLCertificateFile /etc/ssl/certs/pg.saic.it.crt
        SSLCertificateKeyFile /etc/ssl/certs/pg.saic.it.key
        SSLCACertificateFile /etc/ssl/certs/saic.sslforfree.ca
        WSGIDaemonProcess pgadmin processes=1 threads=25
        WSGIScriptAlias /pgadmin4 /usr/lib/python2.7/site-packages/pgadmin4-web/pgAdmin4.wsgi

        <Directory /usr/lib/python2.7/site-packages/pgadmin4-web/>
                WSGIProcessGroup pgadmin
                WSGIApplicationGroup %{GLOBAL}
                <IfModule mod_authz_core.c>
                        # Apache 2.4
                        Require all granted
                </IfModule>
                <IfModule !mod_authz_core.c>
                        # Apache 2.2
                        Order Deny,Allow
                        Deny from All
                        Allow from 127.0.0.1
                        Allow from ::1
                </IfModule>
        </Directory>
</VirtualHost>                

if you have this error in your Apache log file : Fatal Python error: PyEval_AcquireThread: NULL new thread state

is because mod_python have to removed from the modules

After the installation when you do an update the steps are: A, B, C

 

Use Let’s Encrypt for ssl certificate

From this web site follow the instructions to update your server web environment:

$ yum -y install yum-utils
$ yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
yum install certbot python2-certbot-apache

then run this for the website sample.lu

 certbot certonly --apache -d pennellificioeurope.it -d www.pennellificioeurope.it

or

certbot run -a webroot -i apache -w /path_to_web -d solci.eu -d www.solci.eu

this the result

Saving debug log to /var/log/letsencrypt/letsencrypt.log

Plugins selected: Authenticator webroot, Installer apache

Enter email address (used for urgent renewal and security notices) (Enter ‘c’ to

cancel): postmaster@saic.it

Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Please read the Terms of Service at

https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must

agree in order to register with the ACME server at

https://acme-v02.api.letsencrypt.org/directory

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

(A)gree/(C)ancel: A

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Would you be willing to share your email address with the Electronic Frontier

Foundation, a founding partner of the Let’s Encrypt project and the non-profit

organization that develops Certbot? We’d like to send you email about our work

encrypting the web, EFF news, campaigns, and ways to support digital freedom.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

(Y)es/(N)o: Y

Starting new HTTPS connection (1): supporters.eff.org

Obtaining a new certificate

Performing the following challenges:

http-01 challenge for sample.lu

http-01 challenge for www.sample.lu

Using the webroot path /var/www/sample.lu/web for all unmatched domains.

Waiting for verification…

Cleaning up challenges

Resetting dropped connection: acme-v02.api.letsencrypt.org

Deploying Certificate to VirtualHost /etc/httpd/conf/sites-enabled/100-sample.lu.vhost

Deploying Certificate to VirtualHost /etc/httpd/conf/sites-enabled/100-sample.lu.vhost

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

1: No redirect – Make no further changes to the webserver configuration.

2: Redirect – Make all requests redirect to secure HTTPS access. Choose this for

new sites, or if you’re confident your site works on HTTPS. You can undo this

change by editing your web server’s configuration.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Select the appropriate number [1-2] then [enter] (press ‘c’ to cancel): 2

Redirecting vhost in /etc/httpd/conf/sites-enabled/100-sample.lu.vhost to ssl vhost in /etc/httpd/conf/sites-enabled/100-sample.lu.vhost

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Congratulations! You have successfully enabled https://sample.lu and

https://www.sample.lu

You should test your configuration at:

https://www.ssllabs.com/ssltest/analyze.html?d=sample.lu

https://www.ssllabs.com/ssltest/analyze.html?d=www.sample.lu

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

IMPORTANT NOTES:

– Congratulations! Your certificate and chain have been saved at:

   /etc/letsencrypt/live/sample.lu/fullchain.pem

   Your key file has been saved at:

   /etc/letsencrypt/live/sample.lu/privkey.pem

   Your cert will expire on 2019-06-11. To obtain a new or tweaked

   version of this certificate in the future, simply run certbot again

   with the “certonly” option. To non-interactively renew *all* of

   your certificates, run 

sudo certbot renew –dry-run

for test

sudo certbot renew

for prod

or

/opt/certbot/certbot-auto renew -i apache -a webroot

single domain CORRECT to USE

certbot --apache certonly -n -d domain.com

remember to deactivate cloudfare dns proxy CDN and to deactivate any apache tomcat redirection before to run the renew.

– Your account credentials have been saved in your Certbot

   configuration directory at /etc/letsencrypt. You should make a

   secure backup of this folder now. This configuration directory will

   also contain certificates and private keys obtained by Certbot so

   making regular backups of this folder is ideal.

– If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let’s Encrypt:   https://letsencrypt.org/donate

   Donating to EFF:                    https://eff.org/donate-le

To renew seafile.saic.it do : 

mv /etc/httpd/conf.d/seafile.conf /etc/httpd/conf.d/seafile.conf.tmp

service httpd restart

/opt/certbot/certbot-auto renew -i apache -a webroot

service httpd restart

mv /etc/httpd/conf.d/seafile.conf.tmp /etc/httpd/conf.d/seafile.conf

To update an existing domain with adding a new subdomain

--expand tells Certbot to update an existing certificate with a new certificate that contains all of the old domains and one or more additional new domains. With the --expand option, use the -d option to specify all existing domains and one or more new domains.

Example:

certbot --expand -d existing.com,example.com,newdomain.com

If you prefer, you can specify the domains individually like this:

certbot --expand -d existing.com -d example.com -d newdomain.com

TO DELETE THE CERTIFICATE:

1. Verifica l’elenco dei certificati gestiti da Certbot

Esegui il comando seguente per visualizzare tutti i certificati attualmente gestiti da Certbot:

certbot certificates

Troverai una lista dei certificati attivi, con informazioni come il dominio principale, eventuali domini aggiuntivi, e il percorso del file di configurazione.

2. Identifica il certificato da rimuovere

Annota il nome del dominio o il cert name associato al certificato che desideri rimuovere.

3. Elimina il certificato

Per rimuovere il certificato e la sua configurazione dai rinnovi automatici, usa il comando:

certbot delete --cert-name nome-certificato

Sostituisci nome-certificato con il valore del Cert Name trovato nel passo precedente.

 

 

from here 

certbot docs

Linux Access to shared Windows Folder command

mount -t cifs //192.168.51.21/SWIFT-production/ /mnt/SWIFT-production -o user=foras,domain=farad.local

to give all permission

mount -t cifs //192.168.51.21/SWIFT-production/ /mnt/SWIFT-production -o user=foras,domain=farad.local,rw,file_mode=0777,dir_mode=0777

remove user tomcat from group root : gpasswd -d tomcat root

unmount with force a folder : umount -f -l /mnt/SWIFT-production/