Chapter 1: Exploring Linux Command Line Flashcards

1
Q

GNU Born Again Shell

A

This is <b>bash</b>. It’s the most common shell, and was built upon the Bourne shell.

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

Bourne

A

This is <b>sh</b>. <b>sh</b> is now usually a pointer for another shell.

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

<b>tcsh</b>

A

Based on C shell, no major distributions default to it, but it’s fairly popular to a dedicated croud. It’s pretty similar to <b>bash</b>.

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

<b>csh</b>

A

C shell. It’s not used much anymore.

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

<b>ksh</b>

A

Korn shell. It was designed to combine the best elements of <b>sh</b> and <b>csh</b>. It has a small, dedicated following.

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

<b>zsh</b>

A

Z shell. It’s an evolution of <b>ksh</b>.

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

Default interactive shell

A

This is the shell that the user makes use of to interact with Linux.

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

Default system shell

A

This is the shell used by Linux to run system shell scripts, usually at startup.

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

<b>uname</b>

A

This displays your operating system. <b>uname -a</b> will give you a more verbose display.

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

Internal vs. External commands

A

You can determine whether a command is a built-in with <b>type</b>
<b>$type cd
cd is a shell builtin
$</b>

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

How do you run an external command when you have an internal command of the same name installed?

A

You have to type the whole directory path to it, because internal commands take precedence.
<b>$/bin/pwd
/root
$</b>

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

<b>chmod</b>

A

This command is used to change the executable status of a file.

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

Command Completion

A

If you’re lazy, you can hit tab while you’re typing in the command line and it will go through auto complete options that it thinks you may want

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

Command history

A

You can up arrow to go through the commands you’ve typed, or you can ctrl+R to search for commands you’ve typed.

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

Invoke a text editor

A

Type ctrl+x followed by ctrl+E. This launches the editor defined by <b>$FCEDIT</b> or <b>$EDITOR</b>.

  • It will launch Emacs as a last resort.
  • If you prefer vi to Emacs, type <b>set -o vi</b>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do I retrieve and run the last command I ran?

A
With <b>!!</b>
<b>$!!
type -a pwd
pwd is a shell builtin
pwd is /bin/pwd
$</b>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How do I clear my command history?

A

<b>history -c</b>

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

Where is my bash history contained?

A

in <b>/home/.bash_history</b>

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

<b>touch</b>

A

This is used to create an empty file.

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

<b>man</b>

A

<b>man</b> is how you access the user manual for damn near any program you could possibly want to run. You may use <b>info</b> as well, which produces about the same result, but displays it in hypertext format.

21
Q

File Desctriptors

A

STDIN-0
STDOUT-1
STDERR-2

22
Q

Common redirection operators

A

> creates a new file containing standard output
> Appends standard output to an existing file
2> Creates a new file containing standard error
2» Appends standard error to an existing file
&> Creates a new file containing STDOUT, STDERR
Causes a file to be used for STDIN, STDOUT

23
Q

When you’re getting a bunch of useless error messages, what should you do?

A

<b>whine 2> /dev/null</b>

<b>/null</b> is a ghost directory that isn’t attached to anything, so all the files you send there go to Limbo.

24
Q

Piping

A

<b>$first | second</b>

this sends the output of <b>first</b> to be the input of <b>second</b>.

25
Q

<b>tee</b>

A

You can use this to see the STDOUT as well as create a file for output.
<b>$echo $PATH | tee path.txt</b>

26
Q

<b>xargs</b>

A

This builds a command from its standard input.
Basic syntax:
<b>xargs [options] [command[initial-arguments]]</b>

<b>find /-user Christine | xargs -d “\n” rm</b>
That just found all the files and directories owned by Christine and removed them.

27
Q

<b>cat</b>

A

<b>$cat first.txt second.txt > combined.txt</b>

This just combined the first and second files together.

28
Q

<b>join</b>

A

Used to join data together based on common fields

29
Q

<b>paste</b>

A

used to join data together with tab-separated columns.

30
Q

<b>expand</b>

A

Turns tabs into spaces. The default amount of spaces is eight.

31
Q

<b>od</b>

A

This stands for octal dump. It shows a file in an unambiguous format (octal by default, displays in hex, decimal, and ASCII with escaped control characters)
-this helps you view files that don’t play well with ASCII

32
Q

<b>sort</b>

A

Used to sort output files. IT gets very in depth

33
Q

<b>split</b>

A

This splits a file into certain sizes, you can determine by bytes, by maximum byte size with no line cutoffs, or by line.

34
Q

<b>tr</b>

A

This translates characters. There are a lot of modifiers you can use.

35
Q

<b>unexpand</b>

A

Converts spaces to tabs. This can compress the size of some files.

36
Q

<b>uniq</b>

A

Removes duplicate lines.

37
Q

<b>fmt</b>

A

REformats a file whose lines might be too long for your display

38
Q

<b>nl</b>

A

Numbers lines in a file. Default numbers blank lines, too.

39
Q

<b>pr</b>

A

Formats documents in a way that’s suitable for printing.

40
Q

<b>head</b>

A

Echoes the first 10 lines of one or more files. You can change how many lines get echoed.

41
Q

<b>tail</b>

A

Echoes the last 10 lines of one or more files. You may choose to keep it opened and view lines as they are added. This is useful with logs.

42
Q

<b>less</b>

A

A robust file viewer that lets you read one page at a time.

43
Q

<b>cut</b>

A

This extracts portions of input lines and displays them as standard output. You can cut specified lists of bytes or cut specified lists of characters. You can also cut specified lists of fields, which will produce different results

44
Q

<b>list</b>

A
You can write lists in a few ways.
one value <b>4</b>
a range of values <b>2-4</b>
all values leading up to something <b>-4</b>
all values following something <b>4-</b>
45
Q

<b>wc</b>

A
Displays a word count.
<b>$wc file.txt
308 2343 15534 file.txt
$</b>
This shows us that the file has 308 lines, 2343 words, and 15534 bytes
46
Q

Regular Expressions

A
Bracket Expressions
  -b[aeiou]g matches bag, beg, big, bog, bug
Range expressions
  -a[2-4]z matches a2z, a3z, a4z
Any Single Character
  -a.z matches abz, a8z, aUz....
47
Q

<b>grep</b>

A

Searches for files that contain a specified string and return the name of the file and the line of context for that string.
<b>grep [options] pregexp] [files]</b>

48
Q

<b>sed</b>

A

Directly modifies a file’s contents and sends it to STDOUT.
<b>sed [options] -f [script file] [input file]
sed [options] [script text] [input file]</b>