Commands Flashcards

1
Q

What is the “less” utility

A

A pager

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

What is the copy file command

A

cp sourceFilepath destinationFilepath

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

How do you rename a file

A

mv

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

How do you move a file

A

mv sourceFilepath destinationDirectory

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

How do you compare files

A

diff -u file1 file2

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

What is the wc command

A

Word count

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

What is the command that compresses multiple files for linux systems

A

tar

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

Why is it called “tar”

A

Short for “tape archive”, this command used to be only for creating and reading archive and backup tapes

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

How do you find the full pathname of the file in your PATH of a non-builtin utility

A

which utilityToFind

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

What does the “which” command do

A

Returns the first pathname found in the directories of $PATH of a utility you provide as an argument

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

How do you look for files related to a non-builtin utility in standard locations

A

whereis filesToFind

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

What does the “whereis” command do

A

Searches standard locations (instead of $PATH directories) for files relating to a utility you specify

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

How do you find files using a keyword as to loosely match filenames to

A

locate keywordOfFilenamesToLooselyMatch

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

What does the “locate” command do

A

Finds loosely matched filenames and returns their filepath

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

What are the 3 commands to see who is using the system

A

w
who
finger

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

Which “who” command shows system usage information

A

w

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

Which “who” command displays the least amount of information

A

who

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

Which “who” command displays the most human profile information

A

finger

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

Which command shows system memory information

A

free

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

What does the “free” command do

A

Shows system memory information

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

How do you write to a user

A

write userToSendTo

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

How do you enable messaging

A

mesg y

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

What is the “ls” option to show hidden files

A

-a

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

What does the “pwd” command do

A

Prints the current working directory

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

How do you print the current working directory

A

pwd

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

What command makes a new directory

A

mkdir nameWithOptionalPath

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

What does “mkdir” do

A

Makes a new directory

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

What command changes your directory

A

cd absoluteOrRelativePath

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

How do you remove a directory

A

rmdir pathOfDirectoryToRemove; the directory must be empty.
You can use rm -r to recursively delete the contents of a directory, but making a mistake can be disasterous

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

What does “rmdir” do

A

Removes a directory

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

What does “chmod” do

A

Changes permissions of a file

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

How do you change permissions of a file

A

chmod newPermissions fileToChange

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

The “cat” command without arguments will start concatenating a string that you type, and includes newlines. How do you finish this?

A

ctrl-d (end of file)

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

What do the >, <, and > > symbols do

A

Redirection

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

Which is the redirect output symbol

A

>

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

Which is the redirect input symbol

A

<

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

In BASH, how do you enable and disable overwriting files via redirection

A

disable:
set -o noclobber
enable
set +o noclobber

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

Which is the append output symbol

A

> >

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

How do you append the end of a file

A

> >

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

What is > > called

A

The Append Output Symbol

41
Q

What file is the black hole for output, and what is this called

A

/dev/null
Data Sink / Bit Bucket

42
Q

What is the difference between redirection and pipelines

A

Pipelines do everything in memory with no need for files

43
Q

You can “cat” files and pipe them into another utility, but what is a better way

A

Use Redirect Input Symbol
commandToUse < fileToReadFrom

44
Q

Can any command be used as a filter

A

No

45
Q

How can you split a command to write to a file and also provide Standard Output

A

commandGivingOutput | tee pathnameToWriteTo | commandToReceiveOutput

46
Q

Why is it called “tee”

A

The letter like a pipeline splitting “T”

47
Q

How do you run a Job in the background

A

End the command-line with & (right before you hit Enter)

48
Q

How do you put a suspended foreground Job into the background and restart it

A

bg numberOfJobToRestartOrOptionalIfOnlyOne

49
Q

How do you bring a background job to the foreground

A

fg numberOfJobOrOptionalIfOnlyOne
OR
% numberOfJobOrOptionalIfOnlyOne

50
Q

What does “ps” stand for

A

Process Status

51
Q

How do you get all of the current background processes

A

ps

52
Q

What are PIDs

A

Process IDs

53
Q

What command shows what shell youre running

A

echo $0 (zero)
or
echo $SHELL

54
Q

How do you delete a word in the terminal

A

ctrl+w

55
Q

How do you suspend a program

A

ctrl-z

56
Q

How do you delete a line in the terminal

A

ctrl-u OR ctrl-x

57
Q

How do you terminate a program

A

ctrl-c OR [delete]

