File Name Generators
Learn On Demand
Learn On Demand Pro Series

Time
45 minutes
Difficulty
Beginner

In this IT Pro Challenge virtual lab, the learner will use basic Linux administrator skills to list files by certain criteria using wildcards. Learners will use the ls (list) command along with wildcards, such as * (star or splat),? (question mark),! (exclamation), and (brackets). These are essential skills for Linux and Security Administrators.

Start your free 7-day trial and become one of the 3 million Cybersecurity and IT professionals advancing their career goals

Sign up with
Or

Already have an account? Sign In »

Overview

Lab Overview:

This challenge is ideal for learners that need a basic introduction to Linux Administration. You will learn how to use the ls command to list out file names in a directory, along with using wildcards that will limit your output to only files that match specific criteria.

Understand the scenario

You are a Linux administrator, and you need to search your file system for file names that match specific criteria. To set the stage, you will use the mkdir and touch commands to set up your directory and file structure. Then you will search the directory, using the ls command and wildcards to find the files that meet specific criteria. For example, you’ll look for files that have a particular character in their file name, files that have a specific number of characters in their file name, and files that have a defined combination of characters in their filename.

Create files and directories

To set the stage for this lab, you will use the mkdir and touch commands to create a working directory and file structure. The mkdir command allows you to create a directory with a specified name. Touch is a standard Linux command that is used to modify file timestamps. If you ‘touch’ a file that doesn’t exist, then it creates an empty file with the name you specified. You will then use the cd (change directory) command to navigate inside the newly created directory, where you will create some sample files. Using the touch command, you will create empty files with specific file names. Finally, you will use the ls command to list and verify that the files exist.

Search for files by using the * wildcard

After creating your workspace, you will then gain experience using the asterisk, * (called star or splat), wildcard. The * wildcard allows you to specify any or no characters as a requirement. For example, the ls command with a * by itself means you want to list all file names, regardless of their name. You will learn different ways to use the * wildcard.

Search for a specific number of characters by using the ? wildcard

This section teaches you how to use the question mark as a wildcard. The ? wildcard represents any character and specifies the number of characters that you want to find. Each question mark represents one character. So, if you are interested in file names that have only three characters, you would use three question marks, like this ???, with your list command. You will learn different ways to use the ? wildcard.

Search for a range of values by using the [ ] and ! wildcards

Here, you will learn how to use brackets and the exclamation point as wildcards. The brackets allow you to include a range of letters or numbers to specify as search criteria. The exclamation point specifies negation, or literally “not” when used as a wildcard with the list command. You will learn different ways of using brackets and combining your wildcards for very specific file names.

Lab Summary

This hands-on challenge teaches you the basic Linux administrator tasks of creating directories, creating files, listing out file structures, and searching for specific file name criteria within your directory. The Linux commands that you will gain experience with are:

  • mkdir, cd, touch, ls
  • wildcards: *, ?, !, and [ ]

Other Challenges in this series

  • GUIDED CHALLENGE: Configure the Display of a File
  • ADVANCED CHALLENGE: Can You Create Files from Parts of Other Files?