Is there a simple command to find out your architecture?

20 respuestas [Último envío]
lammi87

I am a member!

Desconectado/a
se unió: 07/27/2012

Hi,

I'm looking for a simple way to figure out a computer's architecture (Desktop, laptop, etc.). I'm contributing to www.h-node.org and would like to find out a way to tell quickly wether one's PC's architecture is one of the following four architectures:

x86
x86-64/amd64
MIPS
ARM

A few commands in bash are preferred over some GUI applications. Your help is most appreciated. Thanks in advance.

Michał Masłowski

I am a member!

I am a translator!

Desconectado/a
se unió: 05/15/2010

> I'm looking for a simple way to figure out a computer's architecture
> (Desktop, laptop, etc.). I'm contributing to www.h-node.org and would
> like to find out a way to tell quickly wether one's PC's architecture
> is one of the following four architectures:
[...]
> A few commands in bash are preferred over some GUI applications. Your
> help is most appreciated. Thanks in advance.

"uname -m" will show the architecture of the currently running kernel.
If you run a 32-bit x86 kernel on a 64-bit CPU, it won't tell that the
architecture is 64-bit. On x86 "egrep '\' /proc/cpuinfo" will show
some lines with flags if AMD64 is supported by the CPU. If you use
e.g. MIPS or ARM, you already know this (different binaries are needed).

teodorescup

I am a member!

Desconectado/a
se unió: 01/04/2011

Try:

uname -p

Source:
http://linux.die.net/man/1/uname
or
man uname

jxself
Desconectado/a
se unió: 09/13/2010

Or: lscpu

Or: less /proc/cpuinfo

So, there are options.

Magic Banana

I am a member!

I am a translator!

Desconectado/a
se unió: 07/24/2010

You can simply run 'arch'. :-)

MagicFab
Desconectado/a
se unió: 12/13/2010

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/06/2012 04:15 PM, name at domain wrote:
> Hi,
>
> I'm looking for a simple way to figure out a computer's architecture
(Desktop, laptop, etc.). I'm contributing to www.h-node.org and would
like to find out a way to tell quickly wether one's PC's architecture is
one of the following four architectures:
>
> x86
> x86-64/amd64
> MIPS
> ARM
>
> A few commands in bash are preferred over some GUI applications. Your
help is most appreciated. Thanks in advance.

All the answers given in this thread will give you the architecture of
the *installed* or *running* (if LiveCD) OS.

To see the actual PC architecture, issue this command:

lshw -C cpu

And even shorter:

lshw -C cpu | grep width

Cheers,

Fabian Rodriguez
http://trisquel.magicfab.ca

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: PGP/Mime available upon request
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlAgQwgACgkQfUcTXFrypNXCNACgtzQ/eK+zcXXRn6VdSIeCQre+
s8kAn1KB+h3Efu9xqS4pMgnDnAaS4yms
=qa0+
-----END PGP SIGNATURE-----

lammi87

I am a member!

Desconectado/a
se unió: 07/27/2012

Thank you all very much for your answers. I think the command suggested by MagicFab is the one I am looking for:

lshw -C cpu | grep width

OR

lshw -C cpu

Now I'd like to ask you to help me with its output. I need to know what kind of output a user will get if she has one of the architectures I mentioned:

x86
x86-64/amd64
MIPS
ARM

After running lshw -C cpu | grep width, I got the following (it means I have a dual core 64-bit CPU, right?):


width: 64 bits
width: 64 bits
width: 64 bits

So now I have one answer, what would the rest be?

x86 width: ? ( my gues: 32 bits)
x86-64/amd64 width: 64 bits
MIPS width: ?
ARM width: ?

Michał Masłowski

I am a member!

I am a translator!

Desconectado/a
se unió: 05/15/2010
MagicFab
Desconectado/a
se unió: 12/13/2010

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/07/2012 03:08 PM, Micha? Mas?owski wrote:
>> Thank you all very much for your answers. I think the command
>> suggested by MagicFab is the one I am looking for:
>>
>> lshw -C cpu | grep width
>
> This won't give more information than if the CPU is 32-bit or 64-bit.
> And it's not installed by default in Parabola (and doesn't seem
> available on mips64el).

Well, this the Trisquel list, isn't it?

>
>
> For "uname -m":
>
> x86 i?86 unless /proc/cpuinfo has lm in flags
> x86-64/amd64 x86_64 or i686 if /proc/cpuinfo has lm in flags
> MIPS mips*
> ARM arm*

If someone has installed a 32-bit OS on a 64 bit system, the above won't
report x86_64.

The lshw command reports exactly that, no matter what version of the OS
is installed.

>
>
> (* has the usual meaning of matching any text.)
>
> Wouldn't expect 32-bit systems being common on x86-64 CPUs, this is
> useful nearly only for nonfree kernel modules built only for 32-bit x86.

You should :)

>
>
> I still don't believe that anyone reporting a non-x86 machine on h-node
> wouldn't know what CPU architecture it has (e.g. by choosing the
> installation media for it). (Or is there a free distro supporting
> multiple such architectures and being often preinstalled on non-x86
> devices? Ones I know support MIPS and are only on a single device model
> From a single seller.)

Don't underestimate the masses :)

Cheers,

Fabian

- --

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: PGP/Mime available upon request
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlAhgScACgkQfUcTXFrypNXdfACgyu2zQsfj/7tGnY0yut2hIxg+
lLoAoKp2oJmu5zymE64QQbvOgiWeWl0e
=7wmM
-----END PGP SIGNATURE-----

Michał Masłowski

I am a member!

I am a translator!

Desconectado/a
se unió: 05/15/2010

