2

Are there any commands that I can use on a secondhand laptop or PC running Linux that will tell me if there are any problems with the system? If so, what are they?

For example, battery life/condition, hard drive space, bad sectors, bad RAM, bus speed, video/audio hardware and driver specs, LAN card specs, etc., etc.

4
  • This probably won't be a quick job like you seem to think. You may wanna start with something simple like specs with hardinfo, gpu-g or perlmon. There is also a thread about this on askubuntu. askubuntu.com/questions/109935/…
    – Cestarian
    Commented Mar 2, 2016 at 5:15
  • 1
    If you have bad hard drive, you can just fsck it. :)
    – Munir
    Commented Mar 2, 2016 at 5:17
  • @munircontractor I don't know how long that would take, and perhaps it would not go down well with the owner :/ Commented Mar 2, 2016 at 5:26
  • @fuzzyanalysis fsck is quite fast actually, but you must unmount your drive to run it (so you can't run it on your system drive, although as I said in my answer, it is usually run as a necessary part of the booting process since a forceful or hectic shutdown can easily damage ext partitions and thus they have to be repaired)
    – Cestarian
    Commented Mar 2, 2016 at 8:24

1 Answer 1

13

Lets go from top to bottom, this guide is not distro specific (most of these commands will be available on most distros either out of the box, or through the package repositories) first you probably want to get the rough lay of your hardware specs. For this you have a couple options:

All in one options:

inxi --admin --verbosity=7 --filter --width #<- Lists your complete system specs
lshw #<- Lists your complete system specs, sudo recommended
hwinfo > hwinfo.txt #<-Writes your hardware info in extreme detail to hwinfo.txt

All in one GUI options:

hardinfo #<- A pretty good GUI system information utility, also offers benchmarks.
i-nex #<- Similar to CPU-Z on windows
lshw-gtk <- GUI for lshw

Targeted options:

cat /sys/devices/virtual/dmi/id/board_{vendor,name,version} #<- Lists your motherboard details.
lspci -Q #<- Lists all your internal hardware and checks online for missing/updated names.
lspci -v | grep "VGA controller" #<- Displays your currently active graphics card. Very useful on laptops with hybrid/switchable graphics. (Typically this is the integrated card unless you have configured it otherwise)
lspci -v | grep "3D controller" #<- Displays your Nvidia Dedicated GPU. For laptops with hybrid/switchable graphics.
lspci -v | grep "Display controller" #<- Displays your ATI/AMD Dedicated GPU. For laptops with hybrid/switchable graphics.
lsusb #<- Lists all your USB hardware.
lscpu #<- Lists detailed processor info (alternative: cat /proc/cpuinfo )
fdisk -l #<- Lists your hard drives and partitions (may requires sudo access).
free -h --si #<- Lists your memory information, total is your total, available is your total free memory.
cat /proc/meminfo #<- Much more detailed info on your memory
ip link #<- lists your network devices and their status

Let's also do a quick check for kernel errors:

cat /proc/kmsg | grep -i Error #<-Lists errors detected by the kernel (often hardware related ones), probably requires sudo access.

Now that we know what we're working with, we're going to check thermals, most distros do not have lm_sensors installed by default, lm_sensors is usually the package name, but sometimes it can be sensors.

It is invoked like this:

sensors-detect #<-Detect sensors on your pc; you only need to do this once. Requires sudo.
sensors #<-Display current values for known sensors on your pc

After this, if you want a GUI utility to monitor these sensors you can use psensor

If you want to see temps or other information for an Nvidia GPU and you have the proprietary drivers for it installed, run nvidia-smi.

Next up, we're gonna go for hard drive diagnostics, fsck is run on bootup for most linux distributions (it's pretty much standard, it is run on Linux mint) to check for and fix hard drive errors and bad sectors, so you pretty much don't need to do this. fsck can not be run on a mounted drive so if you want to further diagnose your hard drive you are going to have to boot out of your system and use a 3rd party utility such as system rescue cd(or another live cd/usb) or ultimate boot cd. Additionally smartmontools's smartctl can be used to run SMART tests, like fsck, the more in-depth tests can not run on a currently mounted drive (but many drives do support running these tests automatically when they are offline). Anyhow, there are a few more things that can be done from your running system. hdparm can be used for analyzing and tuning a hard drive.

dd if=/dev/zero of=$HOME/testfile bs=1G count=1 conv=fdatasync oflag=direct #<- Measures throughput of your hard drive (whichever one has your home folder on it).
hdparm -Tt /dev/sdx #<- Gives read speed information on hard drive sdx. I won't cover this in more detail, but you can look for guides on it.
smartctl -Hic /dev/sdx #<- Gives basic info of hard drive sdx and runs an overall health assesment. (If the assessment fails either the drive has failed or is in the process of failing) it then lists the drives SMART capabilities.
smartctl -t short /dev/sdx #<- Runs a short SMART test (cannot be run on a mounted drive (some drives support offline data collection and can automatically run the test on shutdown))

