Is Hyper Threading enabled?

There are times when you need to know whether hyper-threading is enabled without the luxury to reboot the system to check the BIOS or You know for sure, that it is enabled in the BIOS, but you need to check at the node level.

You can simply look at the output of /proc/cpuinfo and compare the siblings with the cpu cores fields. Although /proc/cpuinfo shows you all the logical CPUs (processor field) in the system, the siblings field holds the number of logical CPUs for the physical CPU this entry belongs to (including both the cores and the hyper-threaded LCPUs).

If the number of cpu cores is the same as the number of siblings, hyper-threading is disabled.

Below are different examples of how to check if Hyper threading is enabled.

  1. Using information from /proc/cpuinfo
# egrep ‘processor|siblings|cpu cores’ /proc/cpuinfo | head -3
processor : 0
siblings : 4
cpu cores : 2

In the above example; the LCPU #0 (the first logical CPU in your system) is one of the 4 logical CPUs on the physical CPU that has 2 cores. So yes, hyper-threading is enabled.

# cat /proc/cpuinfo | grep -i flags | head -1
flags : fpu vme ht de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt aes xsave avx f16c rdrand hypervisor lahf_lm ida arat epb pln pts dtherm fsgsbase smep

In the above, you can see the “ht” in the flags section. This also tells you that hyper-threading is enabled.

  1. Using the lscpu command
# lscpu | grep -i -E “^CPU\(s\):|core|socket”
CPU(s): 24
Thread(s) per core: 2
Core(s) per socket: 6
Socket(s): 2

As you can see, number of threads per core is 2, so it’s HT enabled.

  1. Another way to check us to install dmidecode (if it isnt already available).
# /usr/sbin/dmidecode | grep -E “Socket Designation: Node |HTT”
Socket Designation: Node 1 Socket 1
HTT (Multi-threading)
Socket Designation: Node 1 Socket 2
HTT (Multi-threading)

In the above, It tells you that HT is enabled.

# /usr/sbin/dmidecode | grep Count
Core Count: 4
Thread Count: 8

Again, here it tells you the thread count of the cores.

Leave your comments, if you know any other ways to check for hyper-threading at node level.

One liner to rename files extensions

Ubuntu / Debian

# rename “s/txt/text/” *.txt

The above command will rename all files with extension “txt” to new extension “text” in all files matching “*.txt”

Mac OSx

With OSx and Homebrew installed, you can install the rename command using the following:

$ brew install rename
==> Downloading
……………………………………………………………… 100.0%
==> Pouring rename-1.600.el_capitan.bottle.tar.gz
? /usr/local/Cellar/rename/1.600: 3 files, 40.9K

Then issue the following command, to rename all files with extension “txt” to new extension “text” in all files matching “*.txt”

$ rename “s/txt/text/” *.txt

Zipping everything except a specific folder?

So, there are times, when you want to zip up a while directory, but you may want to exclude just 1 or 2 directories or files. Here is how to do it:


$ ls -lrt /tocompress/
total 16
drwxr-xr-x 2 root root 4096 Apr 17 07:38 dir001
drwxr-xr-x 2 root root 4096 Apr 17 07:38 dir002
drwxr-xr-x 2 root root 4096 Apr 17 07:39 dir003
-rw-r–r– 1 root root 8 Apr 17 07:39 test.txt

$ sudo zip -r ~/ /tocompress -x /tocompress/dir002/*
adding: dir001/ (stored 0%)
adding: dir001/dir00/ (stored 0%)
adding: dir003/ (deflated 13%)
adding: test.txt (stored 0%)


The above example, compresses the /tocompress folder and stores it in the users’ home directory. It also excludes the dir002 folder and its contents, while the rest of them are compressed.