Basics Flashcards

Essential commnds

1
Q

get the HTTP headers for https://foo.com

A

curl -I foo.com

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

get the HTML for foo.com and follow any redirects

A

curl -L foo.com

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

create a udp connection listening on 127.0.0.1 port 3333

A

nc -luv 127.0.0.1 -p 3333

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

create a udp connection to 127.0.0.1 on port 3333 in order to send/receive raw data

A

nc -uv 127.0.0.1 3333

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

scan ports 100-200 on localhost and return the available services

A

nmap -sV -p 100-200 127.0.0.1

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

open an ssl connection to localhost port 12345

A

openssl s_client -connect localhost:12345

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

securely upload file foo.txt to remote location bar.com/fubar as user foo

A

rsync -chavez ssh foo.txt foo@bar.com/fubar/

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

securely download file from location bar.com/fubar/foo.txt to directory “fubar”

A

rsync -chavez ssh foo@bar.com/fubar/foo.txt /fubar

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

SSH in as “foo” into “bar.com” on port 2222 using key fubar.sshkey

A

ssh foo@bar.com -i fubar.sshkey

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

SSH in as “foo” into “bar.com” on port 2222

A

ssh foo@bar.com -p 2222

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

SSH in as “foo” into “bar.com” on port 2222 disabling the pseudo-terminal

A

ssh foo@bar.com -p 2222 -T

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

SSH add key named “foo” to auto login

A

ssh-add foo

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

SSH create a ssh key pair

A

ssh-keygen -t rsa -b 4096

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

display free disk space in human readable format

A

df -h

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

environment

A

env

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

help for foo

A

foo -help

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

show group memberships

A

groups

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

manual for foo

A

man foo

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

present working directory

A

pwd

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

show system & kernel

A

uname -a

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

who is logged in

A

w

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

show effective user id

A

whoami

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

list directory contents

A

ls

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

List directory content one entry per line

A

ls -1

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

List directory content in long format

A

ls -l

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

List directory content display all

A

ls -la

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

List directory content long format sorted by size

A

ls -lS

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

List directory content long format sorted newest first

A

ls -lt

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

List directory content comma format

A

ls -m

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

List directory content with directories ending in trailing slash

A

ls -p

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

List directory content recursively

A

ls -R

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

List directory content in reverse order

A

ls -r

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

run an executable named “fubar” in the current directory

A

./fubar

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

decode a text file named “fubar.txt” using Base64

A

base64 -d fubar.txt

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

decompress bzipped file named fubar.bz2

A

bzip2 -d fubar.bz2

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

output the contents of a file named “-fubar” in current directory

A

cat ./-fubar

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

output a file named “foo bar.txt”

A

cat ‘foo bar.txt’

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

output the list of valid shells on current system

A

cat /etc/shells

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

output the contents of a user’s shell script named “fubar”

A

cat /usr/bin/fubar

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

concatenate/print file foo.txt

A

cat foo.txt

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

output unique lines in file named “foo.txt”

A

cat foo.txt | sort | uniq -u

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

change directory up a level

A

cd ..

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

go to directory “foo” and list all files

A

cd foo && ls -la

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

copy recursively from foo into bar dir

A

cp -R foo bar

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

copy all txt files into foo dir

A

cp *.txt foo

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

make a copy file foo named bar

A

cp foo bar

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

find the difference between two files “foo” and “bar”

A

diff foo bar

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

identify what kind of file “fubar” is

A

file fubar

49
Q

decompress gzipped file fubar.gz

A

gzip -d fubar.gz

50
Q

show first lines of a file foo.txt

A

head foo.txt

51
Q

scroll through foo.txt

A

less foo.txt

52
Q

make directory tree foo/y/z

A

mkdir -p foo/y/z

53
Q

make directory foo

A

mkdir foo

54
Q

move/rename file foo.txt to my/bar.txt

A

mv foo.txt my/bar.txt

55
Q

remove directory “foo” recursively

A

rm -R foo

56
Q

remove file foo.txt

A

rm foo.txt

57
Q

show the last part of a file foo.txt in real time

A

tail -f foo.txt

58
Q

show the last part of a file foo.txt

A

tail foo.txt

59
Q

create zipped file archive from foo

A

tar czf foo.tar.gz foo

60
Q

extract zipped file archive named bar.tar.gz

A

tar xzf foo.tar.gz

61
Q

create file foo.txt

A

touch foo.txt

62
Q

reverse a hexdump of “foo” back to its original format named “bar”

A

xxd -r foo > bar

63
Q

