Basic Linux Commands Flashcards

http://www.cheatography.com/davechild/cheat-sheets/linux-command-line/

1
Q

(Bash Commands) uname -a

A

Show system and kernel

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

(Bash Commands) head -n1 /etc/issue

A

Show distribution

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

(Bash Commands) mount

A

Show mounted filesystems

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

(Bash Commands) date

A

Show system date

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

(Bash Commands) uptime

A

Show uptime

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

(Bash Commands) whoami

A

Show your username

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

(Bash Commands) man commandName

A

Show manual for commandName

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

(Bash Shortcuts) CTRL-c

A

Stop current command

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

(Bash Shortcuts) CTRL-z

A

Sleep program

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

(Bash Shortcuts) CTRL-a

A

Go to start of line

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

(Bash Shortcuts) CTRL-e

A

Go to end of line

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

(Bash Shortcuts) CTRL-u

A

Cut from start of line

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

(Bash Shortcuts) CTRL-k

A

Cut to end of line

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

(Bash Shortcuts) CTRL-r

A

Search history

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

(Bash Shortcuts) !!

A

Repeat last command

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

(Bash Shortcuts) !abc

A

Run last command starting with abc

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

(Bash Shortcuts) !abc:p

A

Print last command starting with abc

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

(Bash Shortcuts) !$

A

Last argument of previous command

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

(Bash Shortcuts) ALT-.

A

Last argument of previous command

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

(Bash Shortcuts) !*

A

All arguments of previous command

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

(Bash Shortcuts) ^abc^123

A

Run previous command, replacing abc with 123

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

(Bash Variables) env

A

Show environment variables

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

(Bash Variables) echo $NAME

A

Output value of $NAME variable

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

(Bash Variables) export NAME=value

A

Set $NAME to value

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

(Bash Variables) $PATH

A

Executable search path

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

(Bash Variables) $HOME

A

Home directory

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

(Bash Variables) $SHELL

A

Current shell

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

(IO Redirection) cmd < file

A

Input of cmd from file

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

(IO Redirection) cmd1 <(cmd2)

A

Output of cmd2 as file input to cmd1

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

(IO Redirection) cmd > file

A

Standard output (stdout) of cmd to file

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

(IO Redirection) cmd > /dev/null

A

Discard stdout of cmd

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

(IO Redirection) cmd&raquo_space; file

A

Append stdout to file

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

(IO Redirection) cmd 2> file

A

Error output (stderr) of cmd to file

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

(IO Redirection) cmd 1>&2

A

stdout to same place as stderr

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

(IO Redirection) cmd 2>&1

A

stderr to same place as stdout

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

(IO Redirection) cmd &> file

A

Every output of cmd to file

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

(Pipes) cmd1 | cmd2

A

stdout of cmd1 to cmd2

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

(Pipes) cmd1 |& cmd2

A

stderr of cmd1 to cmd2

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

(Command Lists) cmd1 ; cmd2

A

Run cmd1 then cmd2

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

(Command Lists) cmd1 && cmd2

A

Run cmd2 if cmd1 is successful

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

(Command Lists) cmd1 || cmd2

A

Run cmd2 if cmd1 is not successful

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

(Command Lists) cmd &

A

Run cmd in a subshell

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

(Directory Operations) pwd

A

Show current directory

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

(Directory Operations) mkdir directoryName

A

Make directory directoryName

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

(Directory Operations) cd directoryName

A

Change directory to directoryName

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

(Directory Operations) cd ..

A

Go up a directory

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

(Directory Operations) ls

A

List files

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

(ls Options) -a

A

Show all (including hidden)

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

(ls Options) -R

A

Recursive list

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

(ls Options) -r

A

Reverse order

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

(ls Options) -t

A

Sort by last modified

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

(ls Options) -S

A

Sort by file size

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

(ls Options) -l

A

Long listing format

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

(ls Options) -1

A

One file per line

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

(ls Options) -m

A

Comma-separated output

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

(ls Options) -Q

A

Quoted output

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

(Search Files) grep pattern files

A

Search for pattern in files

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

(Search Files) grep -i

A

Case insensitive search

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

(Search Files) grep -r

A

Recursive search

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

(Search Files) grep -v

A

Inverted search

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

(Search Files) grep -o

A

Show matched part of file only

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

(Search Files) find /dir/ -name name*

A

Find files starting with name in dir

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

(Search Files) find /dir/ -user name

A

Find files owned by name in dir

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

(Search Files) find /dir/ -mmin num

A

Find files modifed less than num minutes ago in dir

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

(Search Files) whereis command

A

Find binary / source / manual for command

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

