Command Line Tools Flashcards
The echo command is an internal command in bash (true or False)
True
You type “echo $PROC” and the computer replies “go away”. What does this mean?
The $PROC environment variable is set “Go away”.
What does the pwd command accomplish?
It prints the name of the working directory
In an xterm window launched from your window manager, you type exec gedit. What will happen when you exit from the gedit program?
The xterm window will close.
What is the surest way to run a program (say, myprog) that’s located in the current working directory?
Type ./ followed by the program name: ./myprog
How does man display information by default on most Linux?
Using the less pager
You want to store the standard output of the ifconfig command in a text file (file.txt) for future reference, and you want to wipe out any existing data in the file. You do not want to store standard error in this file. How can you accomplish these goals?
Type: ifconfig > file.txt
What is the effect of the following command?
$ myprog &> input.txt
Standard output and standard error from myprog are written to input.txt
How many commands can you pipe together at once?
An arbitrary number (in most cases, 16 may be a reasonable number.
You want to run an interactive script, gabby, which produces a lot of output in response to the user’s inputs. To facilitate future study of this script, you want to copy its output to a file. How might you do this?
Type: gabby | tee gabby-out.txt
A text-mode program, verbose, prints a lot of spurious “error” messages to standard error. How might you get rid of those messages while still interacting with the program?
Type: verbose 2> /dev/null
How do the > and»_space; redirection operator differ?
The > operator creates a new file or overwrites an existing on; the»_space; operator creates a new file or appends to an existing one.
What program would you use to display the end of a configuration file?
The tail command displays the last 10 line of a file.
What is the effect of the following command?
$ pr report.txt | lpr
The file report.txt is formatted for printing and sent to the lpr program.
What commands will number the lines in aleph.txt?
1) nl aleph.txt
2) cat -b aleph.txt
3) cat -n aleph.txt