How to keep files and directories synchronized across different devices using syncthing on Linux

Syncthing is defined as a continuous file synchronization program: it can be used to keep files and directories synchronized across different devices or “nodes”. The application uses TLS as encryption method, and it is, together with its protocol, free and open source software. When using Syncthing, our data remains on our device, and is transferred directly to the destination without relaying on a central server (peer to peer). In this tutorial we will see how to install, configure and use Syncthing on Linux.

In this tutorial you will learn:

  • How to install Syncthing on the most used Linux distributions
  • How to setup the firewall for Syncthing to work correctly
  • How to share and keep a directory synchronized across two devices
  • How to austostart the Syncthing daemon automatically on user login
syncthing-logo

Software requirements

CategoryRequirements, Conventions or Software Version Used
SystemDistribution independent
SoftwareSyncthing
OtherRoot permissions
Conventions# – requires given linux-commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux-commands to be executed as a regular non-privileged user

Installation



There are basically two methods we can use to install Syncthing in our favorite Linux distribution: we can use the version packaged in the native repositories, or we can download a tarball from the official Syncthing website. Additionally, only if using Debian or Ubuntu, we can add the official Syncthing repository as an additional software source and install the package from it.

Installing the native version

Syncthing is available in the native repositories of the most used Linux distributions, such as Fedora, Debian/Ubuntu, and Archlinux, therefore we can easily install it with our favorite package manager. This is always the recommended way to obtain software; the only problem is that, especially on distributions like Debian “stable”, the repository can contain outdated versions of the packages. To install Syncthing on Fedora, we can use the dnf package manager, and issue the following command:

$ sudo dnf install syncthing

On Debian and its many derivatives, instead, we can run:

$ sudo apt install syncthing

On Archlinux we can use pacman to install the syncthing package, which is part of the “Community” repository. Obtaining the software it’s just a matter of launching our terminal emulator and run:

$ sudo pacman -Sy syncthing

Downloading a tarball



The second method of installing Syncthing consists into downloading the dedicated Linux tarball from the downloads section of the official site. We should download the archive containing the version compatible with the architecture of our system. If we are using Debian or Ubuntu, we can also add the official repository to our software sources, and then install it using apt.

Setting up the firewall

Before we run Syncthing, for it to work correctly, we must setup some firewall rules in order to allow incoming traffic through certain ports. Recent versions of the Firewalld and Ufw firewall managers, already come with a pre-configured service for Syncthing (here with the word “service” we mean a defined set of rules). If using Firewalld, to activate the service, and thus to enable traffic through the required ports), we should run:

$ sudo firewall-cmd --permanent --add-service=syncthing && sudo firewall-cmd --reload

Notice that with the command above, since no zone is specified, the service will be added to the “default” one. If we want to add the service to a specific zone, we should specify it with the --zone option, passing the zone name as argument. To gather information about the service, and see what ports are included in it, we can run:

$ sudo firewall-cmd --info-service=custom

The output of the command above is the following:

syncthing
  ports: 22000/tcp 21027/udp
  protocols:
  source-ports:
  modules:
  destination:
  includes:
  helpers:



As we can see, the ports “involved” in the service are 22000/tcp and 21027/udp. If we are using Ufw (Uncomplicated Firewall), in order to activate the service, we should run:

$ sudo ufw allow syncthing

Using Syncthing

To start the Syncthing daemon, all we have to do is to invoke the Syncthing binary from our terminal:

$ syncthing

Syncthing comes with a web interface which can be used to manage the application, add shared directories and remote devices. Once we run the command above, the Syncthing daemon is launched, and a web browser tab is automatically opened to the 127.0.0.1:8384 address, which is where the interface can be reached.

The default Syncthing shared directory is ~/Sync; it and all the other ones which should be synchronized, are displayed on the left column of the interface. On the right column, instead, we can see information about the device Syncthing is running on, and a list of associated remote devices. In our case the list is still empty:The Syncthing web interface




To add a remote machine and share a directory with it, what we need to do is to exchange devices IDs. To check a device ID, we can click on the “Actions” button on the top right side of the web interface, and click on “Show ID”. The current device ID will be displayed together with the correspondent QRCode:

syncthing-gtk-id

For the application to work correctly the two (or more devices) should know their respective IDs. In the next section we will see how to add a remote device.

Adding a device

To start synchronizing a directory, we need to add a remote device to our configuration. For the sake of this tutorial, I will use the Linux machine where we installed Syncthing as the synchronization “source”, while the remote system will be an Android device (Syncthing can be easily installed from the Google Play Store); the two devices must be connected to the same LAN.

We click on the “Add Remote Device” button on the bottom right of the web interface. On the fist tab of the popup window that will be opened we need to enter the companion device ID, and an optional human-friendly name:



