GNU and Unix Commands Flashcards

1
Q

make

A

Utility to read a source configuration file and maintain a group of files or programs

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

env

A

Shows the current session environment variables

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

pwd

A

Print the path of the current working directory

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

uname

A

Prints system information

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

uname -n

A

Node name

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

uname -s

A

Kernel name

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

uname -v

A

Kernel version

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

uname -r

A

Kernel release

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

uname -m

A

Machine/CPU info

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

uname -p

A

Processor info

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

uname -i

A

Hardware info

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

uname -o

A

Operating system name

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

uname -a

A

Print all info

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

export

A

Used to set an environment variable

export HOME = /home/user

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

unset

A

Used to remove an environment variable

unset $HOME

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

man (1)

A

Executable programs or shell commands

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

man (2)

A

System calls

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

man (3)

A

Library calls

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

man (4)

A

Special files (usally found in /dev)

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

man (5)

A

File formats and conventions

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

man (6)

A

Games

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

man (7)

A

Miscellaneous

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

man (8)

A

System administration commands

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

man (9)

A

Kernel routines

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

fmt

A

Reformats streams or files for display as indicated

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

join -t :

A

Will join lines on occurrences of :

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

join -1 FIELD
or
join -2 FIELD

A

Will join on the field in file 1 or in file 2

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

pr

A

Convert files for printing

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

split -l 2 file.txt name

A

Will split file.txt 2 lines at a time and name the output files namea, nameb, namec…

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

unexpand

A

Converts spaces to tabs

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

expand

A

Converts tabs to spaces

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

cut -f1 -d: myfile

A

Will return the first field of each line in myfile, as separated by colons. For example, if a line is “Matt:Miller:Man”, then “Matt” would be returned.

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

cut -c2 test.txt

A

Will display only those letters in the 2nd column of test.txt

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

cut -c3-6 test.txt

A

Will display the 3rd through 6th characters of each line

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

head -c 10 file.txt

A

Output the first 10 bytes of file.txt

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

head -n 10 file.txt

A

Output the first 10 lines of file.txt

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

nl

A

Add line numbers to a file for display or redirect to another file

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

sed ‘s/parttime/fulltime/’ myfile

A

Will replace the first occurrence of “parttime” in each line of myfile with “fulltime” (Not in the file, just the stream!)

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

sed ‘s/parttime/fulltime/w promotions.txt’ myfile

A

Will replace the first occurrence of “parttime” in each line of myfile with “fulltime” and write it to the file promotions.txt

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

sed ‘/fulltime/w fulltime.txt’ myfile

A

Will not replace anything, but will write all lines with “fulltime” in them to fulltime.txt

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

sed ‘s/]*>//’ myfile

A

Will substitute anything that starts with “”, and ends with “>”

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

tail -c 10 file.txt

A

Will output the last 10 bytes of file.txt

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

tail -n 10 file.txt

A

Will output the last 10 lines of file.txt

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

uniq -d

A

Only print duplicate lines

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

uniq -u

A

Only print unique lines

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

uniq

A

Prints all lines of a file, but merges duplicates to the first occurrence

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

od

A

Dump files in octal format

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

paste

A

Merge lines of files

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

sort file.txt

A

Outputs the contents of file.txt in alphanumerical order

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

tr

A

Translate/squeeze/delete characters from standard input writing to output

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

wc -l file.txt

A

Shows number of lines in file.txt

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

wc -c file.txt

A

Shows number of bytes in file.txt

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

wc -m file.txt

A

Shows number of characters in file.txt

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

wc -w file.txt

A

Shows number of words in file.txt

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

cp -a file1 file2

A

Makes an archive of file1 called file2

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

cp -r mydir mynewdir

A

Will copy the contents of mydir to mynewdir

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

cp -u

A

Copy only when the SOURCE file is newer than the destination file or when the destination file is missing

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

cp –backup

A

Will backup each destination file

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

cp -d

A

Will preserve links

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

mv file1 file2

A

Will rename file1 to file2

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

mv -f

A

Will not prompt to overwrite

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

mv -i

A

Interactive, prompt for overwrite

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

mv -n

A

No clobber, do not overwrite existing files

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

touch -a

A

Updates the access time only

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

touch -c

A

Do not create file if it doesn’t exist

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

touch -d

A

Parse string and use it instead of current time

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

touch -m

A

