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
fmt
Reformats streams or files for display as indicated
26
join -t :
Will join lines on occurrences of :
27
join -1 FIELD or join -2 FIELD
Will join on the field in file 1 or in file 2
28
pr
Convert files for printing
29
split -l 2 file.txt name
Will split file.txt 2 lines at a time and name the output files namea, nameb, namec...
30
unexpand
Converts spaces to tabs
31
expand
Converts tabs to spaces
32
cut -f1 -d: myfile
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.
33
cut -c2 test.txt
Will display only those letters in the 2nd column of test.txt
34
cut -c3-6 test.txt
Will display the 3rd through 6th characters of each line
35
head -c 10 file.txt
Output the first 10 bytes of file.txt
36
head -n 10 file.txt
Output the first 10 lines of file.txt
37
nl
Add line numbers to a file for display or redirect to another file
38
sed 's/parttime/fulltime/' myfile
Will replace the first occurrence of "parttime" in each line of myfile with "fulltime" (Not in the file, just the stream!)
39
sed 's/parttime/fulltime/w promotions.txt' myfile
Will replace the first occurrence of "parttime" in each line of myfile with "fulltime" and write it to the file promotions.txt
40
sed '/fulltime/w fulltime.txt' myfile
Will not replace anything, but will write all lines with "fulltime" in them to fulltime.txt
41
sed 's/]*>//' myfile
Will substitute anything that starts with "", and ends with ">"
42
tail -c 10 file.txt
Will output the last 10 bytes of file.txt
43
tail -n 10 file.txt
Will output the last 10 lines of file.txt
44
uniq -d
Only print duplicate lines
45
uniq -u
Only print unique lines
46
uniq
Prints all lines of a file, but merges duplicates to the first occurrence
47
od
Dump files in octal format
48
paste
Merge lines of files
49
sort file.txt
Outputs the contents of file.txt in alphanumerical order
50
tr
Translate/squeeze/delete characters from standard input writing to output
51
wc -l file.txt
Shows number of lines in file.txt
52
wc -c file.txt
Shows number of bytes in file.txt
53
wc -m file.txt
Shows number of characters in file.txt
54
wc -w file.txt
Shows number of words in file.txt
55
cp -a file1 file2
Makes an archive of file1 called file2
56
cp -r mydir mynewdir
Will copy the contents of mydir to mynewdir
57
cp -u
Copy only when the SOURCE file is newer than the destination file or when the destination file is missing
58
cp --backup
Will backup each destination file
59
cp -d
Will preserve links
60
mv file1 file2
Will rename file1 to file2
61
mv -f
Will not prompt to overwrite
62
mv -i
Interactive, prompt for overwrite
63
mv -n
No clobber, do not overwrite existing files
64
touch -a
Updates the access time only
65
touch -c
Do not create file if it doesn't exist
66
touch -d
Parse string and use it instead of current time
67
touch -m
Change only the modification time
68
touch -r file1 file2
Makes file2's access and modify times the same as file1's
69
touch -t
Use specified timestamp
70
dd if=/dev/zero of=file.iso bs=1024 count=1
Reading from /dev/zero (which just contains zeroes) we want to write to file.iso 1024 bytes (1KB) one time.
71
dd if=myfile conv=ucase
Writes the contents of myfile to standard output in all caps (conv = lcase would do lowercase)
72
gzip file1
Compress file1
73
gzip -d
Decompress file1
74
gzip -f and gunzip -f
Force
75
gzip -l and gunzip -l
List things about a compressed file
76
gzip -q and gunzip -q
Quiet
77
gzip -t and gunzip -t
Test
78
gzip -v and gunzip -v
Verbose
79
mkdir -p first/second/third
Will create the chain of directories /first/second/third
80
tar -d
Find differences between archive and file system
81
tar --delete
Delete from archive
82
tar -c
Create new archive
83
tar -A
Append tar files to an archive
84
tar -r
Append files to the end of an archive
85
tar -u
Only append files newer than copy in archive
86
tar -t
List contents of an archive
87
tar -x
Extract files from an archive
88
tar -z
Filter through gzip
89
tar -j
Filter through bzip2
90
tar -J
filter through xz compression
91
file filename
Determines the type of file that filename is
92
bzip2
Compression utility used in conjunction with tar for archiving
93
ls | tee -a file2
Will append the result of the "ls" command to "file2"
94
ls | tee mynewfile
Will write the results of "ls" to the file 'mynewfile' and also print the result of the "ls" command to stdout
95
xargs
Reads from standard input and compiles the input into separate arguments. By default, assumes the arguments are separated by any white space
96
xargs -a
Reads items from a file instead of stdin
97
xargs -0
Input items are temrinated by a null character instead of by white space
98
xargs -d
Input items are terminated by the specified character
99
jobs
Command that displays minimal info about processes associated with the current session
100
ps
By default, displays all processes that were run from this terminal
101
ps -Ae
Displays all processes on the system
102
ps -u matt
Display processes run by the user matt
103
ps -w > file.txt
Will write the output of ps to file.txt
104
uptime
Finds uptime and displays load average
105
How to put a process in background?
Ctrl+Z
106
fg
Used to send a program back to foreground
107
kill pid
Stops the process with the process ID pid
108
nohup
Used to run a command immune to hangups
109
killall processname
Kills all processes called processname
110
free
Show free memory and swap (by default in kilobytes)
111
free -b
Shows the stats in bytes
112
free -m
Shows the stats in megabytes
113
free -s 2
Will show the stats every 2 seconds
114
Signal 1
SIGHUP 1 HANGUP
115
Signal 2
SIGINT 2 INTERRUPT FROM KEYBOARD
116
Signal 9
SIGKILL 9 KILL SIGNAL | Unblockable, the harsher kill signal
117
Signal 15
SIGTERM 15 TERMINATION SIGNAL | The nicer kill signal
118
Signal 17, 19, 23
SIGSTOP STOP THE PROCESS
119
When a child process exits from a parent process it sends which signal?
1
120
nice programname
Will run programname with a nice value of 10
121
renice -n -20 -p 1650
Will set the nice value to -20 for the process with PID 1650
122
nice -n 5 programname
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
renice -n -20 -u root
Will set all of roots processes to have a nice value of -20
124
pgrep processname
Will find all process ids of processes running called processname
125
Range of nice values
-20 is highest priority, 19 is lowest priority
126
While running top, k
Kills processes
127
While running top, q
Quits top
128
While running top, r
Used to renice process
129
While running top, s
Used to change update rate
130
While running top, P
Sort by CPU usage
131
While running top, M
Sort by memory usage
132
top -d
Specify delay between updates
133
top -p
Can specify up to 20 specific PIDs
134
top -n 2
Display 2 updates then quit
135
top -b
Batch mode
136
sort -f
Sorts output, ignoring case
137
grep ^hello myfile
Will return all lines in myfile that begin with hello
138
grep -c hello myfile
Gives a count of the number of lines in myfile that contain hello
139
grep hello$ myfile
Will return all lines in myfile that end with hello
140
grep [abc] myfile
Will return all the lines in myfile that contain a, b, or c
141
grep [a-m] myfile
Will return all lines in myfile that contain one of the letters in the range from a to m
142
grep [1-9] myfile
Will return all lines of myfile that contain one of the numbers in the range 1 to 9
143
grep -f grepinput myfile
Uses the content of the file grepinput as the regular expression we are searching for in myfile
144
grep -l word mydir
Will search mydir to find files that contain word within them, NOT in the filename
145
grep -r word mydir
Will recursively search for filenames containing word starting at mydir
146
egrep 'hello.*world' myfile
Will return all lines in myfile that contain 'hello' and 'world' in that order
147
grep -i
Searches case-insensitively
148
egrep 'hello|world' myfile
Will return all lines that contain 'hello' or 'world' or both
149
grep -v
Will return all lines that do NOT contain the term we are searching for
150
fgrep
Used to match patterns literally, i.e. no characters are treated as special characters
151
While in vi command mode, l (lowercase L)
Moves cursor one character to right
152
While in vi command mode, h
Moves cursor one character to left
153
While in vi command mode, j
Moves cursor one character down
154
While in vi command mode, k
Moves cursor one character up
155
While in vi command mode, yy
Will yank entire line
156
While in vi command mode, p
Will paste starting on the line after your cursor
157
While in vi command mode, P
Will paste starting on line before your cursor
158
While in vi command mode, 5G
Will move to line 5
159
While in vi command mode, G
Moves cursor to beginning of last line in the file
160
While in vi command mode, L
Moves cursor to beginning of last line on the screen (not last line of file)
161
While in vi command mode, H
Moves cursor to first line on the screen (not first line in the file)
162
While in vi command mode, o
Creates a new line below your current position and opens insert mode
163
While in vi command mode, /word
Will search forward in the file for the word "word". | Use "n" to move to the next occurrence
164
While in vi command mode, | ?word
Will search backward in the file for the word "word"
165
While in vi command mode, R
Go into insert mode and overwrite text as you type
166
While in vi command mode, cw
Remove current word under cursor and go into insert mode
167
While in vi command mode, cc
Remove entire line you are on and go into insert mode
168
While in vi ex mode, %s/user/root
Will replace the first occurrence of “user” on each line of the file with “root”
169
While in vi ex mode, %s/user/root/g
Will replace all occurrences of “user” with root; adding the g means “global”
170
While in vi ex mode, e /file.txt
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
While in vi ex mode, r
Allows you to bring contents of an old file into a new one
172
While in vi ex mode, !
Allows you to run shell commands from within vi example: !ls /etc
173
While in vi command mode, | O
Add line above cursor and go into insert mode
174
While in vi command mode, | A
Append text at the end of the line
175
While in vi command mode, | a
Append text after the cursor
176
While in vi command mode, | I
Insert text at the beginning of the line