Checking Computer Specs in Linux

:!: Note: automated script downloadable at the bottom of this post!

Something you always want to do on a computer, even if only once, is to check its hardware specifications, that is:

  • how much RAM do I have?
  • how much hard disk space do I have?
  • how “fast” is my CPU?
  • how much RAM does my graphics card have?

Of course most modern GNU/Linux desktop environments like Ubuntu usually come with some kind of graphical tool to find this information. GNOME’s System Monitor program should provide at least some of what you’re looking for. The information here is more for when you’re staring at a blinking cursor on a black screen trying to remember what the command was to show information about the CPU, RAM or Graphics Card.

This is the third time I’ve had to go on an internet search quest to remind myself how to do this in a Linux terminal. To save myself the trouble in the future, I’m writing down the commands here and if anyone else finds it useful then that’s great, and a second bird is figuratively killed!

How much RAM do I have?

I’m not sure if there’s another way of doing this, but dmidecode is a tool for dumping DMI information in human readable form and can be used to show information about your RAM devices like this:

# dmidecode --type 17

How much hard disk space do I have?

To list your partitions and their information, including size, you can use the -l option on the fdisk command:

# fdisk -l

❗ It needs to be run with root privileges. With no arguments it describes all the devices found in /proc/partitions but you can also specify a device name, as in:

# fdisk -l /dev/sda1

How fast is my CPU?

You can find a lot of information about your CPU, including the number of cores and the clock speed in the /proc/cpuinfo file:

$ cat /proc/cpuinfo

How much RAM does my graphics card have?

It will take 2 steps to find out how much graphics memory your computer has. The lspci command is used to get information about PCI busses and devices connected to them. We need to search the output of the command for something VGA compatible:

$ lspci | grep VGA

That should return a line starting with a number. You use that number to refer to the graphics device to get info for it:

$ lspci -vs 01:00.0

The -v flag is for verbose output and the -s flag is for specifying the domain (the number from the first step). Among the information here will be the amount of memory, with the size written in square brackets at the end of the line.

A brief mention of that other OS…

I suppose the methods for the ubiquitous Windows operating system are just as obscure but having used it for years they probably seemed normal just because I was used to them. WinKey+Pause|Break was the shortcut for showing the properties of “My Computer” where you could check your RAM and CPU specs. WinKey+E was the shortcut for Windows Explorer, which would open at “My Computer”, showing you the sizes of the different partitions you have. Even less people would think of typing “dxdiag” at the run prompt (WinKey+R) to start the DirectX Diagnostics Tool, which gives you information about your graphics card. If you were wondering how you check your specs in Windows, I guess I just covered that too! 😀

Speaking of other operating systems, with its shared UNIX roots, I’d be interested to know if these commands work on the Mac OSX operating system too!

A script to automate the process

Shortly after writing this post I realised it might be nice if there was a shell script that did all the above things for you and output it all in a nicely formatted way, so I wrote one!

You can ➡ download the script file here or read the source code here. I considered writing a much more complicated script that could be used to check if your specs are high enough to play a specified game somehow, but this is about using the commandline and I doubt there’s a commandline game with requirements too high for your computer!

If you feel I’ve missed something out or if you think you have better way of doing these things, please add a comment below! Questions about these commands or my script are welcome too.

8 thoughts on “Checking Computer Specs in Linux

  1. This does not serve as any “correction” of any sort, just as an indication that under Linux you always have more than one way to achieve things – and that for good reason, because not every command may be successfull in all cases.

    Regarding “How much hard disk space do I have?”

    I would suggest to also mention the command

    df -h

    which will list not only the physical drives in your system, but also those other volumes you mounted, e.g. via an NFS share. While fdisk only focuses on the physical volumes (including SAN LUNs that may have been added), df will also list automounted devices such as USB sticks, CDs inserted etc. – and acyually also list the available free space on them. The -h makes it a “human readable” format, so you get an M or G to indicate Megabyte or Gigabyte of available storage.

    Regarding “How much RAM do I have?”

    the command

    cat /proc/meminfo

    will list you very detailes memory information, while your dmidecode command on a standard 32Bit Ubuntu Linux may also just render you

    # dmidecode 2.9
    SMBIOS 2.5 present.

    In my case that’s the output generated in a Ubuntu 11.10 virtual machine running under VirtualBox.

    Another option would thus be to use

    free -m

    (where -m gives you the size in Megabytes) to get a more abreviated display of avilable memory. This also works in virtual machines.

    Regarding “How fast is my CPU?”

    Here your DMI table tool may come in handy again with the following parameters:

    dmidecode -s processor-version
    dmidecode -s processor-frequency
    dmidecode -s processor-family
    dmidecode -s processor-manufacturer

    The same info is of course also available. under /proc/cpuinfo, but the output of dmidecode with the above parameters may be easier to use in scripts.

    Another idea under Ubuntu would be to do a

    sudo apt-get install sysinfo

    This (graphical) tools lists very neatly all of the above specs, plus a couple of additional ones (e.g. the network cards found) and allows you to actually save that info in a file for further use too (printing, emailing, whatever).

    • Thanks for that. Something like /proc/meminfo is exactly what I was looking for for RAM, I looked in that directory, I don’t know how I missed it! I’m also very unfamiliar with dmidecode. Would you like to test the script I wrote that does the stuff I mention in this post? It’s somewhere near the end and it uses the df command you mentioned, it produces nicely formatted output (which you could redirect to a file if you wanted) on my computer, but I’d like to know if it works OK on other people’s machines as well.

  2. Pingback: Checking Computer Specs With No Operating System | sinisterstuf

    • I’m avoiding putting Facebook ‘like buttons’ on my site because of privacy issues and also because I don’t like them on a site, I don’t think they belong here. For example, you won’t see advertisements from Google here either.
      However, there is a page for the site at if you would like to get updates directly on Facebook whenever something new happens here, like a new blog post or project.

  3. Thanks for the article. Gave me what I was looking for and more. Much appreciated. And Gerard Jensen too.

Comments are closed.