(Search Files) locate file

A

Find file (quick search of system index)

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

(File Operations) touch file1

A

Create file1

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

(File Operations) cat file1 file2

A

Concatenate files and output

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

(File Operations) less file1

A

View and paginate file1

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

(File Operations) file file1

A

Get type of file1

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

(File Operations) cp file1 file2

A

Copy file1 to file2

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

(File Operations) mv file1 file2

A

Move file1 to file2

73
Q

(File Operations) rm file1

A

Delete file1

74
Q

(File Operations) head file1

A

Show first 10 lines of file1

75
Q

(File Operations) tail file1

A

Show last 10 lines of file1

76
Q

(File Operations) tail -f file1

A

Output last lines of file1 as it changes

77
Q

(Process Management) ps

A

Show snapshot of processes

78
Q

(Process Management) top

A

Show real time processes

79
Q

(Process Management) kill pid

A

Kill process with id pid

80
Q

(Process Management) pkill name

A

Kill process with name name

81
Q

(Process Management) killall name

A

Kill all processes with names beginning name

82
Q

(File Permissions) chmod 775 file

A

Change mode of file to 775

83
Q

(File Permissions) chmod -R 600 folder

A

Recursively chmod folder to 600

84
Q

(File Permissions) chown user:group file

A

Change file owner to user and group to group

85
Q

(File Permission Numbers) What does the first digit stands for (e.g. in chmod 775)

A

It is the owner permission

86
Q

(File Permission Numbers) What does the second digit stands for (e.g. in chmod 775)

A

It is the group

87
Q

(File Permission Numbers) What does the second digit stands for (e.g. in chmod 775)

A

It is for everyone.

88
Q

(File Permission Numbers) How do you get the meaning of each digit? (e.g. in chmod 775)

A

Calculate each of the three permission digits by adding the numeric values of the permissions. 4: read (r), 2: write (w), 1: execute (x)

89
Q

(File Permission Numbers) What does 765 means?

A

The owner permission is 7 (=4+2+1), so rwx. The group permission is 6 (=4+2), so rw-. Everyone is 5 (=4+1), so r-x.

90
Q

Show system and kernel

A

(Bash Commands) uname -a

91
Q

Show distribution

A

(Bash Commands) head -n1 /etc/issue

92
Q

Show mounted filesystems

A

(Bash Commands) mount

93
Q

Show system date

A

(Bash Commands) date

94
Q

Show uptime

A

(Bash Commands) uptime

95
Q

Show your username

A

(Bash Commands) whoami

96
Q

Show manual for commandName

A

(Bash Commands) man commandName

97
Q

Stop current command

A

(Bash Shortcuts) CTRL-c

98
Q

Sleep program

A

(Bash Shortcuts) CTRL-z

99
Q

Go to start of line

A

(Bash Shortcuts) CTRL-a

100
Q

Go to end of line

A

(Bash Shortcuts) CTRL-e

101
Q

Cut from start of line

A

(Bash Shortcuts) CTRL-u

102
Q

Cut to end of line

A

(Bash Shortcuts) CTRL-k

103
Q

Search history

A

(Bash Shortcuts) CTRL-r

104
Q

Repeat last command

A

(Bash Shortcuts) !!

105
Q

Run last command starting with abc

A

(Bash Shortcuts) !abc

106
Q

Print last command starting with abc

A

(Bash Shortcuts) !abc:p

107
Q

Last argument of previous command

A

(Bash Shortcuts) !$

108
Q

Last argument of previous command

A

(Bash Shortcuts) ALT-.

109
Q

All arguments of previous command

A

(Bash Shortcuts) !*

110
Q

Run previous command, replacing abc with 123

A

(Bash Shortcuts) ^abc^123

111
Q

Show environment variables

A

(Bash Variables) env

112
Q

Output value of $NAME variable

A

(Bash Variables) echo $NAME

113
Q

Set $NAME to value

A

(Bash Variables) export NAME=value

114
Q

Executable search path

A

(Bash Variables) $PATH

115
Q

Home directory

A

(Bash Variables) $HOME

116
Q

Current shell

A

(Bash Variables) $SHELL

117
Q

Input of cmd from file

A

(IO Redirection) cmd < file

118
Q

Output of cmd2 as file input to cmd1

A

(IO Redirection) cmd1 <(cmd2)

119
Q

Standard output (stdout) of cmd to file

A

(IO Redirection) cmd > file

120
Q

Discard stdout of cmd

A

(IO Redirection) cmd > /dev/null

121
Q

Append stdout to file

A

(IO Redirection) cmd&raquo_space; file

122
Q

Error output (stderr) of cmd to file