syncthing-add-device

As you can see, if auto-discover works as it should, the other Syncthing device in the LAN should be automatically discovered and reported under the “nearby devices” list. In such cases all we need to do is to click on the correspondent link, and the ID input field will be filled automatically.

On the second tab, “Sharing”, we can select what directories we want to share with the companion device. In this case we selected the default one:

syncthing-add-device

One convenient thing to do, is to check the “Auto Accept” checkbox: this way the system will not prompt us to confirm if we want to accept the synchronization of the directory offered by the remote system, but it will automatically create it.



The third tab contains “advanced settings”. Here we can choose to enter a static address for the remote device, if it has any and dynamic discovery doesn’t work. We could also choose incoming and outgoing rate limit for the device, and what data should be compressed (all data vs metadata only – the default).

syncthing-remote-status

Once done, we can click on the “Save” button. The remote device should than appear in the list on the main page. On the other device we perform the same operation (notice that on the Android app, by clicking on the “hamburger” menu, we have the option to use the web interface) and add our “source” device ID. Once the two devices are paired correctly their status should begin to sync. Once the synchronization process is finished, they will be reported as “Up to Date”:

syncthing-remote-status

At this point our (bi-directional) synchronization should be ready, and the directory will be kept in sync on the two devices.

Autostart the Syncthing daemon




To make the Syncthing daemon start automatically, we can use Systemd, which is the Linux init manager. In this case we will start it as a per-user service, so we won’t need administrative privileges. When a service is configured this way, it will be started only once the user logs in.

The first thing we want to do is to copy the systemd service file into the appropriate directory. If we installed Syncthing from the native repositories of our Linux distribution, such file should be: /usr/lib/systemd/user/syncthing.service; if we downloaded the tarball from the official Syncthing site, the file should be found inside the etc/linux-systemd/user directory.

We create the ~/.config/systemd/user directory if it doesn’t already exist, and copy the file inside it:

$ mkdir -p ~/.config/systemd/user && cp /usr/lib/systemd/user/syncthing.service ~/.config/systemd/user

Once the file is in place, we run the following command to enable the service:

$ systemctl --user enable syncthing.service

Conclusions

On this tutorial we learned how to install and configure Syncthing, a very handful application which let us keep one or more directories synchronized between multiple devices, without the need to use a “central” server. We saw how to install the application, how to setup the firewall to allow traffic through the required ports, how to share a directory between two devices and how to autostart the Syncthing daemon automatically when a user logs in.

Source: https://linuxconfig.org/how-to-keep-files-and-directories-synchronized-across-different-devices-using-syncthing-on-linux

grepWin is an open source tool that searches for files and inside documents using regex

What’s your preferred desktop search engine program? The answer is likely Everything, by Void Tools. I agree with you, it is a fantastic application.

grepWin is an open source tool that searches for files and inside documents using regex

GrepWin is an open source program that specializes in finding text in documents; it supports advanced regular expression filters, and you may want to give it a try for that purpose.

The program’s interface is not the most user-friendly, but that’s probably an impression caused by the various options on the screen.

grepWin example

Select the folder that you want to search by clicking the three-dot button at the top. Enter your query in the box that’s labeled “Search For”. For a more advanced approach, you may opt for the Regex search mode. GrepWin even has a test regex option for checking if your regular expression works or not. Hit F1 to view the help file, it has a list of all supported regex syntax.

grepWin regex commands

Hit the enter key or click on the search button to make the query and grepWin will list the results on the pane at the bottom. The information is split into various columns, such as file name, size, path, extension, encoding, and date modified. Double-click on a file to open it in its default app, e.g. TXT files in Notepad, audio files in your music player, and so on. Right-click on a result to access the Explorer shell menu.

GrepWin could list a ton of files, and if you have trouble finding the one you wanted, I recommend playing around with the Limit Search settings to restrict the process by file size, date, hidden, system or binary files, disabling recursive search (subfolders). This also shortens the time taken for the search to complete by a considerable duration.

grepWin regex search

You can blacklist specific folders from searches using the exclude dirs box, the syntax is ^(FOLDERNAME)$. To include file types, use wildcards like *.TXT, and to exclude types, add a – before it. You may add | to separate multiple items. Speaking of regular expressions, you can add the ones you use to the presets, which will help you add them quickly the next time. Don’t feel intimidated by these options, you don’t need to know regex commands to use the program for simple searches, though by doing so you’ll be missing out on some of its strongest filters.

Switch between the Files search mode and the Content finder by toggling the option in the bottom right corner of the window. This changes the columns in the search results pane, to display the relevant information. The Files mode lists the name, path of the documents which contain the search term.

