Using Sort

Learn On Demand
Learn On Demand Pro Series

The Using Sort virtual lab from IT PRO Challenges provides beginners hands-on experience with the Linux sort command and related options to customize the output. As learners become comfortable with sorting in the console, they improve their effectiveness in Cyber Operation and Exploitation Analyst roles.

Time
45 minutes
Difficulty
Beginner
Share
NEED TO TRAIN YOUR TEAM? LEARN MORE
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Overview

Learners gain hands-on experience, within 45 minutes, using the sort command and its options and build on UNIX/Linux fundamentals to become more comfortable using the command line. The Using Sort guided, virtual lab breaks down into four sections and further illustrates various ways to configure how ordered output displays.

  • Creating eleven files in a newly made subdirectory through the dd command
  • Sorting the newly created files by size.
  • Listing these files sequentially forward and backward.
  • Classifying output using one or more columns.

Many information technology roles require knowledge and use of command line and familiarity with displaying data in a Linux environment. By selecting the commands hyperlinked in the instructions, learners get further definitions, examples, and descriptions, in a Linux Ubuntu manual, useful for troubleshooting, and answering additional questions.

Create Files by Using the dd Command

This section reviews basic Linux commands, as learners create a directory, navigate to the new directory, make file having all sorts of sizes, and review the dd command, which converts and copies a file. Learners work with conditional statements and see the advantages of the tilde (~), a shortcut to putting in the entire home directory.

Sort files by Disk Space Used

This section teaches users the difference between displaying many output lines without and then with sorting. At first, learners use the du command to summarize usage and then pipes or sends the results through sort. The pipe ( | ) separates commands to be executed and uses the results before the pipe to inform what the command after the pipe does with this data. Learners grasp how sort works without any additional specifications. By default, “sort” arranges listings by ASCII, an American Standard defining characters on the keyboard. The command sorts by the first character. If two output values have the same first character, the second character breaks, determines the order, and so forth.

Sort in Reverse Numeric Order:

The Linux sort command can list results in order, forward, or backward. In this exercise, learners try the numeric (-n) and reverse order (-r) parameters. By arranging the eleven files created in the first section, either way, the learner sees output either ascending or descending, depending on the sort option used.

Sort by Columns:

This part of the virtual lab teaches learners how they can optimize sort output with -k. The -k tells Linux to use a key with the command. Think of the output like a table that has a column denoted by a key. Executing the du command displays two columns. By default, a sort command categorizes the first column. Specifying the second column means the file name lists alphabetically.

To list the file results by creation time, the learner includes the --time parameter, initially, and pipes the results into a sort command. The two dashes (--) tells the du (display usage) command to interpret the output a string, rather than as individual characters, making the sort more effective.

Summary:

Upon finishing this virtual lab, learners become familiar with sorting, understand using the sort command to display data more usefully. Learners complete several exercises.

  • Create a series of files to organize using the sort command.
  • View unsorted vs. default sorted outputs, that determines the order by ASCII characters.
  • Sort data from top to bottom and bottom to top.
  • Use specific column/s to customize sort output to give better information.

Users completing this challenge should consider additional virtual labs, as listed below.

  • GUIDED CHALLENGE: Search for Data by Using Grep
  • GUIDED CHALLENGE: Can You Use the Grep and Sort Commands Together?