> Well, this the Trisquel list, isn't it?

Your question referred to h-node and to architectures not supported by
Trisquel, so I assumed you wanted to document it for testing any
machines for h-node.

> If someone has installed a 32-bit OS on a 64 bit system, the above won't
> report x86_64.
>
> The lshw command reports exactly that, no matter what version of the OS
> is installed.

That's why I recommended checking the /proc/cpuinfo file, the "lm" flag
tells exactly this. No significant reason to use one or the other
command.

> Don't underestimate the masses :)

Would be nice if users could buy an available ARM or MIPS machine,
install a free distro and forget that it's not x86. Many things are
missing for this yet.

lammi87

I am a member!

Desconectado/a
se unió: 07/27/2012

Your question referred to h-node and to architectures not supported by
Trisquel, so I assumed you wanted to document it for testing any
machines for h-node.

Yes, that's why I asked. I intend to write simple and easy to follow instructions a child could follow. I'm not too familiar with this subject, so I asked your help. Thanks for helping.

By the way, should I just look for certain flags from the following command's output?

sudo lshw -C cpu | grep capabilities
       capabilities: boot fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx x86-64 constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 lahf_lm tpr_shadow vnmi flexpriority cpufreq
          capabilities: logical
          capabilities: logical

I can see a x86-64 flag, so is finding that a certain way to tell I have a "x86-64/amd64" machine if running "sudo lshw -C cpu | grep width" is not?

Michał Masłowski

I am a member!

I am a translator!

Desconectado/a
se unió: 05/15/2010

> I can see a x86-64 flag, so is finding that a certain way to tell I
> have a "x86-64/amd64" machine if running "sudo lshw -C cpu | grep
> width" is not?

This flag is called "lm" in /proc/cpuinfo and in older lshw (it refers
to long mode, which is what 64-bit systems use). Would choose
"x86-64/amd64" if this flag is listed.

lammi87

I am a member!

Desconectado/a
se unió: 07/27/2012

A few questions:

1. Is there any reason to prefer either

lshw -C cpu | grep capabilities

or

cat /proc/cpuinfo | grep flags

when figuring out machine's architecture?

2. Are those both absolute sure ways to figure it out?

3. What kind of flags a user can find with these two lines if she has machine with any of the following four architectures? Is there a documentation about this somewhere?

lshw -C cpu | grep capabilities

x86
x86-64/amd64        x86-64
MIPS
ARM
cat /proc/cpuinfo | grep flags

x86
x86-64/amd64        lm
MIPS
ARM
Michał Masłowski

I am a member!

I am a translator!

Desconectado/a
se unió: 05/15/2010

> 1. Is there any reason to prefer either
>
> lshw -C cpu | grep capabilities
>
> or
>
> cat /proc/cpuinfo | grep flags
>
> when figuring out machine's architecture?

On my laptop running Brigantia the first command takes 10s and
recommends being run as root while "grep flags /proc/cpuinfo" takes
0.014s, so I would recommend the second command more for the speed
difference (and for availability on non-Trisquel distros).

> 2. Are those both absolute sure ways to figure it out?

They show if the CPU declares x86-64 support, so it should be sure
enough.

> 3. What kind of flags a user can find with these two lines if she has
> machine with any of the following four architectures? Is there a
> documentation about this somewhere?

Just use "uname -m", check the flags only if it declares i686.

lammi87

I am a member!

Desconectado/a
se unió: 07/27/2012

if uname -m gives i386, user's architecture is x86
if uname -m gives i686, run "cat /proc/cpuinfo | grep lm"
if lm is found, user's architecture is x86-64
if not found its x86

Right?

Does it make any difference if a user has installed a 32 bit OS on a 64 bit machine? MagicFab said it would.

Michał Masłowski

I am a member!

I am a translator!

Desconectado/a
se unió: 05/15/2010

> Does it make any difference if a user has installed a 32 bit OS on a
> 64 bit machine? MagicFab said it would.

It does, it prints i686 as you described. Otherwise it's x86_64.
(There is a similar situation on MIPS, mips64 or mips is shown depending
on kernel bitness; the linux32, linux64 and setarch programs can change
what is shown.)

lammi87

I am a member!

Desconectado/a
se unió: 07/27/2012

Thanks for your answer. I think I have most of the details I need. What kind of output would a user get from uname -m if she has ARM machine?

Michał Masłowski

I am a member!

I am a translator!

Desconectado/a
se unió: 05/15/2010

It starts with "arm", unsure what else would be stated by it.

lammi87

I am a member!

Desconectado/a
se unió: 07/27/2012

lscpu seems nice. Is it sufficient? Is it pre-installed with other free distros? It is included in util-linux package.

Michał Masłowski

I am a member!

I am a translator!

Desconectado/a
se unió: 05/15/2010

> lscpu seems nice. Is it sufficient? Is it pre-installed with other
> free distros? It is included in util-linux package.

Outputs on an x86_64 machine with x86_64 Parabola, x86_64 virtual
machine with i686 BLAG and mips64 machine with Parabola (mips64el)
suggest it being ok (for x86_64 it will tell that there is a 64-bit "CPU
op-mode", for most other architectures just the "Architecture" field
obviously states what's needed).

Practically all non-embedded distros have util-linux, the 2.15-rc1
release is the first one including lscpu (easy to check using git). Not
all free distros have it in the newest official stable release,
gNewSense 2.3 probably has an older one since Ubuntu Hardy has (although
it's easy to use uname -m and /proc/cpuinfo in such cases, like lscpu
internally does).

lammi87

I am a member!

Desconectado/a
se unió: 07/27/2012

Thanks a lot. I think I can start writing those instructions to h-node now.