For more thorough hdd benchmarking with fio, using a similar format to crystaldiskmark which windows users may be familiar with, see this answer or use kdiskmark.

On memory testing, for a full on memory test you will most likely need to boot into a memory testing utility (like memtest86+, often embedded into livecds, you may also be able to install it and update grub to display it), but from inside a running linux environment, you can use memtester

memtester 1024 5 #<- Sets aside 1GB(1024MB) free memory, and runs tests on it 5 times, then displays results.

The best way to properly diagnose a LAN devices performance without simply testing how fast (and much) it can send or receive data to/from another device. But to do that you can use iperf or netcat (nc) in conjunction with dd (which we used before to test hard drive). Do note that you actually can test your network cards throughpout from itself to itself by hosting the server on your computer, and then connecting to yourself using the address localhost or 127.0.0.1

iperf -s #<- Starts iperf server (run this on the device you want to connect to, yes, as I said you need another computer for this)
iperf -c <address of server computer> #<- Connects and displays transfer rate information.
nc -vvlnp 12345 >/dev/null #<- Starts a netcat server (requires open firewall port for port 12345 if you have a strict firewall)
dd if=/dev/zero bs=1M count=1K | nc -vvn <server IP address> 12345

For battery testing there are two choices. gnome-battery-bench (graphical) or acpi (terminal) or upower (terminal) these are example commands:

acpi -ib #<- Lists battery status, basic specs and gives an idea of it's health (shows it's charge level last time it was "full")
upower -i /org/freedesktop/UPower/devices/battery_BAT0 #<- Should provide detailed battery information.

For sound testing. well I have no idea why you would want to do that, if sound works it works, if it doesn't work it doesn't work, but lets do this anyways with ALSA (just so it'll work on all distros). You need alsa-utils for this.

speaker-test -c 6 -t wav #<- Runs test sound on 6 speaker channels (for 5.1 speaker setup, you can use -c 2 for stereo speakers), just to see what happens.
speaker-test -r 96000 -f S32LE #<- Test stereo wav sound at 32-bit on 96khz frequencies. You can use this to test the maximum supported format and frequency (for example, while you sepcify 32-bit format, it may set to 16-bit format, if it does this then it will say so so read the output)
aplay -l #<- Lists sound output devices.
speaker-test -D hw:0,0 -c 4 -r 48000 -t wav #<- Test on specific hard ware device 0,0 at 4 channels with 48khz rate.
arecord -l #<- Lists recording devices.
arecord -f dat -d 20 -D hw:0,0 test.wav #<- Test specific recording device by outputting to a file in basic DAT quality
aplay -f dat test.wav #<- Play the recorded test file.

Any further testing (CPU and GPU performance) will require either dedicated benchmarking/stresstesting programs, or booting into a specialized testing environment. Here is a list of the benchmarking utilities I would suggest besides the ones already mentioned. As always with graphical benchmarks, you want to make sure VSync is disabled.

  • glxgears (part of mesa; very basic test of opengl performance)
  • vkcube (part of vulkan-tools; very basic test of vulkan performance)
  • Unigine Heaven or Unigine Valley (Graphical benchmarking program, for testing 3D gaming performance under heavy loads)
  • sysbench (Command-line benchmarking tool for cpu, memory and hdd among others, guide)
  • stress (a command-line CPU and HDD stress testing utility)

And last but not least, don't forget that to be perfectly thorough in your testing, you will want to launch a hardware-testing boot cd like Ultimate Boot CD since there are so many things that cannot be done (at least not effectively) from a running operating system.

5
  • Thanks. Any sort of small performance test (if it's an easy 1-2 line command that I can remember when out and about looking at systems in shops, for example) on any kind of hardware (cpu, ram, hdd, video, audio, motherboard, monitor, battery, etc), but I think you already hit a few of those with your list above. Very handy, cheers. Commented Mar 2, 2016 at 5:55
  • 1
    @fuzzyanalysis I revised my answer, have another look :)
    – Cestarian
    Commented Mar 2, 2016 at 7:07
  • that is a brilliant answer that I am sure many people will benefit for a long time to come. Thanks so much :) Commented Mar 3, 2016 at 9:53
  • 1
    And for finding out what is exactly in that box, I like lshw -html > /path/to/file/hw.html as root and then look at the resulting file in a web browser. Basically a nice formatted combo of all the different ls[pci|usb|etc] stuff plus more.
    – ivanivan
    Commented Dec 31, 2018 at 6:28
  • @ivanivan that is quite nice.
    – Cestarian
    Commented Jan 1, 2019 at 3:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .