RHEL7: How to increase your typing speed.

Share this link

Why Typing Speed

When taking any hands-on exam, your typing speed can make a difference.
So, you need to know some tips to go quicker.
Here, the purpose is not to give a comprehensive list but to list all the main tips.

Bash Completion

Before anything else, check that bash completion is enabled (it’s not the case with the minimal install):

# yum install bash-­completion

From now on, the tab key will provide you some relevant options.

The mkdir Command

Creating nested directories can take some time.

  •  The normal way to create the /projects/myproject/data tree would be:
    # mkdir /projects
    # cd /projects
    # mkdir myproject
    # cd myproject
    # mkdir data
  • Going much quicker is possible:
    # mkdir -p /projects/myproject/data

Creating a directory and setting its permissions normally takes two steps.

  • Creation of the directory and permission assignment:
    # mkdir /projects
    # chmod 770 /projects
  • Both steps can be combined into only one (Note: only numbers accepted):
    # mkdir -m 770 /projects

The systemctl Command

Writing the complete name of a service is not necessary:

  • Normally you should write:
    # systemctl start ntpd.service
  • However it is much quicker to only type:
    # systemctl start ntpd

Starting and activating services at boot take two lines:

  • Start the service and activate it at boot:
    # systemctl start ntpd
    # systemctl enable ntpd
  • Both lines can be combined into only one (Note: the second command is only executed if the first one didn’t return an error):
    # systemctl start ntpd && systemctl enable ntpd

    With the RHEL 7.2 release, you can now enable and start (in this order) one or several services with only one command (this works with the disable and mask options too):

    # systemctl enable --now ntpd httpd

When you need to start several services at the same time, it’s painful:

  • Start the two services:
    # systemctl start ntpd
    # systemctl start httpd
  • Both lines can be combined into only one:
    # systemctl start ntpd httpd

Shell File Management

When you need to execute the same operation on several files, the shell provides an interesting feature:

  • Create three empty files:
    # touch /opt/file1 /opt/file2 /opt/file3
  • This operation can be simplified:
    # touch /opt/{file1,file2,file3}

This is especially useful when dealing with Firewalld.
Let’s assume that you need to add 3 different services to your firewall at the same time: http, https, and dns:

  • You can run four different commands with 3 almost identical ones:
    # firewall-cmd --permanent --add-service=http
    # firewall-cmd --permanent --add-service=https
    # firewall-cmd --permanent --add-service=dns
    # firewall-cmd --reload
  • Or you can run only two commands:
    # firewall-cmd --permanent --add-service={http,https,dns}
    # firewall-cmd --reload

The Shell History

With the arrow keys up and down you can navigate in the shell history. But with the ! character you can search for a pattern in the shell history to execute a previously typed command. This can save you some typing.

The virsh Command

If you need to start a KVM guest and then connect to it through the console, you’ve got two commands to type:

# virsh start vm.example.com
# virsh console vm.example.com

These two steps can be combined into only one:

# virsh start vm.example.com --console

Note: Furthermore, you will not miss any messages displayed on the console like in the two-step solution!

The passwd Command

Szymon Niedziela in the Linkedin’s Red Hat Linux Professional Users group provides a nice tip about the passwd command.
Instead of typing twice your root password with the risk of typo, type:

# echo mypass|passwd --stdin root

Note1: You can’t remove the root argument in this case.
Note2: It’s quick and clean at the exam but not very clever after the exam: your password will be stored in the command history list.

Bash Aliases

If you plan to type several times the same complicated command, you can decide to create an alias.
For example, edit the /root/.bashrc file and paste the following line into it:

alias APACHE-RESTART="systemctl restart httpd"

Then, make the alias active (or exit and reconnect):

# source /root/.bashrc

Now, you only need to type A (uppercase) and Tab to restart your Apache server.

Note1: Use uppercase characters in your alias to make the call to your alias easy.
Note2: Use or but not `, otherwise the command in the alias will be executed each time at the connection.

Thanks to Ernesto for this tip.

Additional Resources

You can also read this interesting Redpill Linpro article about job control and other useful tips.

Don’t hesitate to provide some other useful tips through your comments.

1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 4.75 out of 5)

Leave a Reply

6 Comments on "RHEL7: How to increase your typing speed."

Notify of

Sort by:   newest | oldest
1 year 15 days ago

Excellent topic, It will definitely help me during exam!

6 months 10 days ago

Hi CertDepot, excellent job. Thanks for this website….
I generally use an alias to save time when it is needed to restart a service more than 3 times. For instance, Apache service probably must restart 4 or 5 times, so with: alias APACHE-RESTART=”systemctl restart httpd”, you can save time just typing A (uppercase) and TAB.

6 months 7 days ago

Hi CertDepot. Thanks again for all your support. About “Bash Aliases” In the example above, I think that in the /root/.bashrc file lacks the command “alias”. Am I in the right?


RHCSA7: Task of the day

Allowed time: 5 minutes.
Configure a cron task to write the uptime at 2PM every day.

RHCE7: Task of the day

Allowed time: 8 minutes.
Set up an iScsi target based on a block backstore of 100MB called lv_iscsi with basic authentication, ext4 filesystem and standard firewall configuration.

Poll for favorite RHEL 7 book

What is your favorite RHEL 7 book to prepare RHCSA & RHCE exams?

View Results

Loading ... Loading ...

Poll for most difficult RHCSA 7 topic

What do you think is the most difficult RHCSA 7 topic?

View Results

Loading ... Loading ...

Poll for most difficult RHCE 7 topic

What do you think is the most difficult RHCE 7 topic?

View Results

Loading ... Loading ...