Linux system type check

How to determine whether a given Linux is 32 bit or 64 bit?

How can I know from this that the given OS is 32 or 64 bit? This is useful when writing configure scripts, for example: what architecture am I building for?

21 Answers 21

Try uname -m . Which is short of uname —machine and it outputs:

x86_64 ==> 64-bit kernel i686 ==> 32-bit kernel 

Otherwise, not for the Linux kernel, but for the CPU, you type:

Under «flags» parameter, you will see various values: see «What do the flags in /proc/cpuinfo mean?» Among them, one is named lm : Long Mode (x86-64: amd64, also known as Intel 64, i.e. 64-bit capable)

Or using lshw (as mentioned below by Rolf of Saxony), without sudo (just for grepping the cpu width):

lshw -class cpu|grep "^ width"|uniq|awk '' 

Note: you can have a 64-bit CPU with a 32-bit kernel installed.
(as ysdx mentions in his/her own answer, «Nowadays, a system can be multiarch so it does not make sense anyway. You might want to find the default target of the compiler»)

grep flags /proc/cpuinfo only tells you wether the CPU is 64bit. As I understand the question it was about the OS. uname -m only tells me «i686».

I have a 32 bit kernel on 64 bit hardware and get «x86_64» from ‘uname -m’ (on Debian). The man page for uname says that -m shows the machine hardware name, so that seems correct.

If I have a 32-bit kernel running on a 64-bit machine/ processor, what would uname -i , uname -p and uname -m show?

@JavierNovoaC. tm (Thermal Monitor) indicates Automatic clock control. It has nothing to do with distinguishing a 32-bit processor. In fact, lm (long mode) is present if and only if you have a 64-bit CPU. So that’s why you should only rely on lm. otherwise the answer given by Thomas Watnedal is the best. This answer is just wrong and has misled many people plz moderators do something about it.

Читайте также:  Linux find symbol in lib

If you were running a 64 bit platform you would see x86_64 or something very similar in the output from uname -a

To get your specific machine hardware name run

which returns either 32 or 64

That means the CPU is 64-bit, but you’ve only installed a 32-bit operating system upon it, even though you could have used a 64-bit one.

Steve Kemp is right, so be careful (Mac OS X 10.5 on 2009 MacBooks comes to mind, where the OS is 32-bit but its capable of running 64-bit apps)

The uname -m is not useful for the QP’s configure as it can give the wrong result. The getconf LONG_BIT get the default bit size of the C library which may not be the correct size for a specified, by CC , compiler.

getconf LONG_BIT may provide 32 ig it has been built as a 32 bit application (typically 64 bit kernel running a 32 bit userland).

lscpu will list out these among other information regarding your CPU:

Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit . 

Outputs the physical capabilities of the CPU, useful, but not reliable for the current userspace of the current OS.

Totaly wrong. The question is what OS is running. 42 upvotes? I would spend a down vote but it would drown.

Another useful command for easy determination is as below:

I guess it all depends on what the questioner means by «64-bit» — it used to mean the natural size of integers, but it’s now often used to mean the addressing size instead.

but is twice as fast to type

This returns the process types that the kernel can support. It is possible and even reasonable to run a 32 bit userspace on a 64bit kernel.

I was wondering about this specifically for building software in Debian (the installed Debian system can be a 32-bit version with a 32 bit kernel, libraries, etc., or it can be a 64-bit version with stuff compiled for the 64-bit rather than 32-bit compatibility mode).

Debian packages themselves need to know what architecture they are for (of course) when they actually create the package with all of its metadata, including platform architecture, so there is a packaging tool that outputs it for other packaging tools and scripts to use, called dpkg-architecture. It includes both what it’s configured to build for, as well as the current host. (Normally these are the same though.) Example output on a 64-bit machine:

DEB_BUILD_ARCH=amd64 DEB_BUILD_ARCH_OS=linux DEB_BUILD_ARCH_CPU=amd64 DEB_BUILD_GNU_CPU=x86_64 DEB_BUILD_GNU_SYSTEM=linux-gnu DEB_BUILD_GNU_TYPE=x86_64-linux-gnu DEB_HOST_ARCH=amd64 DEB_HOST_ARCH_OS=linux DEB_HOST_ARCH_CPU=amd64 DEB_HOST_GNU_CPU=x86_64 DEB_HOST_GNU_SYSTEM=linux-gnu DEB_HOST_GNU_TYPE=x86_64-linux-gnu 

You can print just one of those variables or do a test against their values with command line options to dpkg-architecture.

Читайте также:  Yandex browser под linux

