Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Modifying the Bash Shell

A Linux system administrator should have a solid understanding of the Bash shell environment. The Bash shell is the default command line interface used on the vast majority of Linux distributions. Linux administrators can extend the capabilities of the Bash shell by providing their own aliases to commonly used commands and options, as well as create their own functions to use in the Bash environment. In this hands-on lab, we will create our own alias for a command and then create a new command that will take a positional argument.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Beginner
Last updated
Sep 22, 2025
Duration
1h 30m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Create the alias.

    The first step is to create an alias for the Bash shell that will allow you to view the service status of the web server itself. You will name this alias webstat. When you type the command webstat at the prompt, you will see the output of the command systemctl status httpd.service.

    User-created aliases and functions should go in your local ~/.bashrc file. Using the commands listed, append the following alias to your ~/.bashrc file:

    echo 'alias webstat="systemctl status httpd.service"' >> /home/cloud_user/.bashrc
    
  2. Challenge

    Load and test the alias.

    Now that we have created an alias that displays the status of the web server, we need to tell Bash that we want to use it in our current session. First, we need to source our .bashrc file using the “dot” (.) command:

    . ~/.bashrc
    

    Now that the Bash environment has been refreshed with the new alias from our ~/.bashrc file, we can use our new alias:

    webstat
    

    We should be able to see the output of our service's status command.

  3. Challenge

    Create your function.

    The next step is to create a function that will take the name of a directory as a parameter and print out how much disk space that directory is using.

    Using the vi text editor, open up the ~/.bashrc file and add the following function to the bottom, beneath the alias that you created earlier:

    function webspace()
    {
    	du -h /var/www/html/$1;
    }
    

    Save and close your file. Then source the .bashrc file again:

    . .bashrc
    
  4. Challenge

    Use the `webspace` function.

    Since the /var/www/html directory is the root location for all of the individual site locations for this web server, all you need to do is provide the name of the folder that contains a particular part of the site to the webspace function. To view the size and contents of the main public web page, enter this command:

    webspace main
    

    This will print out the contents of the /var/www/html/main directory and how much disk space this directory uses. The $1 used in your function is a positional argument. When you type webspace main at the prompt, the word main is replaced by the $1 argument, thus providing the output of the command for the /var/www/html/main directory.

    Try the same command again, this time for the customer directory on the web server:

    webspace customer
    

    You should see more directories in the output, plus a 5 MB client binary file.

About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight