Redhat Linux 9: truy cập môi trường multui-user, tìm hiểu command prompt



Redhat Linux 9: truy cập môi trường multui-user, tìm hiểu command prompt

Redhat Linux 9:  truy cập môi trường multui-user, tìm hiểu command prompt

Link playlist
Red Hat Enterprise Linux Administration
https://www.youtube.com/playlist?list=PLIpLw6v7Z1qnIUiJipjgYEHwxF16TZbCN
2023 09 23 06 35 49
3
Basic Commands and Simple
Shell Scripts
Once you have your first Red Hat Enterprise Linux (RHEL) system running, you want to start using
it, practicing, and getting comfortable with it. In this chapter, we will review the basics of logging
into the system, navigating through it, and getting to know the basics in terms of its administration.
The set of commands and practices described in this chapter will be used on many occasions when
managing systems, so it is important to study them with care.
The following topics will be covered in this chapter:
• Logging in as a user and managing multi-user environments
• Changing users with the su command
• Understanding users, groups, and basic permissions
• Using the command line, environment variables, and navigating through the filesystem
• Understanding I/O redirection on the command line
• Filtering output with grep and sed
• Listing, creating, copying, and moving files, directories, links, and hard links
• Using tar and gzip
• Creating basic shell scripts
• Using system documentation resources
Basic Commands and Simple Shell Scripts 60
Logging in as a user and managing multi-user
environments
Login is the process during which a user identifies themselves in the system – usually, by providing a
username and password, a couple of pieces of information often referred to as credentials.
The system can be accessed in many ways. The initial case for this, which we are covering here, is
how a user accesses it when they install a physical machine (such as a laptop) or via the virtualization
software interface. In this case, we are accessing the system through a console.
During installation, the user was created with an assigned password, and no graphical interface was
installed. We will access the system in this case via its text console. The first thing we are going to
do is to log in to the system using it. Once we start the machine and the boot process is completed,
we will enter, by default, the multi-user text mode environment in which we are being requested to
provide our login:
Figure 3.1 – The login process and username request
The blinking cursor will let us know that we are ready to enter our username, in this case, user, and
then press Enter. A line requesting the password will appear:
Figure 3.2 – The login process and password request
We may now type the user’s password to complete the login and, by pressing Enter on your keyboard,
start a session. Note that no characters will be displayed on the screen when typing the password to
avoid eavesdropping. The following screenshot shows the session running:
Logging in as a user and managing multi-user environments 61
Figure 3.3 – The completed login process and the session running
Now, we are fully logged in to the system with the credentials for a user called user. This will define
what we can do in the system, which files we can access, and even how much disk space we are assigned.
The console can have more than one session. To make that possible, we have different terminals
through which we can log in. The default terminal can be reached by simultaneously pressing the
Ctrl + Alt + F1 keys. In our case, nothing will happen, as we are already in that terminal. We could
move to the second terminal by pressing Ctrl + Alt + F2, to the third one by pressing Ctrl + Alt + F3,
and so on for the rest of the terminals (by default, six are allocated). This way, we can run different
commands in different terminals.
Using the root account
Regular users will not be able to make changes to the system, such as creating new users or adding
new software to the whole system. To do so, we need a user with administrative privileges and for
that, the default user is root. This user always exists in the system and its identifier – the User Id
(UID) – has the value 0.
In the previous installation, we configured the root password, making the account accessible through
the console. To use it by logging in to the system, we only need to type the user root into one of the
terminals shown right next to the login, then hit Enter, and then provide its password, which won’t
be displayed. This way, we will access the system as the administrator, root:
Figure 3.4 – The completed login process for root
Basic Commands and Simple Shell Scripts 62
Important Note
Above the login prompt, there is a message suggesting how the activation of the web console
(cockpit) can be done – the cockpit is a set of tools that enables web management for the system.
The cockpit is covered in Chapter 4, Tools for Regular Operations.
Using and understanding the command prompt
The command line that appears once we have logged in and are waiting for our commands to be typed
and run is called the command prompt.
In its default configuration, it will show the username and hostname