I have no idea how dpkg-architecture deduces the architecture, but you could look at its documentation or source code (dpkg-architecture and much of the dpkg system in general are Perl).

Источник

7 Ways to Determine the File System Type in Linux (Ext2, Ext3 or Ext4)

A file system is the way in which files are named, stored, retrieved as well as updated on a storage disk or partition; the way files are organized on the disk.

A file system is divided in two segments called: User Data and Metadata (file name, time it was created, modified time, it’s size and location in the directory hierarchy etc).

In this guide, we will explain seven ways to identify your Linux file system type such as Ext2, Ext3, Ext4, BtrFS, GlusterFS plus many more.

1. Using df Command

df command reports file system disk space usage, to include the file system type on a particular disk partition, use the -T flag as below:

$ df -Th OR $ df -Th | grep "^/dev"

df Command - Find Filesystem Type

For a comprehensive guide for df command usage go through our articles:

2. Using fsck Command

fsck is used to check and optionally repair Linux file systems, it can also print the file system type on specified disk partitions.

The flag -N disables checking of file system for errors, it just shows what would be done (but all we need is the file system type):

$ fsck -N /dev/sda3 $ fsck -N /dev/sdb1

fsck - Print Linux Filesystem Type

3. Using lsblk Command

lsblk displays block devices, when used with the -f option, it prints file system type on partitions as well:

lsblk - Shows Linux Filesystem Type

4. Using mount Command

mount command is used to mount a file system in Linux, it can also be used to mount an ISO image, mount remote Linux filesystem and so much more.

When run without any arguments, it prints info about disk partitions including the file system type as below:

Читайте также:  Linux find path name

Mount - Show Filesystem Type in Linux

5. Using blkid Command

blkid command is used to find or print block device properties, simply specify the disk partition as an argument like so:

blkid - Find Filesystem Type

6. Using file Command

file command identifies file type, the -s flag enables reading of block or character files and -L enables following of symlinks:

file - Identifies Filesystem Type

7. Using fstab File

The /etc/fstab is a static file system info (such as mount point, file system type, mount options etc) file:

Fstab - Shows Linux Filesystem Type

That’s it! In this guide, we explained seven ways to identify your Linux file system type. Do you know of any method not mentioned here? Share it with us in the comments.

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Delete Huge Files in Linux

Parted Command in Linux

TLDR Man Pages for Linux Commands

apt-get Command Examples

Ubuntu apt-cache Commands

apt Command Examples

15 thoughts on “7 Ways to Determine the File System Type in Linux (Ext2, Ext3 or Ext4)”

will create a ext2 filesystem on image1, if its not big enough (warning “Filesystem too small for a journal” means a filesystem without a journal, a.k.a. ext2, is created) If you don’t realize this and nevertheless mount it as ext4. The df and mount methods above will mirror back ext4:

$ df -Th /tmp/mnt* Filesystem Type Size Used Avail Use% Mounted on /dev/loop4 ext4 1003K 24K 908K 3% /tmp/mnt1 /dev/loop5 ext4 987K 33K 812K 4% /tmp/mnt2 $ mount | grep mnt . /home/mallikab/image1 on /tmp/mnt1 type ext4 (rw,relatime,seclabel) /home/mallikab/image2 on /tmp/mnt2 type ext4 (rw,relatime,seclabel,data=ordered)
$ fsck -N /tmp/mnt1 fsck from util-linux 2.23.2 [/sbin/fsck.ext2 (1) -- /tmp/mnt1] fsck.ext2 /tmp/mnt1 $ fsck -N /tmp/mnt2 fsck from util-linux 2.23.2 [/sbin/fsck.ext4 (1) -- /tmp/mnt2] fsck.ext4 /home/mallikab/image2 $ file -sL /home/mallikab/image2 /home/mallikab/image2: Linux rev 1.0 ext4 filesystem data, UUID=b4e8e086-54ca-4d9d-9f38-32bbed211e6b (needs journal recovery) (extents) (64bit) (huge files) $ file -sL /home/mallikab/image1 /home/mallikab/image1: Linux rev 1.0 ext2 filesystem data (mounted or unclean), UUID=09b3a8c9-0b6d-43c5-b195-c45f6c091765 (extents) (64bit) (huge files) hm, although fsck doesn't indicate ext2 unless the images are mounted, i.e. $ fsck -N ~/image1 fsck from util-linux 2.23.2 [/sbin/fsck.ext4 (1) -- /home/mallikab/image1] fsck.ext4 /home/mallikab/image1

The only working method for me was ‘ lsblk -f ‘; the other replied “fuseblk“, “HPFS/NTFS/exFAT” or nothing. Reply

Источник

Оцените статью
Adblock
detector