Book Image

Essential Linux Commands

By : Paul Olushile
Book Image

Essential Linux Commands

By: Paul Olushile

Overview of this book

The role of a system administrator is ever-evolving, with the Linux command line at its core. This makes Linux command-line mastery an essential skill to demonstrate your ability to efficiently manage and maintain systems efficiently. Essential Linux Commands addresses a diverse range of topics, including package management, file manipulation, networking strategies, system monitoring, and diagnostic tools. Each command is intricately explained to eliminate any ambiguity, ensuring ease of implementation in real-world scenarios. This book explains how to use SELinux to maintain security, run Linux machines on AWS Cloud, and transfer and download files to remote systems. With the help of practical examples and use cases, you’ll not only gain a thorough understanding of a command’s syntax but also grasp its functional breadth and limitations. The book also explores commands frequently used by system administrators to check network card statistics and firewall rules. Whether you’re a beginner or an experienced administrator, this book is an invaluable resource, filling in the gaps in your skill set and helping you improve your skills and expertise in Linux administration.
Table of Contents (20 chapters)
1
Part 1:Server Installations and Management Commands
5
Part 2:Frequently Used Commands – Part 1
9
Part 3:Frequently Used Commands – Part 2
15
Part 4:Linux Security and the Cloud

Information commands

CentOS provides system administrators with a range of commands for obtaining information about various aspects of the system, including hardware, software, networks, and users. These commands are essential tools for monitoring and troubleshooting the system and its components, providing insight into the current status, configuration, and performance of the system. With the ability to obtain accurate and up-to-date information about the system, system administrators can quickly identify and resolve issues, ensuring optimal performance and the stability of the system. These commands provide information about the system’s hostname, disk usage, processes, CPU, and network interfaces, respectively, making them valuable tools for system administrators who need to diagnose and resolve system issues.

Here are a few commonly used information commands in CentOS:

  • uname: The uname command is used to display information about the operating system and the system’s hostname. This command can also display the type of hardware, the version of the operating system, and the release number of the kernel.
Figure 1.38 – Displaying the operating system

Figure 1.38 – Displaying the operating system

The uname command comes with different flags that can be executed; for example, the -a parameter displays the whole information, including the system name, network node hostname, kernel release, version, and machine hardware name, as we can see in the following terminal:

Figure 1.39 – Displaying all system information

Figure 1.39 – Displaying all system information

  • lsb_release: The lsb_release command is used to display information about the Linux Standard Base (LSB) version, distributor ID, and release number. The LSB is a standard that defines the Linux operating system and ensures compatibility among different Linux distributions.
Figure 1.40 – Displaying the Linux Standard Base version

Figure 1.40 – Displaying the Linux Standard Base version

To execute additional flags, we’ll make use of a flag commonly used by administrators to display the distributor indicator.

Figure 1.41 – Displaying Distributor Indicator

Figure 1.41 – Displaying Distributor Indicator

  • hostnamectl: The hostnamectl command is used to display and modify the system hostname and to view various system settings such as the operating system architecture, boot mode, and system time zone. This command is useful for changing the hostname or viewing system settings without having to log in to the system as a root user.
Figure 1.42 – Displaying the system settings and architecture

Figure 1.42 – Displaying the system settings and architecture

Let us execute hostnamectl with another flag, set-hostname. This flag is used to set the system hostname to a specified value. For example, you might execute hostnamectl set-hostname myhost:

Figure 1.43 – Setting a system hostname

Figure 1.43 – Setting a system hostname

The preceding useful information commands that we covered in this section will help you gather information about your system. Throughout this chapter, we emphasized the importance of proper server setup and installations, including regular software upgrades and updates, to ensure that your system runs smoothly and remains secure. By following the steps outlined in this chapter, you will be well on your way to setting up a reliable and secure server for your personal use, as well as building a foundation to further learn about Linux system administration.