• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/61

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

61 Cards in this Set

  • Front
  • Back

What does using exec to execute a program do that typing the name of the program does not?

It causes the new process to replace the current shell. When the process terminates the shell is closed.

How can you time how long a command takes to execute?

time some_command



This will display total execution time, user cpu time, and system cpu time.

What's the difference between exit and logout in a bash shell?

exit terminates any shell


logout only terminates login shells - login shells are those that are launched automatically when you log in as opposed to those that are started in xterm or another console

What does set do?

It displays or sets various options related to bash operation.

How would you run myprog if the directory in which it resides is the current directory but not in the path?

./myprog



the ./ tells bash the current directory

How do you navigate bash history



go up?


go down?


search in reverse?


search forward?


terminate the search?

up - up arrow or Ctrl + P


down - down arrow or Ctrl + N


search back - Ctrl + R


search forward - Ctrl + S


terminate the search - Ctrl + G


How do you move to the beginning of a line at a bash prompt?

Ctrl + A

How do you move to the end of a line in bash?

Ctrl + E

Move left one character at a time in the bash shell?

Ctrl + B or left arrow key




think B for Back

Move right one character at a time in the bash shell?

Ctrl + F or right arrow key




think F for Forward

Move left one word at a time in the bash shell?

Ctrl + left arrow key or press Esc and then B

Move right one word at a time in the bash shell?

Ctrl + right arrow key or Esc and then F

How do you delete the character under the cursor in the bash shell?



The character to the left?

Del



Backspace

How do you delete all the text from the cursor to the end of the line in the bash shell?

Ctrl + K

How do you delete all the text from the cursor to the beginning of the line in the bash shell?

Ctrl + X

How can you transpose the character before the cursor with the character under t he cursor in the bash shell?



The two words immediately before or under the cursor?

Ctrl + T





Esc and then T

Changing case:

Command to convert the text under the cursor to the end of the line to upper case.

To lower case?

To convert the letter under the cursor to upper case and not affect the rest of the word?
Esc + U (for upper case)

Esc + L (for lower case)

Esc + C (for convert)
How do you invoke an editor to edit a command?
CTRL +X and then CTRL + E

launches the editor defined by $FCEDIT or $EDITOR or Emacs as a last resort.
How do you change the editor mode to Vi?
set -o vi
How do you display all the commands in bash history?
history

(typically the last 500 commands)
How would you execute command number 101 in the history file?
!101
How can you clear the history file?
history -c
Where is your history file stored?
~/.bash_history
What's the difference between ~/.bashrc and ~/.profile and the similarly named /etc/bash.bashrc and /etc/profile?
~/.bashrc and ~/.profile are the main user configuration files for bash whereas /etc/bash.bashrc and /etc/profile are the main global configuration files.
How do you add directories to your path?
Edit the $PATH variable and add colon delimited directories
How do you set an environment variable in bash?
VARIABLE=value
export VARIABLE

or just
export VARIABLE=value
How do you see the value of a variable?
echo $VARIABLE


How can you see the entire environment (all the environment variables and their values)?
env
How can you delete an environment variable?
unset VARIABLE
How do you view the man pages for a command, file, or other feature?
man command

or man file
man uses the less pager.
How do you advance the page?
How do you move back one page?
How do you search the pages?
How do you quit?
Advance a page - space bar
Go back a page - Esc + V
Search - / followed by the text to search for
Quit - Q
What man section contains Device files (usually stored in /dev)?
4
What man section contains executable programs and shell commands?
1
What man section contains System administration commands (programs mainly or exclusively by root)?
8
What man section contains system calls provided by the kernel?
2
What man section contains library calls provided by program libraries?
3
What man sections contain games?
Miscellaneous?
Kernel routines?
games 6
misc 7
kernel routines 9
What is the hypertext variation of man?
info
What numbers correlate to these streams?
Standard Input
Standard Output
Standard Error
Standard Input - 0
Standard Output -1
Standard Error -2

What redirection operator creates a new file containing standard output, overwriting the specified file if it already exists?
>
What redirection operator appends standard output to an existing file but creates the file if it does not exist?
>>
What redirection operator creates a new file containing standard error and overwrites the file if it exists?
2>
What redirection operator appends standard error to a file and creates the file if it does not exist?
2>>
What redirection operator creates a new file containing both standard output and standard error and if the specified file exists, overwrites it?
&>
What redirection operator sends the content of the specified file to to be used as standard input?
<
What redirection operator accepts text on the following lines as standard inputs?
<<
(here document)
What does someprog << EOF do?
This causes someprog to accept input until it see a line that only contains the string EOF. Typically this is accomplished by pressing CRTL + D.

This is an instance of a here document and it is usually done as part of a script to pass data to an interactive program.
What redirection operator causes a file to be used for bot standard input and standard error?
<>
How would you silence a program that was generating a lot of annoying error messages?
annoying_program 2> /dev/null

/dev/null is a dummy device, the bit bucket
How can you pass output from one program to both the screen and as many files as you like?
tee

myprogram | tee output.txt

to append with tee add -a
myprogram | tee -a output.txt
What is the pipe symbol? What does it do?
Just here for completeness.
|
It sends the standard output of one command to the standard input of another command and pipes can be chained an arbitrary number of times.

command1 | command2 | command3 etc
some_command | xargs [option(s)] command [initial-arguments]]

What does xargs do in the above example?
It takes the output of some_command as it's input and for each word passed to it it runs the command.
What does xargs take as delimiters?
How can you specify that is should use newlines as a delimiter?
By default, xargs takes both spaces and newlines as delimiters. You can specify that it take newlines as the delimiter like so:

xargs -d "\n"
What is the difference between the following:

find ./ -name "*~" | xargs -d "\n" rm

and

rm `find ./ -name "8~"`
The example using xargs runs an instance of rm for each result of the find command.

The example using backticks (deprecatred btw, use $(values) instead) runs the rm once and inserts the value of the find command as if it had been typed in the shell.
How can you display line ends with cat?
-E

or

--show-ends
How can you display line numbers with cat?
-n

or

--number

-b or --number-nonblank works similarly but only numbers non blank lines
How do you minimize blank lines with cat?
That is, how do you make it show multiple blank lines as one blank line?
-s or --squeeze-blank
How can you make cat show special characters?
-T or --show-tabs makes cat show tabs
-v or -show--nonprinting displays most special characters using ^ and M- notations.
What does the tac command do?
Displays the output of a file but reverses the order of the lines.
When using join,
If you see a spurious message about a line not being sorted that you don't think is in the file, what might be the issue?
There is an extra line with just a LF in it. Use cat -tE to look for the $ on a line by itself. Not really an exam question but a problem I noticed when practicing with join.
What does join do?
It combines two files based on a match of specified fields in those files. It expects the key fields to be sorted and only returns the combined lines if the key field matches, unless -a is specified as an option. The default key field is the first one and they are delimited by a space or tab. You can use -t char where char is the character you want to be delimiter to change this.