Change only the modification time

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

touch -r file1 file2

A

Makes file2’s access and modify times the same as file1’s

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

touch -t

A

Use specified timestamp

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

dd if=/dev/zero of=file.iso bs=1024 count=1

A

Reading from /dev/zero (which just contains zeroes) we want to write to file.iso 1024 bytes (1KB) one time.

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

dd if=myfile conv=ucase

A

Writes the contents of myfile to standard output in all caps (conv = lcase would do lowercase)

72
Q

gzip file1

A

Compress file1

73
Q

gzip -d

A

Decompress file1

74
Q

gzip -f
and
gunzip -f

A

Force

75
Q

gzip -l
and
gunzip -l

A

List things about a compressed file

76
Q

gzip -q
and
gunzip -q

A

Quiet

77
Q

gzip -t
and
gunzip -t

A

Test

78
Q

gzip -v
and
gunzip -v

A

Verbose

79
Q

mkdir -p first/second/third

A

Will create the chain of directories /first/second/third

80
Q

tar -d

A

Find differences between archive and file system

81
Q

tar –delete

A

Delete from archive

82
Q

tar -c

A

Create new archive

83
Q

tar -A

A

Append tar files to an archive

84
Q

tar -r

A

Append files to the end of an archive

85
Q

tar -u

A

Only append files newer than copy in archive

86
Q

tar -t

A

List contents of an archive

87
Q

tar -x

A

Extract files from an archive

88
Q

tar -z

A

Filter through gzip

89
Q

tar -j

A

Filter through bzip2

90
Q

tar -J

A

filter through xz compression

91
Q

file filename

A

Determines the type of file that filename is

92
Q

bzip2

A

Compression utility used in conjunction with tar for archiving

93
Q

ls | tee -a file2

A

Will append the result of the “ls” command to “file2”

94
Q

ls | tee mynewfile

A

Will write the results of “ls” to the file ‘mynewfile’ and also print the result of the “ls” command to stdout

95
Q

xargs

A

Reads from standard input and compiles the input into separate arguments.
By default, assumes the arguments are separated by any white space

96
Q

xargs -a

A

Reads items from a file instead of stdin

97
Q

xargs -0

A

Input items are temrinated by a null character instead of by white space

98
Q

xargs -d

A

Input items are terminated by the specified character

99
Q

jobs

A

Command that displays minimal info about processes associated with the current session

100
Q

ps

A

By default, displays all processes that were run from this terminal

101
Q

ps -Ae

A

Displays all processes on the system

102
Q

ps -u matt

A

Display processes run by the user matt

103
Q

ps -w > file.txt

A

Will write the output of ps to file.txt

104
Q

uptime

A

Finds uptime and displays load average

105
Q

How to put a process in background?

A

Ctrl+Z

106
Q

fg

A

Used to send a program back to foreground

107
Q

kill pid

A

Stops the process with the process ID pid

108
Q

nohup

A

Used to run a command immune to hangups

109
Q

killall processname

A

Kills all processes called processname

110
Q

free

A

Show free memory and swap (by default in kilobytes)

111
Q

free -b

A

Shows the stats in bytes

112
Q

free -m

A

Shows the stats in megabytes

113
Q

free -s 2

A

Will show the stats every 2 seconds

114
Q

Signal 1

A

SIGHUP 1 HANGUP

115
Q

Signal 2

A

SIGINT 2 INTERRUPT FROM KEYBOARD

116
Q

Signal 9

A

SIGKILL 9 KILL SIGNAL

Unblockable, the harsher kill signal

117
Q

Signal 15

A

SIGTERM 15 TERMINATION SIGNAL

The nicer kill signal

118
Q

Signal 17, 19, 23

A

SIGSTOP STOP THE PROCESS

119
Q

When a child process exits from a parent process it sends which signal?

A

1

120
Q

nice programname

A

Will run programname with a nice value of 10

121
Q

renice -n -20 -p 1650

A

Will set the nice value to -20 for the process with PID 1650

122
Q

nice -n 5 programname

A

Will run programname with a nice value of 5 (can also just do “nice -5 programname”) (better to do the -n though so that negative values are less confusing)

123
Q

renice -n -20 -u root

A

Will set all of roots processes to have a nice value of -20

124
Q

pgrep processname

A

Will find all process ids of processes running called processname

125
Q

Range of nice values

A

