Brainscape Bash Flashcards

1
Q

search history forward/backward

A

CTRL-R / CTRL-S (mnemonic: Reverse history search, Search [forward])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

cancel history search

A

CTRL-G (mnemonic “Get out of here”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

cycle through final parameter of previous commands

A

ALT-.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

cycle through completions (set manually)

A

ALT-S

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

go to beginning/end of line

A

CTRL-A / CTRL-E

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

go to previous / next command in history

A

CTRL-P / CTRL-N

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

move forward/backward (right/left) one word

A

ALT-F / ALT-B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

toggle between beginning of line and current character position

A

CTRL-XX

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

clear whole screen, similar to “clear” command

A

CTRL-L (mnemonic “cLear”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

delete word backward / forward

A

ALT-Backspace / ALT-D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

cut word before/after cursor to clipboard

A

CTRL-W / CTRL-K (mnemonics, backward just like Vim, CTRL-K “Kill”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

cut the whole line before the cursor to clipboard

A

CTRL-U

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

paste the last thing to be cut

A

CTRL-Y

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

swap current word with previous

A

ALT-T

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

undo

A

CTRL-_

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

revert the line to the way it was in history

A

ALT-R (mnemonic: “Revert”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

how to make a tag on a command in history

A

just use “#tag”–anything after the tag is a comment, but will be retained in history

18
Q

how to change to the previous directory

A

cd -

19
Q

how to use the previous directory in a command

A

can be specified with “~-“ (e.g. “tar xzf ~-/moz”)

20
Q

view all history

A

history

21
Q

view last five commands of history

A

history 5

22
Q

search history for all commands with “cd” in them

A

history | grep cd

23
Q

how to do a reverse-i-search with text you’ve already entered

A

CTRL-aryr

24
Q

history for previous command name

A

!!:0

25
Q

history to execute the last “ssh” command

A

!ssh

26
Q

search history for a string not at the beginning of the command

A

!?commit?

27
Q

history to access the second word of the most recent command

A

!!:1

28
Q

history to grab everything from the second word on, of the most recent command

A

!!:1*

29
Q

history to grab everything from the beginning to the third word of the most recent command

A

!!:*2

30
Q

history to grab indices 2-3 of the most recent command

A

!!:2-3

31
Q

history for the first/last word of the most recent command

A

!!:^ / !!:$

32
Q

access history entry number 51

A

!51

33
Q

history access second-to-last most recent command

A

!-2 (-1 is most recent command, and count back from there)

34
Q

macro to add an option to the previous command (manually defined)

A

ALT-O

35
Q

meaning of single quotes

A

everything is completely literal, no escaping needed

36
Q

meaning of double quotes

A

treated like a string, except that “$” and “" are interpreted

37
Q

define a variable

A

ten=10

38
Q

print out the contents of the variable “ten”, also, what is a caviat with this that you should anticipate

A

echo $ten if the variable is a string with spaces, you’ll have to quote the variable in order to preserve it, e.g. echo “$ten”

39
Q

create an alias

A

alias ds=’cd ~/Dropbox’

40
Q

remove an alias

A

unalias ds

41
Q

temporarily ignore an alias

A

\ls (simply escape with backslash)