GrepWin’s content mode can search inside documents and list every instance the phrase was found in each document along with the line name and a preview of the text. The application supports case-sensitive search, which can be handy if there are a lot of matches, and you want to filter them based on the case. The application can be used to replace content in documents directly, to use this option enter the words in the replace with box, and click on the Replace button. You may want to enable the create backup file option, before using the replace function.

The Search button in grepWin has a few additional options including an inverted lookup, i.e. find files that don’t match the entered query. You can also use it to run a search within the found results.

GrepWin is available for 32-bit and 64-bit computers, and comes in portable versions. If you’re using the installer version, you can access the program from the Windows Explorer context menu.

DnGrep is a similar software, in fact it is nearly identical to grepWin. I’m not sure if one of them is a fork of the other.

Source: https://www.ghacks.net/2021/04/09/grepwin-is-an-open-source-tool-that-searches-for-files-and-inside-documents-using-regex/

Ultimate guide to backup Ubuntu systems using Timeshift

In this tutorial, we will learn how to perform Ubuntu backups using Timeshift. Timeshift is a fabulous tool that is used for the backup & restoration of the Linux operating system, it takes incremental backup after the first initial complete backup. TImeshit creates filesystem snapshots using Rsync or BTRFS. It has a nice GUI as well as support for CLI.

Timeshifts also have support for scheduled snapshots, multiple backup levels & also exclude filters. Snapshots can be easily restored even if the system is running from a Live CD or USB.

So let’s now start with the installation of Timeshift.


Install Timeshift in Ubuntu 20.04 or up

If you are running Ubuntu 20.04 or up, then you just need to run a single command to install Timeshift on Ubuntu as the timeshift packages are available in default repositories,

$ sudo apt install timeshift

Install Timeshift in Ubuntu 19.10 or older

If you are running Ubuntu 19.10 or older versions (which you should not be using), then you are required to add the repository for timeshift first & then install timeshift. Use the following commands to perform the actions,

$ sudo add-apt-repository -y ppa:teejee2008/ppa

$ sudo apt update

$ sudo apt install timeshift

Performing Ubuntu Backup using Timeshift

Now that we have the timeshift installed on our Ubuntu systems, we can start creating the snapshots for our Ubuntu installation. Browse or search the menu for timeshift & open it.

Once timeshift is opened, you will be asked to select the preferred snapshot type. You will have the options for selecting,

1- RSYNC – Rsync takes backup with the rsync command and also used hard links. Rsync backups are browsable using file managers.

2- BTRFS – with this mode, timeshift uses in-built features of BTRFS & then to restore snapshots, BTRFS should be supported with the Ubuntu-type subvolume layout.

You can select either but we will be using rsync,

Once on the next screen, you are required to select the destination drive to save your snapshots. Select a suitable drive (which is not the source drive) & press ‘Next’. On the next screen, you will be asked to select screenshot level. It can be either ‘Monthly’, ‘Weekly’, ‘Daily’, ‘Hourly’ or on ‘Boot’,

ubuntu backup

Now click on ‘Finish’ to complete the setup. Now your initial setup is complete & you can start creating your backup snapshots. To create the backup, click on ‘Create’ on the main menu,

The backup process will now start and once it’s complete, click on ‘Finish’.

Restore the backup

Similar to how we created the backup, restoration is also pretty simple. From the main menu, click on the option ‘Restore’, & then select the snapshot from the list. Next, you need to provide the destination to where this snapshot needs to be restored.

Before clicking on restore, you can also perform ‘Dry Run’ to verify all files and folders. Once you are ok, you can click next & the restoration process will start. It will take some time to complete.

Now that we have discussed how to perform Ubuntu backup using the GUI, we will take a look at CLI commands as well.


Create Ubuntu backup using CLI

Timeshift also supports the command line to create and restore the backup. to create a backup, simply run the following command,

$ sudo timeshift –create –comments “Backup with CLI” –tags D

In tags, you can any of the following options,

–tags D stands for Daily Backup

–tags W stands for Weekly Backup

–tags M stands for Monthly Backup

–tags O stands for On-demand Backup

Restore a backup using  CLI

To restore a backup using the timeshift in CLI, use the following command,

$ sudo timeshift –restore

You will then be asked to select a snapshot from the list by pressing the number for that snapshot. Then press enter key to continue.

For the next step, it will ask to Re-install the GRUB2 bootloader, press ‘Y’, and then again press ‘Y’ & enter to start the restoration process.

With this, we end our tutorial on how to backup Ubuntu using Timeshift. If you have any questions or queries, please do send them in using the comment box below.

Source: https://linuxtechlab.com/backup-ubuntu-systems-using-timeshift/

Linux File System Types Explained, Which One Should You Use

Linux supports a variety of file systems such as ext4, ZFS, XFS, Btrfs, Reiser4, and so on. Different types of file systems solve different kinds of problems and their usage is application specific.

