Course – Black Friday 2026 – NPI EA – linux – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 4th December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

1. Overview

Sometimes on Linux, we need an automated way to determine if our computer is a desktop or laptop. For instance, this can be useful for a script that decides which packages to install based on the computer type.

In this tutorial, we’ll look at the Linux commands to check if a computer is a laptop or desktop.

First, we’ll check the hostnamectl command. Then, we’ll learn the dmidecode command.

2. Using hostnamectl

The quickest way to check the computer type is to use the hostnamectl command. The command comes with the systemd package and should be available by default on most Linux distributions.

There are two ways to check the computer type using the hostnamectl command. Let’s check both.

2.1. With the chassis Option

The first way is to check the computer type using the chassis option:

$ hostnamectl chassis
desktop

As we can see, adding the chassis keyword shows that we use a desktop computer.

Based on the computer type, the other possible outputs of this command are “laptop“, “tablet“, “convertible“, “server“, “handset“, “watch“, “embedded“, and the special chassis types “vm” and “container” for virtualized systems.

However, on some systems, the chassis option may not be available by default. So, let’s check the alternative.

2.2. With the icon-name Option

Another way to check the computer type is to use the hostnamectl command with the icon-name option:

$ hostnamectl icon-name
computer-desktop

As a result, it correctly shows that we’re using a desktop computer.

The other possible outputs of this command are “computer-laptop” for the laptop type, and “computer-vm” for the virtual machine type.

3. Using dmidecode

The dmidecode command displays the computer hardware information. Let’s use it to display the computer chassis type:

$ sudo dmidecode -s chassis-type
Desktop

As we can see, the computer is of a desktop type.

We need to run the above command with sudo, as otherwise, it lacks the required permissions.

In case we use a laptop, the output of the command may be “Laptop“, “Notebook“, “Portable“, “Hand held” or “Sub Notebook” depending on the manufacturer’s designation.

4. Conclusion

In this article, we learned the Linux commands to check the type of our computer. First, we looked at the hostnamectl command which provides the chassis and the icon-name options. Then, we discussed the dmidecode command.