What's in this computer?
Somebody hands you a server and asks "what is it?". How many CPUs, how much memory, which disks, which Linux, which kernel, and is it even a real machine or a virtual one? Linux can tell you all of that from the command line. This is the first thing a sysadmin does on a new box.
You will learn
- Which Linux and kernel:
/etc/os-release,uname,hostnamectl - CPU and memory:
lscpu,nproc,free -h,/proc/cpuinfo,/proc/meminfo - Disks:
lsblkanddf -h, and the difference between them - Devices:
lspciandlsusb - The firmware's view:
sudo dmidecode, andsystemd-detect-virtfor "am I a VM?"
Which Linux, which kernel?
cat /etc/os-release # the distribution: NAME, VERSION, ID, ID_LIKE uname -r # the kernel version, e.g. 5.14.0-570.22.1.el9_6.x86_64 uname -a # everything: kernel, host name, architecture hostnamectl # host name, OS, kernel, hardware vendor and model in one screen
ID_LIKE in os-release tells you the family: rhel centos fedora or debian. Scripts check it to decide between dnf and apt.
CPU and memory
lscpu # model, CPU(s), cores, threads, caches, virtualisation nproc # just the number of CPUs you can use: 4 free -h # memory and swap, in human units cat /proc/cpuinfo | grep "model name" | head -1 head -3 /proc/meminfo
/proc isn't a real folder on disk. The kernel makes those files up on the spot when you read them, so they're always current. Tools like lscpu and free mostly just read /proc and format it nicely.
available, not free
In free -h, look at the available column. Linux uses spare memory as a cache for files (buff/cache), and hands it back the moment a program needs it. Low "free" is normal; low "available" is a problem.
Disks: lsblk vs df
lsblk # the disks and partitions the kernel sees, mounted or not df -h # mounted filesystems and how full they are
lsblk answers "what disks are plugged in?". df answers "how much space is left?". A brand-new disk shows up in lsblk but not in df until you format and mount it. (That's the Linux Sysadmin, lesson 7 lesson.)
Devices on the buses
lspci # graphics, network cards, disk controllers (the PCI bus) lspci -k # …and which kernel driver runs each one lsusb # USB devices: keyboard, stick, webcam
A minimal install doesn't have them: sudo dnf install pciutils usbutils.
Ubuntu Server already has pciutils and usbutils.
Maker, model, serial: dmidecode
sudo dmidecode -s system-manufacturer # Dell Inc., LENOVO, innotek GmbH (VirtualBox)… sudo dmidecode -s system-product-name # the model sudo dmidecode -t memory # RAM sticks and slots cat /sys/class/dmi/id/product_name # some of it, without root systemd-detect-virt # kvm, oracle (VirtualBox), vmware, amazon… or none
dmidecode reads tables the firmware (BIOS/UEFI) fills in: the only way to learn a server's serial number without walking to the rack. It needs root because those tables include serial numbers.
The practice server is a virtual machine, and the tools say so: lscpu shows a Hypervisor vendor line, lspci lists VirtualBox devices, dmidecode says innotek GmbH / VirtualBox, and the network card's MAC address starts with 08:00:27, VirtualBox's prefix. On a cloud server you'd see Amazon EC2 or KVM instead.
Practice: write a machine report 🔍
Find out everything about this server, then save a short report you could send to a teammate.
Quick check
1. You plugged in a new disk. lsblk shows it, df -h doesn't. Why?
✓ lsblk = devices the kernel sees. df = space on mounted filesystems.
2. free -h says only 180 MB "free", but 2.6 GB "available". Is the server running out of memory?
✓ Unused RAM is wasted RAM, so Linux borrows it for caching.
3. Why does dmidecode need sudo?
✓ Reading, not writing. A few harmless fields are copied to /sys/class/dmi/id for everyone.