Choosing Linux file system that is appropriate for your application is an important decision. This tutorial describes some of the major Linux file systems and provides recommendations on the right file system to suit your application.

Table of contents

What is Linux file system

Almost every bit of data and programming that is needed to boot a Linux system and keep it working is saved in the file system. For example, the operating system itself, compilers, application programs, shared libraries, configuration files, log files, media mount points, and so on.

File systems operate in the background. Like the rest of an operating system’s kernel, they’re largely invisible in everyday use.

Linux file system is generally a built-in layer of a Linux operating system used to handle the data management of the storage. It controls how data is stored and retrieved. It manages the file name, file size, creation date, and much more information about a file.

ext4 file system

In 1992 the Extended File System or ext was launched specifically for the Linux operating system. It has its roots in the Minix Operating system. In 1993 an update called Extended File System 2 or ext2 was then released and was for many years the default file system in many Linux distros. By 2001 ext2 was upgraded to ext3 which introduced journaling to protect against corruption in the event of crashes or power failures.

Ext4 (Fourth Extended Filesystem) was introduced in 2008 and it is the default Linux filesystem since 2010. It was designed as a progressive revision of the ext3 file system and overcomes a number of limitations in ext3. It has significant advantages over its predecessor such as improved design, better performance, reliability, and new features.

Nowadays ext4 is the default file system on most Linux distributions. It can support files and file systems of up to 16 terabytes in size. It also supports an unlimited number of sub-directories (the ext3 file system only supports up to 32,000). Further, ext4 is backward compatible with ext3 and ext2, allowing these older versions to be mounted with the ext4 driver.

There is a reason ext4 is the default choice for most Linux distributions. It’s tried, tested, stable, performs great, and is widely supported. If you are looking for stability, ext4 is the best Linux filesystem for you.

Despite all of its features, ext4 does not support transparent compression, transparent encryption, or data deduplication.

XFS file system

XFS is a highly scalable file system that was developed by Silicon Graphics and first deployed in the Unix-based IRIX operating system in 1994. It is a journaling file system and, as such, keeps track of changes in a log before committing the changes to the main file system. The advantage is guaranteed consistency of the file system and expedited recovery in the event of power failures or system crashes.

Originally XFS was created to support extremely large filesystems with sizes of up to 16 exabytes and file sizes of up to 8 exabytes. It has a long history of running on large servers and storage arrays.

One notable feature of XFS is Guaranteed Rate IO. This allows applications to reserve bandwidth. The file system calculates the available performance and adjusts its operation according to the existing reservations.

XFS has a reputation of operating in environments that require high performance and scalability and hence is routinely measured as one of the highest performing file systems on large systems with enterprise workloads.

Today XFS is supported by most Linux distributions and has now become the default filesystem on Red Hat Enterprise Linux, Oracle Linux, CentOS and many other distributions.

Best use cases for XFS file system

So, do you have a large server? Do you have large storage requirements or have a local, slow SATA drive?

If both your server and your storage device are large, and there is no need to reduce the filesystem size, XFS is likely to be the best choice. XFS is a great filesystem, that scales well for large servers. But even with smaller storage arrays, XFS performs very well when the average file sizes are large, for example, hundreds of megabytes in size.

Btrfs file system

Btrfs is the next generation general purpose Linux file system that offers unique features like advanced integrated device management, scalability and reliability. It is licensed under the GPL and open for contribution from anyone. Different names are used for the file system, including “Butter FS”, “B-tree FS”, and “Better FS”.

Btrfs development began at Oracle in 2007. It was merged into the mainline Linux kernel in the beginning of 2009 and debuted in the Linux 2.6.29 release.

Btrfs is not a successor to the default ext4 file system used in most Linux distributions, but it offer better scalability and reliability. Btrfs is a copy-on-write (CoW) file system intended to address various weaknesses in current Linux file systems. It primary focusing on fault tolerance, self-healing properties, and easy administration.

Btrfs can support up to a 16 exbibyte partition and a file of the same size. If you are confused by the numbers, all you need to know is that Btrfs can support up to sixteen times of the data of Ext4.

How does Copy-on-Write work and why would you want it

On a traditional file system, modifying a file would read the data, change it and then write it back to the same place. In a copy on write file system, it reads the data, changes it and writes it to a new location. This prevents the loss of data during the read-modify-write transaction because the data is always on disk.

Since you don’t “repoint” until the new block is completely written out, if you lose power or crash in the middle of a write, you end up with either the old block or the new block, but not a half-written corrupted block. So you don’t need to fsck filesystems on startup and you lower your risk of data corruption.

You can snapshot the filesystem at any point, creating a snapshot entry in the metadata with the current set of pointers. This protects old blocks from being garbage collected later on and allows the filesystem to present a volume as it was during the snapshot. In other words, you have instant rollback capabilities. You can even clone that volume to make it a writable volume based on the snapshot.

