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

Creating and Modifying a File with Vim

Knowing how to modify files at the command line is an essential skill for any Linux administrator. This learning activity will focus on using the Vim text editor to practice creating a new file, adding text to the file, and then modifying that text. We will also practice some of the basic keyboard shortcuts to change the text of this file.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Beginner
Last updated
Aug 29, 2025
Duration
30m

Contact sales

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

    Create a new file

    Using the vim text editor, create a new file called notes.txt in the cloud_user home directory. Enter the text "Beginning of Notes File" at the top of the document. Leave two blank lines under this top line. Save and close the file.

    The process is:

    vi notes.txt
    i (insert)
      Text - Beginning of Notes File
    (2 blank lines)
    :wq!
    
  2. Challenge

    Send Data to the notes.txt file

    Using the cat command and output redirection, send the contents of the /etc/redhat-release file to the end of the notes.txt file, taking care to append the contents so as to not overwrite the file.

    This can be accomplished via:

     cat /etc/redhat-release >> notes.txt
    
  3. Challenge

    Modify the notes.txt File

    Open the notes.txt file for editing again. Place the cursor before the openening parentheses around the word "Core." Using a keyboard shortcut, delete the text from the cursor position to the end of the line. Leave two blank lines under this line. Save and close the file.

    The following process will meet the criteria:

    vim notes.txt
    (cursor to 'core')
    SHIFT D (or d$) remove cursor to end of line
    o - blank line
    enter (2nd line)
    :wq!
    
  4. Challenge

    Send More Data to the File, and Modify Its Contents

    Using the free -m command and output redirection, send the output of the command to the end of the notes.txt file, taking care to append the contents so as to not overwrite the file.

    Open notes.txt for editing. Move the cursor to the line that begins with "Swap." Using a keyboard shortcut, delete this entire line. Leave two blank lines after the line that begins with "Mem".

    Follow this process:

    free -m >> notes.txt
    
    vim notes.txt
    move cursor to Swap line
    dd (delete line)
    o - blank line
    enter (2nd)
    SHIFT: 3 (3rd line of file)
    i - insert
    enter (blank line)
    :wq!
    
  5. Challenge

    Enter New Text into the File

    Using a keyboard shortcut, jump to line 3 of the file, then enter the text: "This is a practice system." Leave a blank line after this text has been entered. Save and close the file.

    You can accomplish this via:

     vim notes.txt
     SHIFT: 3 (moves to 3rd line)
     i (insert)
     This is a practice system
     (enter for blank line)
     :wq!
    
  6. Challenge

    Finalize the Notes File

    Using the dbus-uuidgen --get command, send the output of this command (which will retrieve the system's dbus unique ID) to the end of the notes.txt file. Take care to append the contents so as to not overwrite the file. Open notes.txt in vim, and use a keyboard shortcut to jump to the end of the file. At the beginning of the line that contains the dbus ID, enter in the following text: "Dbus ID = " so that there is a space between the equal sign and the Dbus ID number. Save and close the file. Hand the system over for grading.

    dbus-uuidgen --get >> notes.txt
    
    vim notes.txt
    SHIFT G (end of file)
    i - insert
    Dbus ID = (before ID)
    :wq!
    
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