-20 is highest priority, 19 is lowest priority

126
Q

While running top, k

A

Kills processes

127
Q

While running top, q

A

Quits top

128
Q

While running top, r

A

Used to renice process

129
Q

While running top, s

A

Used to change update rate

130
Q

While running top, P

A

Sort by CPU usage

131
Q

While running top, M

A

Sort by memory usage

132
Q

top -d

A

Specify delay between updates

133
Q

top -p

A

Can specify up to 20 specific PIDs

134
Q

top -n 2

A

Display 2 updates then quit

135
Q

top -b

A

Batch mode

136
Q

sort -f

A

Sorts output, ignoring case

137
Q

grep ^hello myfile

A

Will return all lines in myfile that begin with hello

138
Q

grep -c hello myfile

A

Gives a count of the number of lines in myfile that contain hello

139
Q

grep hello$ myfile

A

Will return all lines in myfile that end with hello

140
Q

grep [abc] myfile

A

Will return all the lines in myfile that contain a, b, or c

141
Q

grep [a-m] myfile

A

Will return all lines in myfile that contain one of the letters in the range from a to m

142
Q

grep [1-9] myfile

A

Will return all lines of myfile that contain one of the numbers in the range 1 to 9

143
Q

grep -f grepinput myfile

A

Uses the content of the file grepinput as the regular expression we are searching for in myfile

144
Q

grep -l word mydir

A

Will search mydir to find files that contain word within them, NOT in the filename

145
Q

grep -r word mydir

A

Will recursively search for filenames containing word starting at mydir

146
Q

egrep ‘hello.*world’ myfile

A

Will return all lines in myfile that contain ‘hello’ and ‘world’ in that order

147
Q

grep -i

A

Searches case-insensitively

148
Q

egrep ‘hello|world’ myfile

A

Will return all lines that contain ‘hello’ or ‘world’ or both

149
Q

grep -v

A

Will return all lines that do NOT contain the term we are searching for

150
Q

fgrep

A

Used to match patterns literally, i.e. no characters are treated as special characters

151
Q

While in vi command mode, l (lowercase L)

A

Moves cursor one character to right

152
Q

While in vi command mode, h

A

Moves cursor one character to left

153
Q

While in vi command mode, j

A

Moves cursor one character down

154
Q

While in vi command mode, k

A

Moves cursor one character up

155
Q

While in vi command mode, yy

A

Will yank entire line

156
Q

While in vi command mode, p

A

Will paste starting on the line after your cursor

157
Q

While in vi command mode, P

A

Will paste starting on line before your cursor

158
Q

While in vi command mode, 5G

A

Will move to line 5

159
Q

While in vi command mode, G

A

Moves cursor to beginning of last line in the file

160
Q

While in vi command mode, L

A

Moves cursor to beginning of last line on the screen (not last line of file)

161
Q

While in vi command mode, H

A

Moves cursor to first line on the screen (not first line in the file)

162
Q

While in vi command mode, o

A

Creates a new line below your current position and opens insert mode

163
Q

While in vi command mode, /word

A

Will search forward in the file for the word “word”.

Use “n” to move to the next occurrence

164
Q

While in vi command mode,

?word

A

Will search backward in the file for the word “word”

165
Q

While in vi command mode, R

A

Go into insert mode and overwrite text as you type

166
Q

While in vi command mode, cw

A

Remove current word under cursor and go into insert mode

167
Q

While in vi command mode, cc

A

Remove entire line you are on and go into insert mode

168
Q

While in vi ex mode, %s/user/root

A

Will replace the first occurrence of “user” on each line of the file with “root”

169
Q

While in vi ex mode, %s/user/root/g

A

Will replace all occurrences of “user” with root; adding the g means “global”

170
Q

While in vi ex mode, e /file.txt

A

Will load the new file.txt into the vi editor for editing. This will only occur if the current changes to the file being edited are saved

171
Q

While in vi ex mode, r

A

Allows you to bring contents of an old file into a new one

172
Q

While in vi ex mode, !

A

Allows you to run shell commands from within vi example: !ls /etc

173
Q

While in vi command mode,

O

A

Add line above cursor and go into insert mode

174
Q

While in vi command mode,

A

A

Append text at the end of the line

175
Q

While in vi command mode,

a

A

Append text after the cursor

176
Q

While in vi command mode,

I

A

Insert text at the beginning of the line