Troubleshooting in Linux is a breeze if you know which tools to use and how to use them. In this article we learn to do some general Linux troubleshooting on the most common elements of the computer: hardware, programs installed, network, and log files.
Getting ram information
or if you want to get just the amount of ram you can do:
Another fun thing to do with ram is actually open it up and take a peek. This next command will show you all the string (plain text) values in ram.
Getting cpu info
Sometimes in troubleshooting we want to know what processor we are dealing with along with how much cpu is currently being used by our OS and programs. We can do this with these two commands.
Check the temperature of your CPU
Keeping a computer within a safe temperature is the key to maintaining a stable system.
List PCI and USB devices
To list all the PCI devices in your system issues the following command:
For USB use:
Check out how much hard drive space is left
See what hard drives are currently detected
It is often times helpful to know what hard drives are connected to a system and what name was given them in the Linux directory. This info allows us to mount the hard drive and manipulate it.
Ever want to find all the packages that are installed on your system? You can find all the packages and also find out why they are on your system. You can even determine what packages depend on them if any.
Find all installed packages
Find out why a packages is installed and what depends on it
Find out where the package stores all of its files
Kill a process
Go to a terminal
Show all network connections
There are many great network scanners and assessment tools available for Linux but netstat is a very easy to use often a first step in troubleshooting network issues. We will leave the rest of the network tools for a later article as there is so much to cover.
List all files that are currently open on the system
This command will allow you to see all the files that are currently open on your system. Limiting the directory or coupling this command with grep is often useful for finding files that are still open restricting the ability to unmount a device. Lsof will also ouput the process id or PID. You can then kill the process using the kill command above.
Keep an eye on something for awhile
The watch command will repeat a command at a set interval (default 2 seconds) and output the response. This is useful for watching directories that change, watching hard drives fill up when a lot of data is being transfered, or using it with lsusb to watch for USB devices being plugged in.
Find where a binary is stored and its libraries
Often times when running a cron command you want to include the absolute path to the command. Sometimes I run scheduled PHP tasks. This can be acomplished by using the ‘whereis‘ command.
See if you have kernel boot issues
For more logs just cd into the /var/log directory and start using, cat, less, tail, grep, find or any other tool to view and search.