Your other choice is ZFS on Linux, which may be more stable, but requires a few more steps to install on typical Linux distributions.

Btrfs features

  • Copy on Write (CoW) and snapshotting – Make incremental backups painless even from a “hot” filesystem or virtual machine (VM).
  • File level checksums – Metadata for each file includes a checksum that is used to detect and repair errors.
  • Compression – Files may be compressed and decompressed on the fly, which speeds up read performance.
  • Auto defragmentation – The filesystems are tuned by a background thread while they are in use.
  • Subvolumes – Filesystems can share a single pool of space instead of being put into their own partitions.
  • RAID – Btrfs does its own RAID implementations so LVM or mdadm are not required in to have RAID. Currently RAID 0, 1 and 10 are supported. RAID 5 and 6 are considered unstable.
  • Partitions are optional – While Btrfs can work with partitions, it has the potential to use raw devices (/dev/<device>) directly.
  • Data deduplication – There is limited data deduplication support; however, deduplication will eventually become a standard feature in Btrfs. This enables Btrfs to save space by comparing files via binary diffs.

Btrfs is a filesystem that does not need administration once it has been implemented, that is, you should never have to run an fsck on it. Whenever any errors or inconsistencies arise, it should just handle them on its own and be on its way.

While it is true that Btrfs is still considered experimental and it is currently under active development, the time when Btrfs will become the default filesystem for Linux systems is getting closer. Some Linux distributions have already begun to switch to it with their current releases.

If you aren’t afraid of having to deal with a somewhat less mature ecosystem, though, Btrfs may be the better option for you.

ZFS file system

ZFS (Zettabyte File System) remains one of the most technically advanced and feature-complete filesystems since it appeared in October 2005. It is a local filesystem (i.e.: ext4) and logical volume manager (i.e.: LVM) created by Sun Microsystems. ZFS was published under an open source license until Oracle bought Sun Microsystems and closed source the license.

You can think of ZFS as volume manager and a RAID array in one, which allows extra disks to be added to your ZFS volume which allows extra space to be added to your file system all at once. In addition to, ZFS comes with some other features that traditional RAID doesn’t have.

ZFS depends heavily on memory, so you need at least 8GB to start. In practice, use as much you can get for your hardware/budget.

ZFS is commonly used by data hoarders, NAS users, and other geeks who prefer to put their trust in a redundant storage system of their own rather than the cloud. It’s a great file system to use for managing multiple disks of data and rivals some of the greatest RAID setups.

ZFS is similar to other storage management approaches, but in some ways, it’s radically different. ZFS does not normally use the Linux Logical Volume Manager (LVM) or disk partitions, and it’s usually convenient to delete partitions and LVM structures prior to preparing media for a zpool.

The zpool is the analog of the LVM. A zpool spans one or more storage devices, and members of a zpool may be of several various types. The basic storage elements are single devices, mirrors and raidz. All of these storage elements are called vdevs.

ZFS is able to enforce storage integrity far better than any RAID controller, as it has intimate knowledge of the structure of the filesystem. Data safety is an important design feature of ZFS. All blocks written in a zpool are aggressively checksummed to ensure the data’s consistency and correctness.

For server use where you want to eliminate almost entirely any possibility of data loss and stability is the name of the game, you may want to look into ZFS.

ZFS features

Endless scalability. Well, it’s not technically endless, but it’s a 128-bit file system that’s capable of managing zettabytes (one billion terabytes) of data. Therefore, no matter how much hard drive space you have, ZFS will be suitable for managing it.

Maximum integrity. Everything you do inside of ZFS uses a checksum to ensure file integrity.  You can rest assured that your files and their redundant copies will not encounter silent data corruption.  Also, while ZFS is busy quietly checking your data for integrity, it will do automatic repairs anytime it can.

Drive pooling. The creators of ZFS want you to think of it as being similar to the way your computer uses RAM. When you need more memory in your computer, you put in another stick and you’re done. Similarly with ZFS, when you need more hard drive space, you put in another hard drive and you’re done. No need to spend time partitioning, formatting, initializing, or doing anything else to your disks. When you need a bigger storage “pool”, just add disks.

RAID. ZFS is capable of many different RAID levels, all while delivering performance that’s comparable to that of hardware RAID controllers. This allows you to save money, make setup easier, and have access to superior RAID levels that ZFS has improved upon.

Reiser4 file system

ReiserFS is a general-purpose, journaled computer file system initially designed and implemented by a team at Namesys led by Hans Reiser. Introduced in version 2.4.1 of the Linux kernel, it was the first journaling file system to be included in the standard kernel.

With the exception of security updates and critical bug fixes, Namesys has ceased development on ReiserFS. Reiser4 is the successor filesystem for ReiserFS. It has added encryption, improved performance, and much more.

