Find the answer to your Linux question:
Results 1 to 8 of 8
Hi, Which of these is the accurate way of determining if the OS (not the cpu) is 32 or 64 bit? uname -a | grep "x86_64" => $? = 0 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2009
    Posts
    11

    Best way to find if OS is 32 or 64 bit?


    Hi,

    Which of these is the accurate way of determining if the OS (not the cpu) is 32 or 64 bit?

    uname -a | grep "x86_64" => $? = 0 implies 64bit

    uname -p | grep "x86_64" => $? = 0 implies 64bit

    getconf LONG_BIT (returns 32 or 64)

    Thanks

  2. #2
    Linux User
    Join Date
    Nov 2009
    Location
    France
    Posts
    292
    Could you consider
    Code:
    file /bin/bash
    ?
    0 + 1 = 1 != 2 <> 3 != 4 ...
    Until the camel can pass though the eye of the needle.

  3. #3
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,398
    uname -m works for me
    You must always face the curtain with a bow.

  4. #4
    Just Joined!
    Join Date
    Feb 2009
    Posts
    11
    @nmset

    Is that guranteed to give the correct result? Also this method would require to parse the output. I am looking for some command which gives direct result without having to parse a text.

  5. #5
    Just Joined!
    Join Date
    Feb 2009
    Posts
    11
    @Irithori

    Everytime I see the manpage for uname, I get more confused.

    What is the difference between uname -m and uname -i. They seem like they are information regarding machine hardware. Not sure how it is related to the OS that is installed on the machine. Please can you explain.

    Thanks

  6. #6
    Linux User
    Join Date
    Nov 2009
    Location
    France
    Posts
    292
    There are certainly many ways to get to what you are looking for.

    The reasoning behind the using the file command on the bash binary is that you're doing it in a bash session originating from the very binary you're testing, and there's not much parsing to do

    Code:
    file /bin/bash | grep -c "64-bit"
    will give you 0 or 1.

    Code:
    uname -m
    is more direct however.
    0 + 1 = 1 != 2 <> 3 != 4 ...
    Until the camel can pass though the eye of the needle.

  7. #7
    Linux Guru rokytnji's Avatar
    Join Date
    Jul 2008
    Location
    Desert
    Posts
    4,136
    Easy way

    INXI Script

    I have it installed from Puppy Linux to Ubuntu.

    Code:
    ystem:    Host owner-desktop Kernel 2.6.32-22-generic x86_64 (64 bit) Distro Ubuntu 10.04 lucid
    CPU:       Dual core AMD Athlon 64 X2 4200+ (SMP) cache 1024 KB flags (lm nx sse sse2 sse3 svm) bmips 8799.08 
               Clock Speeds: (1) 2199.774 MHz (2) 2199.774 MHz
    Graphics:  Card nVidia G71 [GeForce 7900 GS] X.Org 1.7.6 Res: 1024x768@50.0hz 
               GLX Renderer GeForce 7900 GS/PCI/SSE2 GLX Version 2.1.2 NVIDIA 195.36.24 Direct Rendering Yes
    Audio:     Card ATI SBx00 Azalia (Intel HDA) driver HDA Intel BusID: 00:14.2
               Sound: Advanced Linux Sound Architecture Version 1.0.21
    Network:   Card Realtek RTL8111/8168B PCI Express Gigabit Ethernet controller driver r8169 v: 2.3LK-NAPI at port dc00 BusID: 02:00.0
    Disks:     HDD Total Size: 320.1GB (4.4% used) 1: /dev/sda WDC_WD3200AAKS 320.1GB 
    Partition: ID:/ size: 288G used: 14G (5%) fs: ext4 ID:swap-1 size: 6.17GB used: 0.00GB (0%) fs: swap 
    Sensors:   System Temperatures: cpu: 49.0C mobo: 46.0C gpu: 0.0:66C 
               Fan Speeds (in rpm): cpu: 5400 psu: 0 sys-1: 1010 
    Info:      Processes 168 Uptime 5:53 Memory 589.6/2008.5MB Runlevel 2 Client Shell inxi 1.4.10

    Code:
    ~$ inxi -F
    Resuming in non X mode: glxinfo not found in path
    System:    Host Biker Kernel 2.6.32-1-mepis-smp i686 (32 bit) Distro antiX-core-686-a1 20 June 2010
    CPU:       Single core Pentium III (Coppermine) (UP) cache 256 KB flags (sse) bmips 1396.28 clocked at 698.057 MHz 
    Graphics:  Card ATI Rage Mobility P/M AGP 2x tty res: 80x24 
    Audio:     Card ESS ES1988 Allegro-1 at port e800 BusID: 00:0a.0
               Sound: Advanced Linux Sound Architecture Version 1.0.21
    Network:   Card Realtek RTL-8139/8139C/8139C+ driver 8139too v: 0.9.28 at port e400 BusID: 00:09.0
    Disks:     HDD Total Size: 30.0GB (5.4% used) 1: /dev/hda IC25N030ATCS04-0 30.0GB 
    Partition: ID:/ size: 5.8G used: 1.3G (23%) fs: ext3 ID:swap-1 size: 0.58GB used: 0.00GB (0%) fs: swap 
    Info:      Processes 69 Uptime 1:16 Memory 70.9/374.6MB Runlevel 5 Client Shell inxi 1.4.10
    Last edited by rokytnji; 06-25-2010 at 07:39 PM.
    Linux Registered User # 475019
    Lead,Follow, or get the heck out of the way. I Have a Masters in Raising Hell
    Tech Books
    Free Linux Books
    Newbie Guide
    Courses at Home

  8. #8
    Just Joined!
    Join Date
    Feb 2009
    Posts
    11
    Thank you nmset for the explanation. That makes sense.

    Thank you all for the responses.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •