Introduction to Basic Troubleshooting Terminal Commands in Ubuntu Linux
Summary: The following article provides an introduction about basic troubleshooting commands in Terminal for Ubuntu Linux.
Symptoms
Table of Contents:
- Introduction
- Examples of basic troubleshooting commands within Terminal and how to use them
- A list of basic troubleshooting commands and their function within Ubuntu Linux
Introduction
The following article deals with basic troubleshooting commands in terminal on an Ubuntu operating system.
The most common ways of opening a Terminal window in Ubuntu Linux are:
- Use the desktop search function to look for
terminal,command, orpromptand it brings up the Terminal window as a search result. - If you use the menus to locate it, most versions of Linux put it in the same location as the other application launchers.
- The following keyboard shortcut works across most Ubuntu revisions, and the other types of Linux. Press the CTRL + Alt + T keys down simultaneously.
See the following article if you are looking for a tutorial on general terminal commands:
See the following reference article if you were after a list of the most common commands:
Cause
Examples of basic troubleshooting commands within Terminal and how to use them
This list provides basic Terminal commands within Ubuntu Linux. It gives examples of how they can be used to help troubleshoot specific issues with your computer.
-
Use the command
unameto show what kernel is being used. The kernel is the first section of the operating system to load into memory. It controls such system areas as disk drive management, memory allocation, system processes, and interrupt handler. In the example below, the kernel being used is3.11.0-15-generic:user@avalon:~$ uname -aLinux avalon 3.11.0-15-generic #23-Ubuntu SMP Mon Dec 9 18:17:04 UTC 2013 x86_64 x86_64 x86_64 GNU/Linuxuser@avalon:~$ -
Use the command
dmesgto show the contents of the boot log. This is a good way to find errors at startup:user@avalon:~/linux101$ sudo dmesg > dmesg.logIn the example below, the command
catcan be used withdmesgto join the contents of the log file. The additional commandgrepcan be used to show any instance of a particular file name occurring in the log, for example, either Intel or error:user@avalon:~/linux101$ cat dmesg.log | grep intel[ 1.732400] intel_idle: MWAIT substates: 0x21120[ 1.732402] intel_idle: v0.4 model 0x3A[ 1.732405] intel_idle: lapic_timer_reliable_states 0xffffffff[ 10.148411] fbcon: inteldrmfb (fb0) is primary device[ 10.922434] i915 0000:00:02.0: fb0 inteldrmfb frame buffer device[ 10.926448] snd_hda_intel 0000:00:1b.0: irq 50 for MSI/MSI-Xuser@avalon:~/linux101$user@avalon:~/linux101$ cat dmesg.log | grep error[ 7.478502] EXT4-fs (sda2): re-mounted. Opts: errors=remount-rouser@avalon:~/linux101$ -
The command
lspcilists all devices that are found on the Peripheral Component Interconnect (PCI) bus:user@avalon:~/linux101$ sudo lspci > lspci.logUsing the
lspcicommand with the additional commands ofcatandgrephelps to isolate specific PCI devices, as with Realtek below:user@avalon:~/linux101$ cat lspci.log | grep Realtek07:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. TRL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 07)09:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS5209 PCI Express Card Reader (rev 01)09:00.1 SD Host controller: Realtek Semiconductor Co., Ltd. RTS5209 PCI Express Card Reader (rev 01)user@avalon~/linux101$ -
Use the command
lsmodto list all the loaded mod files within the kernel:user@avalon:~/linux101$ sudo lsmod > lsmod.loguser@avalon:~linux101$In Linux, the driver files are loaded as mods. To see which drivers or mods are loaded in the kernel, you can use the
catandgrepcommand. When used withlsmodto search for specific mod files, you can see two examples with Dell andhdabelow:user@avalon:~/linux101$ cat lsmod.log | grep delldell_wmi 12761 0sparse_keymap 13948 1 dell_wmidell_laptop 17369 0dcdbas 14847 1 dell_laptopwmi 19070 1 dell_wmiuser@avalon:~/linux101$user@avalon:~/linux101$ cat lsmod.log | grep hdasnd_hda_codec_hdmi 41117 1snd_hda_codec_realtek 55704 1snd_hda_intel 48171 3snd_hda_codec 188738 3 snd_hda_codec_realtek,snd_hda_codec_hdmi,snd_hda_intelsnd_hwdep 13602 1 snd_hda_codecsnd_pcm 102033 3 snd_hda_codec_hdmi,snd_hda_codec,snd_hda_intelsnd_page_alloc 18710 2 snd_pcm,snd_hda_intelsnd 69141 17 snd_hda)codec_realtek,snd_hwdep,snd_timer,snd_hda_codec_hdmi,snd_pcm,snd_seq,snd_rawmidi,snd_hda_codec,snd_hda_intel,snd_seq,device,snd_seq_midiuser@avalon:~/linux101$ -
Use the command
lsusbto list all the USB devices that are connected to the USB bus:user@avalon:~/linux101$ sudo lsusb > lsusb.loguser@avalon:~linux101$You can use this command with the additional
catandgrepcommands to isolate specific USB devices, as with Intel below:user@avalon:~/linux101$ cat lsusb.log | grep IntelBus 002 Device 003: ID 8087:07da Intel Corp.Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching HubBus 001 DEvice 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hibuser@avalon:~/linux101$ -
Use the
ifconfigcommand to set and query your computer's network settings:user@avalon:~/linux101$ ifconfig > ifconfig.loguser@avalon:~/linux101$You can use this command with the additional
catandgrepcommands to search forinet, which lists your computer's IP addresses:user@avalon:~/linux101$ cat ifconfig.log | grep inetinet addr:127.0.0.1 Mask:255.0.0.0inet6 addr: ::1/128 Scope:Hostinet addr:192.168.1.90 Bcast:192.168.1.255 Mask:255.255.255.0inet6 addr: fe80::caf7:33ff:fedb:b2bc/64 Scope:Linkuser@avalon:~/linux101$
Resolution
A list of basic troubleshooting commands and their function within Ubuntu Linux
The following table lists the more basic commands that are used within Linux for troubleshooting purposes. It gives the function and syntax for each:
| Command | Function | Syntax |
|---|---|---|
sudo |
Used before a command to run as root or an administrator. | sudo apt-get update |
ls |
Same as dir; lists the current directory. | ls-ll |
cp |
Copy the file. | cp /dir/filename /dir/filename |
rm |
Delete the file. | rm /dir/filename /dir/filename |
mv |
Move the file. | mv /dir/filename /dir/filename |
mkdir |
Make a directory. | mkdir /dirname |
df |
Report the disk space usage of the file system. | df -h |
dmesg |
Print or control the kernel ring buffer. | dmesg |
lspci |
List all the PCI devices. | lspci |
lsusb |
List all the USB devices. | lsusb |
lsmod |
Show the status of the modules in the Linux kernel. | lsmod |
cat |
Concatenate files and print on the standard output. | cat /dir/logfile |
grep |
Print lines of the input matching a specified pattern. | grep intel |
apt-get |
Update the installer. | apt-get update, or apt-get upgrade |
sosreport |
A utility that collects configuration and diagnostic information about your computer. The utility must be installed first using the following command line: "sudo apt-get install sosreport." It is recommended you reboot your computer after the install before first running the utility. | sosreport |
cat and grep together |
Use to list all the instances of a specific search item. | cat /dir/logfile | grep intel (the output of this command would print to the default output source any instance of the string "intel") |
For additional help troubleshooting your Dell computer, you can contact us from Dell's Support Website.