Reiser4 requires a patched kernel. It is still not included in the official Linux kernel, but patches for Linux-5.x is already available. The reasons Reiser4 is not in the Linux kernel today can be summarized as claims that further testing are required.

Reiser4 provides the most efficient disk space usage among all file systems in all scenarios and workloads. ReiserFS offers advantages over other file systems, especially when it comes to handling a large number of small files. It supports journaling for fast recovery in case of problems. The file system structure is based on trees. In addition, Reiser4 consumes a little more CPU than other filesystems.

Reiser4 has a unique ability to optimize disk space occupied by small files (less than one block). They are stored entirely in their inode, without allocation of blocks in the data area.

As well as implementing the traditional Linux filesystem functions, reiser4 provides users with a number of additional features: transparent compression and encryption of files, full data journaling, as well as almost unlimited (with the help of plug-in architecture) extensibility.

However, there is currently no support for direct IO (work has begun on implementation), quotas, and POSIX ACL.

Conclusion

Choosing the file system that satisfies your specific application needs requires consultation and research of various parameters. This article outlines the benefits of ext4, ZFS, XFS, Btrfs, and Reiser4 file system options and to assist you make the decision regarding the right file system for your application environments. Thank you for spending your time here.

Source: https://linuxiac.com/linux-file-system-types-explained-which-one-should-you-use/#h-zfs-file-system

Find Linux System Hardware Information With Hwinfo

There are multitude of programs available to find the hardware and software information in a Linux system. We already have covered many such programs here. Today, we are going to learn about yet another similar tool called Hwinfo. Hwinfo is a free, open source and command line utility to find Linux system hardware information.

Hwinfo probes for the hardware present in a Linux system and displays the extensive details of each hardware device. If you think the details are too much to comprehend, Hwinfo provides an option to display the abbreviated output. It uses libhd.so library to gather details of almost all hardware such as BIOS, CPU, Architecture, Memory, Hard Disk(s), Partitions, Camera, Bluetooth, CD/DVD drives, Keyboard/Mouse, Graphics card, Monitor, Modem, Scanner, Printer, PCI, IDE, SCSI, Sound card, Network interface card, USB and a lot more.

Hwinfo is initially developed for openSUSE operating system. It was later adopted by several other popular  Linux distributions such as Arch Linux, Debian, Fedora, RHEL, CentOS, Ubuntu etc.

Install hwinfo in Linux

The hwinfo is available in the official repositories of many Linux distributions.

On Arch Linux and its variants like Manjaro Linux, install hwinfo using command:

$ sudo pacman -S hwinfo

On Debian, Ubuntu:

$ sudo apt install hwinfo

On Fedora:

$ sudo dnf install hwinfo

On CentOS, RHEL:

First, enable [EPEL] repository with command:

$ sudo dnf install epel-release

And then install hwinfo using command:

$ sudo yum install hwinfo

On openSUSE:

$ sudo zypper install hwinfo

Find Linux System Hardware Information With Hwinfo

When running Hwinfo without any options, you will get the complete details of the hardware present in your Linux system:

$ sudo hwinfo

Or,

$ sudo hwinfo --all

Sample output:

============ start debug info ============                      
libhd version 21.68 (x86-64) [7688]
using /var/lib/hardware
kernel version is 5.4
----- /proc/cmdline -----
  BOOT_IMAGE=/boot/vmlinuz-5.4.0-29-generic root=UUID=3968763a-adde-46e0-ae93-e2a1e51120da ro quiet splash vt.handoff=7
----- /proc/cmdline end -----
debug = 0xff7ffff7
probe = 0x15938fcdaa17fcf9fffe (+memory +pci +isapnp +net +floppy +misc +misc.serial +misc.par +misc.floppy +serial +cpu +bios +monitor +mouse +scsi +usb -usb.mods +modem +modem.usb +parallel +parallel.lp +parallel.zip -isa -isa.isdn +isdn +kbd +prom +sbus +int +braille +braille.alva +braille.fhp +braille.ht -ignx11 +sys -bios.vbe -isapnp.old -isapnp.new -isapnp.mod +braille.baum -manual +fb +pppoe -scan +pcmcia +fork -parallel.imm +s390 +cpuemu -sysfs -s390disks +udev +block +block.cdrom +block.part +edd +edd.mod -bios.ddc -bios.fb -bios.mode +input +block.mods +bios.vesa -cpuemu.debug -scsi.noserial +wlan -bios.crc -hal +bios.vram +bios.acpi -bios.ddc.ports=0 +modules.pata -net.eeprom +x86emu=dump -max -lxrc)
shm: attached segment 131081 at 0x7f3ae1378000
>> hal.1: read hal data
>> floppy.1: get nvram
----- /proc/nvram -----
  Checksum status: valid
  # floppies     : 3
  Floppy 0 type  : none
  Floppy 1 type  : none
  HD 0 type      : 02
  HD 1 type      : 01
  HD type 48 data: 44876/196/142 C/H/S, precomp 45431, lz 38938
  HD type 49 data: 511/175/180 C/H/S, precomp 40874, lz 56627
  DOS base memory: 629 kB
  Extended memory: 65535 kB (configured), 65535 kB (tested)
  Gfx adapter    : CGA (80 cols)
  FPU            : installed
