RHCSA Series: Reviewing Essential Commands & System Documentation – Part 1

Other well-known shell built-ins include:

  1. echo command: Displays strings of text.
  2. pwd command: Prints the current working directory.
More Built in Shell Commands
More Built in Shell Commands
exec command

Runs an external program that we specify. Note that in most cases, this is better accomplished by just typing the name of the program we want to run, but the exec command has one special feature: rather than create a new process that runs alongside the shell, the new process replaces the shell, as can verified by subsequent.

# ps -ef | grep [original PID of the shell process]

When the new process terminates, the shell terminates with it. Run exec top and then hit the q key to quit top. You will notice that the shell session ends when you do, as shown in the following screencast:

export command

Exports variables to the environment of subsequently executed commands.

history Command

Displays the command history list with line numbers. A command in the history list can be repeated by typing the command number preceded by an exclamation sign. If we need to edit a command in history list before executing it, we can press Ctrl + r and start typing the first letters associated with the command. When we see the command completed automatically, we can edit it as per our current need:

This list of commands is kept in our home directory in a file called .bash_history. The history facility is a useful resource for reducing the amount of typing, especially when combined with command line editing. By default, bash stores the last 500 commands you have entered, but this limit can be extended by using the HISTSIZE environment variable:

Linux history Command
Linux history Command

But this change as performed above, will not be persistent on our next boot. In order to preserve the change in the HISTSIZE variable, we need to edit the .bashrc file by hand:

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)

Important: Keep in mind that these changes will not take effect until we restart our shell session.

alias command

With no arguments or with the -p option prints the list of aliases in the form alias name=value on standard output. When arguments are provided, an alias is defined for each name whose value is given.

With alias, we can make up our own commands or modify existing ones by including desired options. For example, suppose we want to alias ls to ls –color=auto so that the output will display regular files, directories, symlinks, and so on, in different colors:

# alias ls='ls --color=auto'
Linux alias Command
Linux alias Command

Note: That you can assign any name to your “new command” and enclose as many commands as desired between single quotes, but in that case you need to separate them by semicolons, as follows:

# alias myNewCommand='cd /usr/bin; ls; cd; clear'
exit command

The exit and logout commands both terminate the shell. The exit command terminates any shell, but the logout command terminates only login shells—that is, those that are launched automatically when you initiate a text-mode login.

If we are ever in doubt as to what a program does, we can refer to its man page, which can be invoked using the man command. In addition, there are also man pages for important files (inittab, fstab, hosts, to name a few), library functions, shells, devices, and other features.

  1. man uname (print system information, such as kernel name, processor, operating system type, architecture, and so on).
  2. man inittab (init daemon configuration).

Another important source of information is provided by the info command, which is used to read info documents. These documents often provide more information than the man page. It is invoked by using the info keyword followed by a command name, such as:

# info ls
# info cut

In addition, the /usr/share/doc directory contains several subdirectories where further documentation can be found. They either contain plain-text files or other friendly formats.

Make sure you make it a habit to use these three methods to look up information for commands. Pay special and careful attention to the syntax of each of them, which is explained in detail in the documentation.

Converting Tabs into Spaces with expand Command

Sometimes text files contain tabs but programs that need to process the files don’t cope well with tabs. Or maybe we just want to convert tabs into spaces. That’s where the expand tool (provided by the GNU coreutils package) comes in handy.

For example, given the file NumbersList.txt, let’s run expand against it, changing tabs to one space, and display on standard output.

# expand --tabs=1 NumbersList.txt
Linux expand Command
Linux expand Command

The unexpand command performs the reverse operation (converts spaces into tabs).

Display the first lines of a file with head and the last lines with tail

By default, the head command followed by a filename, will display the first 10 lines of the said file. This behavior can be changed using the -n option and specifying a certain number of lines.

# head -n3 /etc/passwd
# tail -n3 /etc/passwd
Linux head and tail Command
Linux head and tail Command

One of the most interesting features of tail is the possibility of displaying data (last lines) as the input file grows (tail -f my.log, where my.log is the file under observation). This is particularly useful when monitoring a log to which data is being continually added.

Read More: Manage Files Effectively using head and tail Commands

Gabriel Cánepa
Gabriel Cánepa is a GNU/Linux sysadmin and web developer from Villa Mercedes, San Luis, Argentina. He works for a worldwide leading consumer product company and takes great pleasure in using FOSS tools to increase productivity in all areas of his daily work.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.


Leave a Reply
  1. Today i attempted RHCSA exam. In that LDAP + AutoFS configuration done, but when i tried to login with ldapuser, it has given error message “Permission denied“. I tried all the way to rectified it but no luck.

    Second question was to create LV, PV, VG, but when i tried to create PV, it given error message “value of range. LV was 8*100 size“. Can you identify this issue?

    I am worrying about my result.

  2. i am getting below error plz help .
    [root@centos1 ldap]# ldapadd -H ldapi:/// -f /root/ldaprootpasswd.ldif SASL/SCRAM-SHA-1 authentication started
    Please enter your password:
    ldap_sasl_interactive_bind_s: Invalid credentials (49)
    additional info: SASL(-13): user not found: no secret in database

  3. I just passed the RHCA with flying colors thanks in part to your materials.
    Great work putting all this materiel up.
    Thank You.

  4. Gabriel Cánepa,

    Before of all, I want to thank you for the good work you are doing. One question is it possible you make all those topic already made to pdf?


      • YES!…..PDF’s my FAVORITE “travel document” format!…..Please hurry, I want them all for my tablet / laptop when I’m traveling!

  5. Gabriel,

    Thank you so very much for the excellent tutorial. I am assuming that you currently certified as RHCSA? I am currently preparing to go and present the text so these tutorials you have been created are excellent for practice and preparation. Gracias de nuevo!

    • @Jairusan,
      I appreciate your taking the time to comment on this post and for your kind words about my work. To answer your question – no, I am not certified as RHCSA. More of a logistics issue than anything else – I live ~450 miles from the nearest testing center. Hopefully in the future.

    • @Senthilkumar, you will see Part 2 live in 2-3 days from today. Stay tuned! And thanks for following Tecmint.com.

  6. Open the /etc/ssh/sshd.conf file and change the Port=22 entry to Port=
    Restart SSh to see your new SSh port.
    Make sure your firewalls are also updated for incoming requests to this new port.

    • @abdi,
      Part 2 has not been published yet. I am going to submit it today so you can expect to see it live in 2-3 days.


Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.