Linux: The Power of the Command Line - dummies

By Emmett Dulaney

The Linux Essentials exam covers the topic of the Command line. This table shows the subtopics, weight, description, and key knowledge areas for this topic.

Breakout of Topic
Subtopic Weight Description Key Areas
Archiving Files on the Command Line 2 Archiving files in the user home directory Files, directories; archives, compression
Searching and Extracting Data from Files 4 Search and extract data from files in the home directory Command line pipes; I/O re-direction
Turning Commands into a Script 4 Turning repetitive commands into simple scripts Basic text editing; basic shell scripting

To adequately address these topics, focus on the following files, terms, and utilities: /bin/sh; arguments; bash; bzip2; case; common tar options; cut; exit status; extracting individual files from archives; find; for loops; grep; gzip; head; if; less; nano; Partial POSIX Basic Regular Expressions ([^],^,$); Partial POSIX Extended Regular Expressions (+,(),|); pico; read; sort; tail; tar; test; unzip; variables; vi; wc; while; xargs; and zip.

Here are the top ten items to know as you study for this domain:

  1. Standard input (stdin) is traditionally the keyboard and standard output (stdout) is traditionally the monitor. Both can be redirected, as can standard error (stderr) using the symbols >, >>, <, and |.

  2. Commands can be joined on the command line by the semicolon (;) and each command will run independent of each other. You can also use the pipe (|) to send the output of one command as the input of another command.

  3. The cut command can pull fields from a file and they can be combined using either paste or join. The latter offers more features than the former and can be used with conditions.

  4. The wc command can count the number of lines, words, and characters in a file.

  5. The grep utility (and its counterparts egrep and fgrep) can be used to find matches for strings within files.

  6. The find command can be used to search the system for files/directories that meet any number of criteria. When these entities are found, the xargs command can be used to look deeper within them for other values (such as in conjunction with grep).

  7. You can use the tar command (which can combine multiple files into a single archive) to do backups.

  8. In addition to archiving, you can also compress files with the gzip or pack commands. To uncompress files, use uncompress, gunzip, or unpack.

  9. Variables can be given at the command line and referenced as $1, $2, and so on, or entered into the executing file with the read command.

  10. Logic can be added to scripts by testing conditions with test or [. Commands can execute using if-then-fi deviations or through looping (while, until, or for). You can use the exit command to leave a script or use break to leave a loop.