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 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, write me on Twitter or get in contact! Questions about these commands or my script are welcome too.