Knowing about our computers can be very important when troubleshooting. It's easy to find our OS and kernel version as well as analyze system resource usage.
- [Instructor] It's often helpful to gather information about the operating system we're running. This may be the Linux kernel version, the distribution type and version, how long our system has been running, the hostname of our system, or even memory usage. There is no standard way of identifying a Linux system, although an attempt has been made to unify Linux through the Linux Standards Base, or LSB. Included in LSB is a tool that gives us data about our OS. But before we can use this tool, we need to install it. Let's go to Applications, Favorites, Terminal.
I'm going to make my Terminal full screen, and bump the font. To install LSB, type in sudo yum install redhat-lsb-core and hit Enter. Type in your password, and say yes to install. Between each operation in this video, I'm going to type in clear to clear my screen. Once redhat-lsb-core is installed, type in lsb_release -a and hit Enter.
This will give us the distribution name and version number. Another way to find out which distribution you're using is to view /etc/redhat-release file. This only works on Red Hat based distributions though. To view this file, we'll use the cat command, cat /etc/redhat-release. Hit Enter. This gives us the same information as lsb release -a for the most part. I'll go ahead and clear my screen. To find the hostname of our CentOS Linux system, we can use the hostnamectl command.
Type in hostnamectl and hit Enter. The hostnamectl command is part of systemd, a new way of managing system services in Linux that is becoming increasingly popular. In a sense, it's unifying the system configuration of different versions of Linux. However, versions of Linux that don't use systemd won't have this command. For these systems, type in hostname and hit Enter. The hostname command still works on CentOS but gives less information than the hostnamectl command.
Type in clear to clear your screen. To gather information about our kernel, we can use the uname command. Type in uname -r. Uname -r shows the kernel revision alone. In my case, the revision is a very long, 3.10.0-327.36.3.el7.x86_64. The major kernel version is 3.10, and it's had 327 revisions.
The el7 signifies this kernel is for Red Hat Enterprise Linux 7, and the last section is for the CPU architecture. In my case, an x86 64-bit processor. To show all kernel information, type in uname - a. This adds in the hostname and the time the kernel was built. Type in clear again to clear your screen. If we want to see how long our system has been running, we'd check the uptime by typing in uptime. If you want an easier to read, or pretty output, use the -p option.
We're going to clear our screen again by typing in clear. If we want to see messages from the kernel, we can use a dmesg command. This will show programs that failed, devices that have errors, or even programs that did work and they output a message telling us so. Type D-M-E-S-G, and hit Enter. The output of dmesg can be fairly cryptic, so if you want a slightly more human readable version, use the -H option, dmesg -H and hit Enter. To exit this, press Q.
You may also want to know how much memory our system has, so let's type in clear, and then type in free -m. The -m option shows our memory in megabytes. For really detailed information about memory, you can view the meminfo file in /proc. So type in cat /proc/meminfo and hit Enter. This file may very well tell us more about our memory than we ever wanted to know. It includes total memory, free memory, and even virtual memory used as swap.
Type in clear again. The very last tool we're going to look at is actually a graphical tool called GNOME System Monitor. To ensure that it's installed, type in sudo yum install gnome-system-monitor and hit Enter. Type in your password. And if it's not installed, say yes to install it. In our case it is, so let's close our Terminal, and go to Applications, System Tools, System Monitor.
We'll make it full screen. The GNOME System Monitor has three tabs, Processes, Resources, and File Systems. The Processes tab shows running processes on the system started by your user. If you want to end a process, you can just click on one and click the End Process button at the bottom of the window. The middle tab is for Resources. Namely, CPU, Memory, and Network usage history. Lastly, the File Systems tab shows a nice graphical representation of our accessible partitions, and how much space they're using.
Getting information about your system is half the battle of troubleshooting problems. Using the tools shown in this video will make the process much easier.
- Learning Linux command syntax
- Getting help on the CLI and GUI
- Finding help online
- Using basic commands
- Navigating file systems
- Editing text