----- /proc/nvram end -----
>> floppy.2: nvram info
>> bios.1: cmdline
>> bios.1.1: apm
>> bios.2: ram
/dev/mem[0x400, 256]: mmap(, 4096,,,, 0x0) ok
/dev/mem[0xc0000, 262144]: mmap(, 262144,,,, 0xc0000) ok
[...]
Find Linux System Hardware Information With Hwinfo

As I mentioned before, Hwinfo will report extensive details of all hardware devices. Fortunately, there is an option to display the summary of each device which makes it easier to read the output.

To display short summary of hardware information, run:

$ sudo hwinfo --short

Sample output:

cpu:                                                            
                       Intel(R) Core(TM) i3-2350M CPU @ 2.30GHz, 1508 MHz
                       Intel(R) Core(TM) i3-2350M CPU @ 2.30GHz, 1371 MHz
                       Intel(R) Core(TM) i3-2350M CPU @ 2.30GHz, 1516 MHz
                       Intel(R) Core(TM) i3-2350M CPU @ 2.30GHz, 1333 MHz
keyboard:
                       Logitech Unifying Receiver
  /dev/input/event4    AT Translated Set 2 keyboard
mouse:
                       Logitech Unifying Receiver
  /dev/input/mice      AlpsPS/2 ALPS GlidePoint
monitor:
                       4Y4GM 156AT LCD Monitor
graphics card:
                       Intel 2nd Generation Core Processor Family Integrated Graphics Controller
sound:
                       Intel 6 Series/C200 Series Chipset Family High Definition Audio Controller
storage:
                       Intel 6 Series/C200 Series Chipset Family 6 port Mobile SATA AHCI Controller
network:
  wlp9s0               Dell Wireless 1702 802.11bgn Half-size Mini PCIe Card [AR9002WB-1NGCD]
  enp5s0               Realtek RTL810xE PCI Express Fast Ethernet controller
network interface:
  mpqemubr0-dummy      Ethernet network interface
  tap-d8f1eebb39f      Ethernet network interface
  wlp9s0               Ethernet network interface
  mpqemubr0            Ethernet network interface
  lo                   Loopback network interface
  enp5s0               Ethernet network interface
disk:
  /dev/sdb             Generic Multi-Card
  /dev/sda             ST9500325AS
                       Realtek RTS5138 Card Reader Controller
partition:
  /dev/sda1            Partition
cdrom:
  /dev/sr0             PLDS DVD+-RW DS-8A8SH
usb controller:
                       Intel 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #2
                       Intel 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #1
bios:
                       BIOS
bridge:
                       Intel 6 Series/C200 Series Chipset Family PCI Express Root Port 1
                       Intel HM67 Express Chipset LPC Controller
                       Intel 6 Series/C200 Series Chipset Family PCI Express Root Port 8
                       Intel 6 Series/C200 Series Chipset Family PCI Express Root Port 4
                       Intel 2nd Generation Core Processor Family DRAM Controller
                       Intel 6 Series/C200 Series Chipset Family PCI Express Root Port 2
hub:
                       Intel Integrated Rate Matching Hub
                       Linux Foundation 2.0 root hub
                       Intel Integrated Rate Matching Hub
                       Linux Foundation 2.0 root hub
memory:
                       Main Memory
bluetooth:
                       Qualcomm Atheros AR3011 Bluetooth
unknown:
                       FPU
                       DMA controller
                       PIC
                       Keyboard controller
                       PS/2 Controller
                       Intel 6 Series/C200 Series Chipset Family MEI Controller #1
                       Intel 6 Series/C200 Series Chipset Family SMBus Controller
                       Logitech Unifying Receiver
                       Suyin Integrated Webcam
Display short summary of hardware information with hwinfo in Linux

See? The above command has excluded the comprehensive technical details and displays only the essential details of each hardware device. It is now much easier to know what hardware is present in our system.

Display device-specific information with Hwinfo

Hwinfo not only displays the complete hardware information, but also individual device details as well. You can list the details of a specific hardware.

Display CPU details using Hwinfo in Linux

For instance, the following command displays the details of CPU:

$ sudo hwinfo --cpu

This will complete details of your CPU.

