3 Basic Commands and Simple Shell Scripts Once you have your first Red Hat Enterprise Linux rhel


[root@rhel-instance ]# ls -l -d /etc



Download 1.85 Mb.
View original pdf
Page8/67
Date26.02.2024
Size1.85 Mb.
#63678
1   ...   4   5   6   7   8   9   10   11   ...   67
Pablo Iranzo Gómez, Pedro Ibáñez Requena, Miguel Pérez Colino, Scott McCarty - Red Hat Enterprise Linux 9 Administration-Packt Publishing (2022) -chap 3 82 - 180
[root@rhel-instance
]# ls -l -d /etc

drwxr-xr-x. 103 root root 8192 Feb 18 18:03 /etc
As you can see, it’s quite easy to obtain information about files and directories in the system. Let’s now learn more about the command line and how to navigate the filesystem easily in the following section.
Using the command line, environment variables, and
navigating through the filesystem
As we have seen before, once we login to the system, we have access to the command line. It’s important to navigate the command line and the filesystem well to feel comfortable in the environment and make the most of it.
Command line and environment variables
The command line is provided by a program also known as an interpreter orb shellb. It will behave differently depending on which shell we use, but in this section, we will cover the most widespread shell used in Linux and the one provided by default in RHEL – bash.
A simple trick to know which shell you are using is to run the following command:
[root@rhel-instance
]# echo $SHELL

/bin/bash
The echo command will show the content of whatever we give to it on the screen. Some content needs to be substituted or interpreted, such as environment variables. The content to be substituted starts with the $ symbol. In this case, we are telling the system to use the echo function on (and therefore, echo) the content of the SHELL variable. Let’s use it for other variables:
[root@rhel-instance
]# echo $USER

root

Basic Commands and Simple Shell Scripts
70
[root@rhel-instance
]# echo $HOME

/root
These are environment variables that can be customized for every user. Let’s now check these fora different user:
[root@rhel-instance
]# su - user

Last login Wed Feb 16 19:03:32 CET 2022 from 192.168.122.1 on
pts/0

Download 1.85 Mb.

Share with your friends:
1   ...   4   5   6   7   8   9   10   11   ...   67




The database is protected by copyright ©ininet.org 2024
send message

    Main page