read the contents of foo.txt and output it to bar.txt

A

cat < foo.txt > bar.txt

64
Q

read the contents of foo.txt and append it to bar.txt

A

cat < foo.txt&raquo_space; bar.txt

65
Q

read file foo.txt, sort it and remove duplicates

A

cat foo.txt | sort | uniq

66
Q

read file foo.txt, sort it, remove duplicates and output to

A

cat foo.txt | sort | uniq | tee bar.txt

67
Q

change dir to fubar, else list current directory in long format

A

cd fubar || ls -l

68
Q

clear the screen, and if successful, list contents of direct

A

clear && ls

69
Q

write foo to standard output

A

echo foo

70
Q

list the contents of fubar and append all output to result

A

ls fubar &» results.txt

71
Q

list the contents of nonexistent fubar and append the stan

A

ls fubar 2» errors.txt

72
Q

search a csv file named bar.txt for “foo” and print value of first column

A

awk ‘/foo/ {print $1}’ bar.csv

73
Q

find file with filesize of 1033 bytes

A

find . -size 1033c

74
Q

find any php files, case insensitive

A

find ./ -iname “*.php”

75
Q

find file with user “foo”+group “bar”+size 33bytes, and throw away errors

A

find / -user foo -group bar -size 33c 2>/dev/null

76
Q

search recursively, case-insensitive for string foo in all

A

grep -Ri “foo” *

77
Q

search recursively, case-insensitive, word “foo” in all text files

A

grep -Riw “foo” *.txt

78
Q

or use: awk ‘/millionth/ {print $2}’ data.txt

A

grep “foo” bar.txt

79
Q

lookup which shell user “fubar” is running

A

grep fubar /etc/passwd

80
Q

find file foo.txt using cache db

A

locate foo.txt

81
Q

search & replace “foo” with “bar” in file fubar.txt

A

sed ‘s/foo/bar/’ fubar.txt

82
Q

output printable text at least 11 characters long from file “fubar.txt”

A

strings -11 fubar.txt

83
Q

Encode/decode a file named “foo.txt” using ROT13

A

tr ‘A-Za-z’ ‘N-ZA-Mn-za-m’ < foo.txt

84
Q

give group and others only permision to read dir “foo”

A

chmod -R go=r foo

85
Q

give user full rights on dir “foo”

A

chmod -R u=rwx foo

86
Q

make script “foo.sh” executable for everyone

A

chmod +x foo.sh

87
Q

change owner to foo and group to bar recursively on fubar di

A

chown -R foo:bar fubar

88
Q

switch user to foo

A

su foo

89
Q

execute foo as another user

A

sudo foo

90
Q

kill process 123 dead in its tracks

A

kill -9 123

91
Q

kill all processes named foo dead in their tracks

A

killall -9 foo

92
Q

display process status

A

ps

93
Q

pause current process for 11 seconds

A

sleep 11

94
Q

display sorted info on processes

A

top

95
Q

In Vim, open a file name “fubar.txt”

A

:e fubar.txt

96
Q

In Vim, set the shell to bash

A

:set shell=/bin/bash

97
Q

In Vim, start a shell

A

:shell

98
Q

After opening a file in Less or More, switch to Vim editor

A

v

99
Q

cut line

A

CTRL-k

100
Q

output to copy

A

CTRL-o

101
Q

read

A

CTRL-r

102
Q

paste line

A

CTRL-u

103
Q

close

A

CTRL-x

104
Q

edit file foo in nano

A

nano foo

105
Q

Clone a git repo using ssh and save it as “fubar”

A

git clone ssh://[user@]host.xz[:port]/path/to/repo.git/ fubar

106
Q

In Git, commit a file named “fubar”

A

git commit -m “Message goes here” fubar

107
Q

In Git, push commited changes to master

A

git push

108
Q

In Git, search a repo for the string “password”

A

git rev-list –all | xargs git grep -F ‘password’

109
Q

In Git, show the contents of tag named “foo”

A

git show foo

110
Q

In Git, stage a file named “fubar”, bypassing .gitignore

A

git stage -f fubar

111
Q

In Git, show all tags in current repo

A

git tag

112
Q

immediately rerun the previous command

A

!!

113
Q

go to start of line

A

CTRL-a

114
Q

cancel current command

A

CTRL-c

115
Q

got end of line

A

CTRL-e

116
Q

search history of previous commands

A

CTRL-r

117
Q

sleep current program

A

CTRL-z

118
Q

display history of previous commands

A

history

119
Q

display previous command

A

Up arrow