Examining Files Flashcards Preview

Networking > Examining Files > Flashcards

Flashcards in Examining Files Deck (30):
1

The "file" command displays a..?

file's type.

2

The "cat" command displays a...?

file's contents.

3

The "more" and "less" commands "page" through....?

a file, one screen at a time.

4

The "head" and "tail" commands display...?

the first or last few lines of a file.

5

In the X graphical environment, "nautilus" can be used to...?

examine text files.

6

The contents of any given file might be...?

ASCII (plain text, HTML, shell script, program source code, etc.) or binary (complied executable, compressed archive, audio, etc.).

7

It is a good idea to check the file type before using commands that work on ASCII because...?

Attempting to use them with binary files can lead to problems ranging from the mildly irritating (screens full of strange characters flashing by) to the more significant (locking the terminal display). This is because binary files can contain arbitrary binary codes, and some of these codes have special meaning when being (mis)interpreted as ASCII text.

8

file [OPTIONS][FILE....]...?

Tests FILE(s) to determine the file type, and displays results to standard output.

9

cat [OPTIONS] [FILE...]...?

Concatenate FILE(s) to standard output.

10

cat command switches...?

Switch Effect
-A Show all characters, including control characters and non-printing characters
-s " Squeeze" multiple adjacent blank lines into a single blank line
-n Number lines of output

11

the cat command, when used for viewing files, simply displays...?

the contents all at once (Large files scroll by to quickly to read, making cat most suitable for files with less than a screen of text.)

12

Both more and less are designed for viewing text files on screen. Their use is quite similar except that...?

the modern less command has a few extra features, such as responding correctly to [PgUp], [PgDn] and navigation arrow keystrokes correctly. After all, less is more. (It is especially important to be familiar with less because other tools (such as man) use it behind the scenes to provide paging capabilities.)

13

more [OPTIONS] [FILE...] ...?

Displays FILE(s) to standard output one screen full at a time under keyboard control.

14

"more" command switches...?

Option Action
-c Clear screen and redraw, instead of scrolling
-s "Squeeze" multiple adjacent blank lines into a single blank line

15

less [OPTIONS] [FILE...] ...?

Displays FILE(s) to standard output one screen full at a time under keyboard control.

16

"less" command switches...?

Option Action
-c Clear screen and redraw, instead of scrolling
-r Display raw control characters
-s "Squeeze" multiple adjacent blank lines into a single blank line

17

less (more) navigation commands...?

Command more? Action
Yes move ahead one full screen
[PgDn] No move ahead one full screen
b Yes move back one full screen
[PgUp] No move back one full screen
[DnArrow] No move ahead one line
[UpArrow] No move back one line
/text Yes search forward for text
?text No search backward for text
n Yes repeat last search
N No repeat last search, but in opposite direction
q Yes quit
h Yes help (which introduces many new commands)

18

One feature of the less pager relies on...?

a standard Unix concept called pipes.

19

Pipes act like redirection, in that the output of a command is redirected...?

somewhere other than a terminal. With redirection (using >), the output gets redirected to a specified file. When piping, the output of one command gets redirected into the input of another command. The bash shell uses the | character (usually found above the RETURN key) on construct pipes.

20

When running a command that produces a lot of output, the output of the command can be piped into...?

less. (Rather than getting dumped into a terminal, the output can be browsed like a file, paging down, paging up, and searching. When finished, quit less, and the output disappears.)

21

The _____ command allows you to see the first few lines of the file.

Head.

22

head [OPTIONS] [FILE...] ...?

Print the first 10 lines of each FILE to standard output.

23

"head" command switches...?

Switch Effect
-num, -n num Print first num lines (default is 10).
-q Suppress headers giving file names

24

If given more than one filename as arguments, head displays...?

the first few lines of each file individually, separated by a header displaying the filename.

25

tail [OPTIONS] [FILE...] ...?

Complementing head, the tail command prints the last 10 lines of each FILE to standard output.

26

"tail" command switches.

Switch Effect
-num, -n num Print last num lines (default is 10).
-q Suppress headers giving file names
-f Keep file open, and print new lines as appended

27

The tail command has another, very useful, option: the -f (follow) option. With this option, tail will display...?

the last lines of the file, and then "waits" and continues to display any new lines as they are added to the file. This is often used to monitor system log files in real time. Once started with the option, the command prompt does not return. Instead the tail -f stays active and will continue to display new lines as they occur until CTRL+C is pressed.

28

What type of file is /usr/bin/run-parts?

A Bash (Bourne-Again) shell script

29

What type of file is /dev/log?

A socket.

30

What command woudl act the same as cp a.txt b.txt assuming the file b.txt does not exist?

cat a.txt > b.txt