58
Q

How do you send a QUIT command from the terminal

A

ctrl-\

59
Q

What command displays all current jobs running

A

jobs

60
Q

How do you suspend a specific job

A

If the job number is 3, it is:
kill %3

61
Q

How do you run the previous command with substitutions

A

^old^new^

62
Q

What is stored in !$

A

The last token (word) of the last command

63
Q

How do you get the last token (word) of the last command

A

It’s stored in !$

64
Q

How do you run a single command using root privs

A

su -c ‘command’

65
Q

How do you spawn a new shell with root privs, and how do you close it

A

su
exit

66
Q

What is the typical symbol for prompts, and what is it for root privileges

A

$, and #

67
Q

What is the syntax for sudo for one command and for multiple

A

One command:
sudo command
Multiple:
sudo -s

68
Q

How do you try to find a command

A

apropos keywordToSearchShortDescriptionsOfManPages

69
Q

Instead of using the “man” command, how can you get info on a utility

A

utilityToGetHelpOn - -help
some times you instead use “-h” or “-help”
you often need to pipe this to “less”

70
Q

What is the remove file command and what is the safe option

A

rm -i

71
Q

What are the 2 main sort options

A

-u, unique
-n, numeric order for numbers

72
Q

What does the “uniq” command do

A

Reads a file and skips identical, adjacent lines; often used with “sort” to remove all duplicates

73
Q

How do you refer to a job number

A

%jobNumber

74
Q

wtf is globbing

A

using wildcards … :(

75
Q

What are wildcards also called

A

Special Characters
Meta-characters
Ambiguous File References (for the whole string)

76
Q

What does the ? special character mean

A

It is like *, but specifically 1 character (not 0 or many)

77
Q

What do the special characters [ ] mean

A

its like ?, but more restrictive in that the characters within the brackets define a set or range of acceptable characters

78
Q

How do you define a range

A

use square brackets and a dash between the start and end
[a-z] (all lowercase letters)
[0-9] (all numbers)
[a-zA-Z] (all letters)

79
Q

What is ^ called

A

A caret

80
Q

How do you negate a set/range

A

have ^ or ! be at the beginning, like:
[!1-3] (not 1, 2, or 3)

81
Q

How do you list the BASH builtins

A

info bash

82
Q

How do you translate contents

A

tr charsFrom charsTo

83
Q

What are the 2 vim modes

A
  1. Command/Normal Mode
  2. Insert Mode
84
Q

How do you delete a character, a word, and a line in vim

A

x, dw, dd

85
Q

What are the 3 ending options for “find”

A
  1. -print
  2. -exec
  3. -ok (same as exec but safe mode via prompting)
86
Q

What are the 15 options for “find”

A
  1. -name
  2. -perm
  3. -prune
  4. -user / -nouser
  5. -group / -nogroup
  6. -mtime
  7. -type
  8. -newer
  9. -size
  10. -depth
  11. -fstype
  12. -mount
  13. -follow
  14. -cpio
  15. local
87
Q

What are the 6 arguments for the -type option of “find”

A
  1. b (block)
  2. d (directory)
  3. c (character)
  4. p (pipe)
  5. l (symbolic link)
  6. f (ordinary)
88
Q

What does “-o” do for the “find” command

A

It’s a logical OR

89
Q

What unit of time is the “-mtime” option for on the “find” command

A

Days … not sure why they didnt just name it -days

90
Q

How do you set a range for the “-newer” option of “find”

A

-newer latestFileModified !-newer newestFileModified

91
Q

When using “find”, what type of file traversal does it perform

A

Breadth-first

92
Q

What do a lot of systems restrict for the -exec command option on “find”

A

You can only use “ls -l”

93
Q

What is a common but dangerous -exec command for “find”

A

Removing files … make sure you “ls -l” instead first to make sure its what you mean to delete, or just replace -exec with -ok to prompt each removal (if the list isnt too big)

94
Q

What is the -exec syntax for “find”

A

-print -exec commandToRun {} \;

95
Q

What is using ~ for a pathname synonymous with

A

$HOME

96
Q

What is a limit of using -exec for “find” and what is the solution

A

The command is not executed until “find” is finished, potentially resulting in a memory limit being reached and the command terminated

You can instead pipe the -print of “find” to “xargs”, which runs in batches instead

97
Q

What does grep stand for

A

Global Regular Expression Print

98
Q
A