System Information
uname¶
uname is a common utility to get information about the system. There are quite a few switches. The -a switches displays all the information. This command shows machine name, information, about the kernel and time. Check the man page for all the available switches.
os-release¶
Not all linux distributions are the same. Some use different package managers, init systems, and configure things differently. It is useful to identify the distribution the system is using. This can be done by viewing the file /etc/os-release. cat is an easy way just to view the contents of a file
hostname¶
To get the system name of a computer you can use hostname command or hostnamectl. These command have a few switches so check the help or man page. hostnamectl gives more information. I recommend to use it when its available on a system.
hostname and hostnamectl examples
df¶
df gives information about mounted file systems. This is often used to look at how full a file system is. It has a few switches so check the man page. The switch I most commonly use with this is -h. This makes the sizes as human readable. This means sizes will be in largest unit possible Megabyte, Gigabyte, Terabyte instead of bytes. You can also specify the -b switch and a single upper case character like M for megabytes or G for gigabytes.
du¶
df gives us information on the file system, but it does not tell us where that space is being used. du is the utility we use to check in what files and folders space is being used. It has quite a few switches as well. The most common switches I use with this command is -d and -h. -h functions the same as it does in the df command. -d is a depth switch and must have a number after it. This limits the output of the report to however many folders deep you select. You will often have to run this command as root or with sudo to avoid permission errors.
du examples
lsblk¶
Often we will need to know what block device (hard disk) is associated with a file system this can be done with lsblk
free¶
Getting information about the memory and swap on a system can be vary useful. This is done with the free command. Again my most common switch for this is -h for human readable. There are also switches for specific sizes, but check the man page because it is different than df.
lscpu¶
To get information about the cpu you can use lscpu. This will tell you make and model of the cpu as well as other information. It can tell you how many cores, how many sockets, how many threads per socket.
uptime¶
uptime tells us how long the system has been up. There are a few switches with it. -p will give an output like "up 10 minutes". -s will say the system has been up since a certain time like "2027-07-18 18:00:00"
last¶
last is a useful command to tell you when a user logged in. It can also tell you the last time the system was rebooted. last without any arguments prints all information. last with the username prints just information for that user
Exercise¶
Note
On AWX https://tower.tuckhome.lan use the User Management - Setup, User Management - Grade, User Management - Cleanup.
These commands do not have any last effect on the system, so we will use redirection to save some information to text files for checking.
Tasks¶
- Using redirection get the kernel release in file /home/student/kernelrelease
- Save the full hostname (fully qualified domain name) to /home/student/fqdn
- Save the out of df in human readable format to /home/student/dfinfo
- Save the output of du in human readable format of /etc with a depth of 1 to /home/student/etcinfo
- Save the current memory and swap usage to /home/student/memory
- Save the uptime in pretty format to /home/student/uptime
- Get a list of login times for the student user save to /home/student/student_logins
Solution
- Using redirection get the kernel release in file /home/student/kernelrelease
- Save the full hostname (fully qualified domain name) to /home/student/fqdn
- Save the out of df in human readable format to /home/student/dfinfo
- Save the output of du in human readable format of /etc with a depth of 1 to /home/student/etcinfo
- Save the current memory and swap usage to /home/student/memory
- Save the uptime in pertty format to /home/student/uptime
- Get a list of login times for the student user save to /home/student/student_logins