Linux Notes -2 :Three Essential Linux Commands for System Administration: su, hostname -I, and lsblk
In Linux system administration, mastering key commands allows you to work efficiently and make informed decisions. The commands su, hostname -I, and lsblk serve different but complementary purposes, covering user management, network identification, and storage inspection.
1. The su Command su stands for “substitute user” or “switch user.” It enables you to operate as another user within the current shell session. This is most often used to switch to the root account for administrative tasks.
su -c "ls /var/log"
2. The hostname -I Command hostname -I displays all IP addresses currently assigned to the system, separated by spaces. This includes wired, wireless, and virtual interfaces, as well as both IPv4 and IPv6 addresses if present.
Example:
$ hostname -I
192.168.1.42
This information is helpful for remote access, network troubleshooting, and automation scripts. To show only the primary IP address:
hostname -I | awk '{print $1}'
3. The lsblk Command lsblk lists information about all available or specified block devices, such as hard drives, solid-state drives, and removable storage. It does not display information about partitions that are not block devices (such as RAM disks).
Example:
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 512G 0 disk
├─sda1 8:1 0 500G 0 part /
├─sda2 8:2 0 10G 0 part /home
This output shows the device names, sizes, types, and mount points. It is invaluable for verifying storage layouts, checking available space, and ensuring devices are correctly mounted.
Conclusion su provides controlled user switching, hostname -I reveals the system’s network addresses, and lsblk offers clear insight into storage devices. Together, they form part of the essential toolkit for any Linux system administrator.
#Linux #SystemAdministration #Networking #Storage #RHEL9 #LinuxCommands