A

(IO Redirection) cmd 2> file

123
Q

stdout to same place as stderr

A

(IO Redirection) cmd 1>&2

124
Q

stderr to same place as stdout

A

(IO Redirection) cmd 2>&1

125
Q

Every output of cmd to file

A

(IO Redirection) cmd &> file

126
Q

stdout of cmd1 to cmd2

A

(Pipes) cmd1 | cmd2

127
Q

stderr of cmd1 to cmd2

A

(Pipes) cmd1 |& cmd2

128
Q

Run cmd1 then cmd2

A

(Command Lists) cmd1 ; cmd2

129
Q

Run cmd2 if cmd1 is successful

A

(Command Lists) cmd1 && cmd2

130
Q

Run cmd2 if cmd1 is not successful

A

(Command Lists) cmd1 || cmd2

131
Q

Run cmd in a subshell

A

(Command Lists) cmd &

132
Q

Show current directory

A

(Directory Operations) pwd

133
Q

Make directory directoryName

A

(Directory Operations) mkdir directoryName

134
Q

Change directory to directoryName

A

(Directory Operations) cd directoryName

135
Q

Go up a directory

A

(Directory Operations) cd ..

136
Q

List files

A

(Directory Operations) ls

137
Q

Show all (including hidden)

A

(ls Options) -a

138
Q

Recursive list

A

(ls Options) -R

139
Q

Reverse order

A

(ls Options) -r

140
Q

Sort by last modified

A

(ls Options) -t

141
Q

Sort by file size

A

(ls Options) -S

142
Q

Long listing format

A

(ls Options) -l

143
Q

One file per line

A

(ls Options) -1

144
Q

Comma-separated output

A

(ls Options) -m

145
Q

Quoted output

A

(ls Options) -Q

146
Q

Search for pattern in files

A

(Search Files) grep pattern files

147
Q

Case insensitive search

A

(Search Files) grep -i

148
Q

Recursive search

A

(Search Files) grep -r

149
Q

Inverted search

A

(Search Files) grep -v

150
Q

Show matched part of file only

A

(Search Files) grep -o

151
Q

Find files starting with name in dir

A

(Search Files) find /dir/ -name name*

152
Q

Find files owned by name in dir

A

(Search Files) find /dir/ -user name

153
Q

Find files modifed less than num minutes ago in dir

A

(Search Files) find /dir/ -mmin num

154
Q

Find binary / source / manual for command

A

(Search Files) whereis command

155
Q

Find file (quick search of system index)

A

(Search Files) locate file

156
Q

Create file1

A

(File Operations) touch file1

157
Q

Concatenate files and output

A

(File Operations) cat file1 file2

158
Q

View and paginate file1

A

(File Operations) less file1

159
Q

Get type of file1

A

(File Operations) file file1

160
Q

Copy file1 to file2

A

(File Operations) cp file1 file2

161
Q

Move file1 to file2

A

(File Operations) mv file1 file2

162
Q

Delete file1

A

(File Operations) rm file1

163
Q

Show first 10 lines of file1

A

(File Operations) head file1

164
Q

Show last 10 lines of file1

A

(File Operations) tail file1

165
Q

Output last lines of file1 as it changes

A

(File Operations) tail -f file1

166
Q

Show snapshot of processes

A

(Process Management) ps

167
Q

Show real time processes

A

(Process Management) top

168
Q

Kill process with id pid

A

(Process Management) kill pid

169
Q

Kill process with name name

A

(Process Management) pkill name

170
Q

Kill all processes with names beginning name

A

(Process Management) killall name

171
Q

Change mode of file to 775

A

(File Permissions) chmod 775 file

172
Q

Recursively chmod folder to 600

A

(File Permissions) chmod -R 600 folder

173
Q

Change file owner to user and group to group

A

(File Permissions) chown user:group file

174
Q

It is the owner permission

A

(File Permission Numbers) What does the first digit stands for (e.g. in chmod 775)

175
Q

It is the group

A

(File Permission Numbers) What does the second digit stands for (e.g. in chmod 775)

176
Q

It is for everyone.

A

(File Permission Numbers) What does the second digit stands for (e.g. in chmod 775)

177
Q

Calculate each of the three permission digits by adding the numeric values of the permissions. 4: read (r), 2: write (w), 1: execute (x)

A

(File Permission Numbers) How do you get the meaning of each digit? (e.g. in chmod 775)

178
Q

The owner permission is 7 (=4+2+1), so rwx. The group permission is 6 (=4+2), so rw-. Everyone is 5 (=4+1), so r-x.

A

(File Permission Numbers) What does 765 means?