General Troubleshooting in LinuxMon, Feb 9, 2009
Getting ram information
or if you want to get just the amount of ram you can do:
cat /proc/meminfo | head -n 1
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.
sudo dd if=/dev/mem | cat | strings
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.
cat /proc/cpuinfo top
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.
sudo fdisk -l
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
dpkg --get-selections | less
Find out why a packages is installed and what depends on it
aptitude why packagename
Find out where the package stores all of its files
dpkg -L packagename
Kill a process
ps -A | grep ProgramName kill 7207
Go to a terminal
Ctrl + Alt + f3 return with, Ctrl + Alt + f7
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.
watch ls watch df -h
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
dmesg | less
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.