3Basic Commands and Simple Shell ScriptsOnce 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 IO 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 environmentsLoginis the process during which a user identifies themselves in the system – usually, by providing ab usernameband
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 login 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. Aline requesting the password will appear:
Figure 3.2 – The login
process and password requestWe 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 into the system with the credentials fora 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 login. The default terminal can be reached by simultaneously pressing the
Ctrl + Alt + F 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 + F, to the third one by pressing Ctrl + Alt + F, and soon for the rest of the terminals (by default, six are allocated. This way, we can run different commands indifferent terminals.