Ceci est une ancienne révision du document !
I recently read a book called Linux Unveiled, that unveiled only that the author, ‘Half-job Hussain’, had no idea how to show newbies around. I did like some of the book somewhat (very little), so I’ll be stealing some of that to do a proper job for our FCM newbies (no, I will not be using anything from that horrible book). I’ll try to take a more hands-on approach, so I would ask you to keep your terminal emulators open and follow along, just to get the muscle-memory going. Now obviously I cannot cover a whole book’s worth of stuff on here, but I’m thinking CPU, memory, and disk here. This can then tie into some of the LPI stuff we are covering elsewhere. That means there will be homework, but I’ll keep it short.
Say you logged on to a friend’s computer and the prompt did not display the name of the computer, you could use the hostname command to get that information, right? But how would you get more information, like the “about” page on Gnome, but from the command line? Yep, the smarties among you got it immediately, hostnamectl. The nice thing about hostnamectl, is that you can immediately see if you are in a virtual machine or not (Chassis).
You could see “desktop” or “laptop” on your machine instead, and if yours did say either, you would not see “Virtualization”. We can see the operating system name, in my case Ubuntu 24.04, even though it is Lubuntu and my kernel version. If I wanted more information on the kernel, I would use: uname -a and I’d get a bit more, but not too much more. If I really wanted more information about my CPU, I’d use cat /proc/cpuinfo | less and I’d get a decent info dump. Go ahead, try it quickly, I’ll wait…
Now, if I needed more information on my OS, I could try cat /etc/*-release and see the codename of my OS (sorry about the mistake, a girl with long, long legs and short shorts was mobile zombie-ing around in the coffee shop, but I’ll leave it there so you can see everyone makes mistakes.) Then there are the ls-commands, like lshw, or if we are talking CPU, lscpu, or even lsusb or lspci and so forth. My point is that there are lots of ways for you to find out more about a foreign (or your own!) computer.
Most of you know: df -h - to see information on how full - or empty - your drive is and: free -h - to see the same about your memory. A favourite of the LPI exams is: uptime, though in my whole career, I have never needed to type that command once in the real world(!), we just have so many better tools, for instance, I can see the uptime in: htop - and usually I have some form of monitoring software installed to get a better view of load over time. I love that there are many ways to skin a cat in Linux! Hehe, yes, I suppose lolcat would be “skinning” your terminal output… but you know what I mean.
Before I move on, let’s quickly look at what we covered in that short piece: • hostname, hostnamectl, uname, lscpu, lshw, lspci, lsusb, df, free, uptime, htop, lolcat • 12 commands in 5 minutes; you are on a roll my friend!
One way of finding out what you are dealing with, when troubleshooting, is the log file, or should I say logs, as there are quite a few. The main one I’d like you to look at is: tail /var/log/syslog (I trust that you are familiar with head and tail?) or you could peruse the whole thing: cat /var/log/syslog | less (I will also assume you know more and less, as they are some of the first commands that one learns when using a terminal). Most of you should also be familiar with: dmesg - or if you did not use earlier versions of Ubuntu, it would be: sudo dmesg - (it did not need sudo elevation before 20.04? not 100% on that, don’t quote me, but if you have old Ubuntu in a VM, say, Hardy Heron or whatever, you can just type dmesg.)
You should know that dmesg is not the only way to see what is/has happened during your boot. You could also look at the boot log: tail /var/log/boot.log
Your homework, erm, mission – should you choose to accept it – is: 1. To look inside the /var/log/ directory and poke around in some of those log files. In particular, I want you to check the logged-on users with the command: w - and then check auth.log to see those users. On some servers though, the logs may be sent off to a log server, so I would suggest doing this on your own desktop/laptop/VM. 2. To type sudo dmesg and type the password wrong three times. I then want you to go and look at /var/log/auth.log - we will talk about this in the next issue.
Now that you have wet your footsies in logfiles, remember to actually go here (/var/log) and have a look here, next time you get an error on the command line.
We covered the ‘where’ “where am I”, and the ‘how’ “how do I check for errors”. ‘When’ you are is not important, but if you really have to know, type: date ;)
As always, should you find an error, or think I helped you in a wrong direction, please let us know on: misc@fullcirclemagazine.org