How to find out your laptop's name with bash

11 replies [Last post]
lammi87

I am a member!

Offline
Joined: 07/27/2012

Hi. If I want to find a 100% sure way to find out the model name of my laptop, is the *dmidecode* command the right way to go? I'm doing this for h-node, in case you were wondering.

I tried the following command and it gave me the right result.

sudo dmidecode | grep "System Information" -A 2

My laptop is Vostro 3300 from Dell. Here's the output I got.

System Information
Manufacturer: Dell Inc.
Product Name: Vostro 3300

So, is this the absolute way to be sure?

lembas
Offline
Joined: 05/13/2010

Worked for me.

However looks like the manual page for dmidecode says the information is "possibly unreliable". And even "more often than not, information contained in the DMI tables is inaccurate, incomplete or simply wrong."

So it might not be the philosopher's stone.

lammi87

I am a member!

Offline
Joined: 07/27/2012

Quote:
---
So it might not be the philosopher's stone.
---
End quote

Indeed. I got some questionable results already. I have tried this with a few laptops and got correct results about 50-70% of the time.

teodorescup

I am a member!

Offline
Joined: 01/04/2011

Try:

sudo lshw
lammi87

I am a member!

Offline
Joined: 07/27/2012

I tried this:

sudo lshw | grep Vostro

Didn't work. My laptop is Vostro 3300.

Michał Masłowski

I am a member!

I am a translator!

Offline
Joined: 05/15/2010

> Hi. If I want to find a 100% sure way to find out the model name of my
> laptop, is the *dmidecode* command the right way to go? I'm doing this
> for h-node, in case you were wondering.

The 100% sure way is to look on the outside, all laptops have their
model name written somewhere. My YeeLoong doesn't have DMI.

> I tried the following command and it gave me the right result.
>
> sudo dmidecode | grep "System Information" -A 2

Are you sure this always takes first two lines?

You can instead read various files from /sys/class/dmi, these don't need
root access to read.

> So, is this the absolute way to be sure?

If you can find a good unique identifier for the laptop model and have
some data to share, I could implement it in h-client. (There was some
private discussion on this, I don't have access to it.)

lammi87

I am a member!

Offline
Joined: 07/27/2012

I'm not sure if the info I want will always be on the first two lines, but it has worked so far. I didn't compare the output to actual *dmidecode* output, though.

Checked the /sys/class/dmi and found this:

/sys/class/dmi/id/product_name

Got correct result (Vostro 3300) with

cat /sys/class/dmi/id/product_name

Will this command work with any laptop? Is it always reliable?

lembas
Offline
Joined: 05/13/2010

That's the same dmi tables as the original command. So no it isn't.

lammi87

I am a member!

Offline
Joined: 07/27/2012

Ok, other ideas?

aloniv

I am a translator!

Offline
Joined: 01/11/2011

The commands worked on my netbook (Asus 1001PX) :)

sudo dmidecode | grep "System Information" -A 2

System Information
Manufacturer: ASUSTeK Computer INC.
Product Name: 1001PX

cat /sys/class/dmi/id/product_name
1001PX

lammi87

I am a member!

Offline
Joined: 07/27/2012

Does anyone have any ideas?

lembas
Offline
Joined: 05/13/2010

It's hilarious but apparently there is no way to do this. I'd say go with

cat /sys/class/dmi/id/{sys_vendor,product_name}

which is equal to the original command AFAIK sans sudo. And then throw in a disclaimer it might be bogus.