01: None 00.0: 10103 CPU                                        
  [Created at cpu.465]
  Unique ID: rdCR.j8NaKXDZtZ6
  Hardware Class: cpu
  Arch: X86-64
  Vendor: "GenuineIntel"
  Model: 6.42.7 "Intel(R) Core(TM) i3-2350M CPU @ 2.30GHz"
  Features: fpu,vme,de,pse,tsc,msr,pae,mce,cx8,apic,sep,mtrr,pge,mca,cmov,pat,pse36,clflush,dts,acpi,mmx,fxsr,sse,sse2,ht,tm,pbe,syscall,nx,rdtscp,lm,constant_tsc,arch_perfmon,pebs,bts,rep_good,nopl,xtopology,nonstop_tsc,cpuid,aperfmperf,pni,pclmulqdq,dtes64,monitor,ds_cpl,vmx,est,tm2,ssse3,cx16,xtpr,pdcm,pcid,sse4_1,sse4_2,x2apic,popcnt,tsc_deadline_timer,xsave,avx,lahf_lm,epb,pti,ssbd,ibrs,ibpb,stibp,tpr_shadow,vnmi,flexpriority,ept,vpid,xsaveopt,dtherm,arat,pln,pts,md_clear,flush_l1d
  Clock: 1437 MHz
  BogoMips: 4589.48
  Cache: 3072 kb
  Units/Processor: 16
  Config Status: cfg=new, avail=yes, need=no, active=unknown
[...]

You can, of course, display the short summary of CPU:

$ sudo hwinfo --short --cpu

Sample output:

cpu:                                                            
                       Intel(R) Core(TM) i3-2350M CPU @ 2.30GHz, 1650 MHz
                       Intel(R) Core(TM) i3-2350M CPU @ 2.30GHz, 1803 MHz
                       Intel(R) Core(TM) i3-2350M CPU @ 2.30GHz, 1462 MHz
                       Intel(R) Core(TM) i3-2350M CPU @ 2.30GHz, 1621 MHz

Display System architecture details using Hwinfo in Linux

To find system architecture details, run:

$ sudo hwinfo --arch

Or,

$ sudo hwinfo --short --arch

Display Memory details using Hwinfo in Linux

To find memory (RAM) details, run:

$ sudo hwinfo --memory

Or,

$ sudo hwinfo --short --memory

Display Disk details using Hwinfo in Linux

To find Hard disk details, run:

$ sudo hwinfo --disk

Or,

$ sudo hwinfo --short --disk

Display Partition details using Hwinfo in Linux

To find partition details of the hard disk, run:

$ sudo hwinfo --partition

Or,

$ sudo hwinfo --short --partition

Display Network details using Hwinfo in Linux

To find Network interface card details, run:

$ sudo hwinfo --network

Or,

$ sudo hwinfo --short --network

Display Sound card details using Hwinfo in Linux

To find sound card details, run:

$ sudo hwinfo --sound

Or,

$ sudo hwinfo --short --sound

Display BiOS details using Hwinfo in Linux

To find BIOS details, run:

$ sudo hwinfo --bios

Or,

$ sudo hwinfo --short --bios

Similarly, Hwinfo can probe all other hard items. The list of available hardware items are:

  • all,
  • arch,
  • bios,
  • block,
  • bluetooth,
  • braille,
  • bridge,
  • camera,
  • cdrom,
  • chipcard,
  • cpu,
  • disk,
  • dsl,
  • dvb,
  • fingerprint,
  • floppy,
  • framebuffer,
  • gfxcard,
  • hub,
  • ide,
  • isapnp,
  • isdn,
  • joystick,
  • keyboard,
  • memory,
  • mmc-ctrl,
  • modem,
  • monitor,
  • mouse,
  • netcard,
  • network,
  • partition,
  • pci,
  • pcmcia,
  • pcmcia-ctrl,
  • pppoe,
  • printer,
  • redasd,
  • reallyall,
  • scanner,
  • scsi,
  • smp,
  • sound,
  • storage-ctrl,
  • sys,
  • tape,
  • tv,
  • uml,
  • usb,
  • usb-ctrl,
  • vbe,
  • wlan,
  • xen,
  • zip.

Export hardware information to a file

Hwinfo can be used to generate a complete system hardware report and easily export the details to a text file. You can then share it with your support person or colleague for troubleshooting purpose.

The following command will dump all hardware information in a text file called “hardwareinfo.txt”.

$ hwinfo --all --log hardwareinfo.txt

Or,

$ hwinfo --all > hardwareinfo.txt

It is also possible to export a specific hardware device details, for example keyboard, to a file:

$ hwinfo --keyboard > hardwareinfo.txt

Getting help

To display Hwino help section, run:

$ hwinfo --help

For more details, refer man pages.

$ man hwinfo

Resource: