loader

This post will introduce some of the basic standard Linux commands. Knowing these commands is crucial for understanding the following concepts. These basic commands are usually the same in all Linux distributions; therefore, their results are the same. We used CentOS Stream release 9. For more information about choosing distros, we suggest reading this post: LPIC1-002-What is a Linux Distribution (distro)?

Command Prompt

We explained about shells and terminals. After accessing a shell through a terminal, the command prompt is ready to get commands and execute them. First of all, the command prompt contains some helpful information, as shown in the image below.

User Name: Is the username that the user logged in with
HostName: Is the meaningful name that administrators define to Address the server
CWD or Current Working Directory: The Path to the directory that the user is currently working on it. Every user logs in to its home directory.
User Type: There are three types of users in the Linux world.

Linux User Types:

root Superuser: In the command prompt, “#” shows that the user currently logged in or working is the root user. Root superuser has the highest privileges. Administrators create the root superuser during Linux installation. Every Linux system can only have one root superuser.

Standard or Regular user: “$” in the command prompt represents the regular user. These users have moderate privileges; therefore, they only can do tasks and have access to files that administrators allow them. Administrators can create several regular users after the installation process.

Service users: when administrators install a package, the installation process creates a specific service user for the service or application. Service users can not do routine tasks. They are only able to execute their service functions.

As the code below shows, we logged in as user “sara.” Another symbol in the command prompt in the code below is the tilde “~.” Tilda means the user is currently in its home directory, which is /home/sara in this example.

				
					login as: sara
sara@Lpic1-Centos9's password:
Last login: Thu Apr 28 04:58:31 2022 from 
[sara@Lpic1-CentOs9 ~]$

				
				
					login as: root
root@Lpic1-Centos9's password:
Last login: Thu Apr 28 05:10:03 2022 from 
[root@Lpic1-CentOs9 ~]#
				

Note I: Everything in a Linux system is a type of file. So files and directories can have the same names. We will explain this in another post.
Note II: Linux is case sensitive; therefore, consider this in the paths and the name of files and directories.

How to execute a command?

To run a program in a Linux shell, type its command in the command prompt in a proper syntax and press enter. The basic command’s syntax is as follows:
Command [options]….[Inputs]
Options or switches are features that help to get better results.
The Brackets indicate that switches are optional to use. Let’s begin to introduce Linux commands.

uname command

uname command helps to get information about the system kernel. uname command, without any switches, displays the kernel’s name. With “-r” command option displays the current kernel version. To display all the information of this utility, use the “-a” command option.

				
					[root@Lpic1-CentOs9 ~]# uname
Linux
[root@Lpic1-CentOs9 ~]# uname -r
5.14.0-78.el9.x86_64
[root@Lpic1-CentOs9 ~]# uname -a
Linux Lpic1-CentOs9 5.14.0-78.el9.x86_64 #1 SMP PREEMPT Mon Apr 11 11:29:35 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

				

Cal Command

To view the calendar quickly, use the “cal” command. By default, it displays only the current month calendar. the cal command syntax is :
cal [month][year]
for example : 

“cal” on its shows the current month calendar.
cal 08 2022” displays April 2022 calendar. Linux also displays previous years’ calendars. try “cal 08 2013“.
cal -3” displays a three-month calendar spanning the current date. Therefore it shows the previous, present, and next month’s calendar.
cal -Y” displays the current year calendar. All twelve months together.

				
					[root@Lpic1-CentOs9 ~]# cal
     April 2022
Su Mo Tu We Th Fr Sa
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
##########################################
[root@Lpic1-CentOs9 ~]# cal 08 2022
     August 2022
Su Mo Tu We Th Fr Sa
    1  2  3  4  5  6
 7  8  9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
##########################################
[root@Lpic1-CentOs9 ~]# cal 08 2013
     August 2013
Su Mo Tu We Th Fr Sa
             1  2  3
 4  5  6  7  8  9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
##########################################
[root@Lpic1-CentOs9 ~]# cal -3
     March 2022            April 2022             May 2022
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
       1  2  3  4  5                  1  2   1  2  3  4  5  6  7
 6  7  8  9 10 11 12   3  4  5  6  7  8  9   8  9 10 11 12 13 14
13 14 15 16 17 18 19  10 11 12 13 14 15 16  15 16 17 18 19 20 21
20 21 22 23 24 25 26  17 18 19 20 21 22 23  22 23 24 25 26 27 28
27 28 29 30 31        24 25 26 27 28 29 30  29 30 31
##########################################
[root@Lpic1-CentOs9 ~]# cal -Y
     April 2022              May 2022               June 2022
Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa
                1  2    1  2  3  4  5  6  7             1  2  3  4
 3  4  5  6  7  8  9    8  9 10 11 12 13 14    5  6  7  8  9 10 11
10 11 12 13 14 15 16   15 16 17 18 19 20 21   12 13 14 15 16 17 18
17 18 19 20 21 22 23   22 23 24 25 26 27 28   19 20 21 22 23 24 25
24 25 26 27 28 29 30   29 30 31               26 27 28 29 30
      July 2022             August 2022          September 2022
Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa
                1  2       1  2  3  4  5  6                1  2  3
 3  4  5  6  7  8  9    7  8  9 10 11 12 13    4  5  6  7  8  9 10
10 11 12 13 14 15 16   14 15 16 17 18 19 20   11 12 13 14 15 16 17
17 18 19 20 21 22 23   21 22 23 24 25 26 27   18 19 20 21 22 23 24
24 25 26 27 28 29 30   28 29 30 31            25 26 27 28 29 30
31
    October 2022           November 2022          December 2022
Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa
                   1          1  2  3  4  5                1  2  3
 2  3  4  5  6  7  8    6  7  8  9 10 11 12    4  5  6  7  8  9 10
 9 10 11 12 13 14 15   13 14 15 16 17 18 19   11 12 13 14 15 16 17
16 17 18 19 20 21 22   20 21 22 23 24 25 26   18 19 20 21 22 23 24
23 24 25 26 27 28 29   27 28 29 30            25 26 27 28 29 30 31
30 31
    January 2023           February 2023           March 2023
Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa
 1  2  3  4  5  6  7             1  2  3  4             1  2  3  4
 8  9 10 11 12 13 14    5  6  7  8  9 10 11    5  6  7  8  9 10 11
15 16 17 18 19 20 21   12 13 14 15 16 17 18   12 13 14 15 16 17 18
22 23 24 25 26 27 28   19 20 21 22 23 24 25   19 20 21 22 23 24 25
29 30 31               26 27 28               26 27 28 29 30 31
[root@Lpic1-CentOs9 ~]# 

				

In the next post, we will follow Linux commands.

Leave a Reply

Your email address will not be published. Required fields are marked *