Linux Commands Examples

A great documentation place for Linux commands

lscpu

display information on CPU architecture

Synopsis

lscpu [-hpx] [-s directory]


add an example, a script, a trick and tips

: email address (won't be displayed)
: name

Step 2

Thanks for this example ! - It will be moderated and published shortly.

Feel free to post other examples
Oops ! There is a tiny cockup. A damn 404 cockup. Please contact the loosy team who maintains and develops this wonderful site by clicking in the mighty feedback button on the side of the page. Say what happened. Thanks!

examples

0
source
            
echo "CPU Specification,"
lscpu | sed s/":"/','/1 | tr -d ' '
}
echo -en "Getting system details..."
getconfig > pci.csv
echo "Done."
ls -l pci.csv
0
source
            
echo "CPU Specification,"
lscpu | sed s/":"/','/1 | tr -d ' '
}
echo -en "Getting system details..."
getconfig > pci.csv
0
source
            
sudo lsblk > lsblk.log
sudo lscpu > lscpu.log
sudo lshw > lshw.log
sudo lspci > lspci.log
sudo lsscsi > lsscsi.log
sudo lsusb > lsusb.log
0
source
            
numa=$(lscpu | grep -i numa | cut -d ":" -f 2 | sed 's/ //g')
if [[ $numa == [0-9]* ]] && [ $numa -gt 0 ]; then
0
source
            
CPUS=`lscpu -p | grep -cv '^#'`
if [ "$CPUS" = '' ]; then CPUS=1; fi
cppcheck ../../source/ -i ../../source/win32_deps -i ../../source/configurator -j $CPUS --enable=all --force --verbose 2> $OUTFILE

description

lscpu gathers CPU architecture information like number of CPUs, threads, cores, sockets, NUMA nodes, information about CPU caches, CPU family, model, bogoMIPS, byte order and stepping from sysfs and /proc/cpuinfo, and prints it in a human-readable format. It supports both online and offline CPUs. It can also print out in a parsable format, including how different caches are shared by different CPUs, which can be fed to other programs.

options

-h, --help

Print a help message.

-p, --parse [=list]

Print out in parsable instead of human-readable format.

If the list argument is not given then the default backwardly compatible output is printed. The backwardly compatible format uses two commas to separate CPU cache columns. If no CPU caches are identified, then the cache columns are not printed at all.

The list argument is comma delimited list of the columns. Currently supported are CPU, Core, Node, Socket, Book and Cache columns. If the list argument is given then always all requested columns are printed in the defined order. The Cache columns are separated by ’:’.

Note that the optional list argument cannot be separated from the option by a space, the correct form is for example ’-p=cpu,node’ or ’--parse=cpu,node’.

-s, --sysroot directory

Use the specified directory as system root. This allows you to inspect a snapshot from a different system.

-x, --hex

Use hexadecimal masks for CPU sets (e.g. 0x3). The default is to print the sets in list format (e.g. 0,1).

availability

The lscpu command is part of the util-linux package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux/.


bugs

The basic overview about CPU family, model, etc. is always based on the first CPU only.

Sometimes in Xen Dom0 the kernel reports wrong data.


author

Cai Qian <qcai[:at:]redhat[:dot:]com>
Karel Zak <kzak[:at:]redhat[:dot:]com>

How can this site be more helpful to YOU ?


give  feedback