Commands Flashcards

(98 cards)

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
How do you print the current working directory
pwd
26
What command makes a new directory
mkdir nameWithOptionalPath
27
What does "mkdir" do
Makes a new directory
28
What command changes your directory
cd absoluteOrRelativePath
29
How do you remove a directory
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
30
What does "rmdir" do
Removes a directory
31
What does "chmod" do
Changes permissions of a file
32
How do you change permissions of a file
chmod newPermissions fileToChange
33
The "cat" command without arguments will start concatenating a string that you type, and includes newlines. How do you finish this?
ctrl-d (end of file)
34
What do the >, <, and > > symbols do
Redirection
35
Which is the redirect output symbol
>
36
Which is the redirect input symbol
<
37
In BASH, how do you enable and disable overwriting files via redirection
disable: set -o noclobber enable set +o noclobber
38
Which is the append output symbol
>>
39
How do you append the end of a file
>>
40
What is > > called
The Append Output Symbol
41
What file is the black hole for output, and what is this called
/dev/null Data Sink / Bit Bucket
42
What is the difference between redirection and pipelines
Pipelines do everything in memory with no need for files
43
You can "cat" files and pipe them into another utility, but what is a better way
Use Redirect Input Symbol commandToUse < fileToReadFrom
44
Can any command be used as a filter
No
45
How can you split a command to write to a file and also provide Standard Output
commandGivingOutput | tee pathnameToWriteTo | commandToReceiveOutput
46
Why is it called "tee"
The letter like a pipeline splitting "T"
47
How do you run a Job in the background
End the command-line with & (right before you hit Enter)
48
How do you put a suspended foreground Job into the background and restart it
bg numberOfJobToRestartOrOptionalIfOnlyOne
49
How do you bring a background job to the foreground
fg numberOfJobOrOptionalIfOnlyOne OR % numberOfJobOrOptionalIfOnlyOne
50
What does "ps" stand for
Process Status
51
How do you get all of the current background processes
ps
52
What are PIDs
Process IDs
53
What command shows what shell youre running
echo $0 (zero) or echo $SHELL
54
How do you delete a word in the terminal
ctrl+w
55
How do you suspend a program
ctrl-z
56
How do you delete a line in the terminal
ctrl-u OR ctrl-x
57
How do you terminate a program
ctrl-c OR [delete]
58
How do you send a QUIT command from the terminal
ctrl-\
59
What command displays all current jobs running
jobs
60
How do you suspend a specific job
If the job number is 3, it is: kill %3
61
How do you run the previous command with substitutions
^old^new^
62
What is stored in !$
The last token (word) of the last command
63
How do you get the last token (word) of the last command
It's stored in !$
64
How do you run a single command using root privs
su -c 'command'
65
How do you spawn a new shell with root privs, and how do you close it
su exit
66
What is the typical symbol for prompts, and what is it for root privileges
$, and #
67
What is the syntax for sudo for one command and for multiple
One command: sudo command Multiple: sudo -s
68
How do you try to find a command
apropos keywordToSearchShortDescriptionsOfManPages
69
Instead of using the "man" command, how can you get info on a utility
utilityToGetHelpOn - -help some times you instead use "-h" or "-help" you often need to pipe this to "less"
70
What is the remove file command and what is the safe option
rm -i
71
What are the 2 main sort options
-u, unique -n, numeric order for numbers
72
What does the "uniq" command do
Reads a file and skips identical, adjacent lines; often used with "sort" to remove all duplicates
73
How do you refer to a job number
%jobNumber
74
wtf is globbing
using wildcards ... :(
75
What are wildcards also called
Special Characters Meta-characters Ambiguous File References (for the whole string)
76
What does the ? special character mean
It is like *, but specifically 1 character (not 0 or many)
77
What do the special characters [ ] mean
its like ?, but more restrictive in that the characters within the brackets define a set or range of acceptable characters
78
How do you define a range
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
What is ^ called
A caret
80
How do you negate a set/range
have ^ or ! be at the beginning, like: [!1-3] (not 1, 2, or 3)
81
How do you list the BASH builtins
info bash
82
How do you translate contents
tr charsFrom charsTo
83
What are the 2 vim modes
1. Command/Normal Mode 2. Insert Mode
84
How do you delete a character, a word, and a line in vim
x, dw, dd
85
What are the 3 ending options for "find"
1. -print 2. -exec 3. -ok (same as exec but safe mode via prompting)
86
What are the 15 options for "find"
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
What are the 6 arguments for the -type option of "find"
1. b (block) 2. d (directory) 3. c (character) 4. p (pipe) 5. l (symbolic link) 6. f (ordinary)
88
What does "-o" do for the "find" command
It's a logical OR
89
What unit of time is the "-mtime" option for on the "find" command
Days ... not sure why they didnt just name it -days
90
How do you set a range for the "-newer" option of "find"
-newer latestFileModified !-newer newestFileModified
91
When using "find", what type of file traversal does it perform
Breadth-first
92
What do a lot of systems restrict for the -exec command option on "find"
You can only use "ls -l"
93
What is a common but dangerous -exec command for "find"
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
What is the -exec syntax for "find"
-print -exec commandToRun {} \;
95
What is using ~ for a pathname synonymous with
$HOME
96
What is a limit of using -exec for "find" and what is the solution
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
What does grep stand for
Global Regular Expression Print
98