Basics Flashcards

Essential commnds (119 cards)

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
List directory content in long format
ls -l
26
List directory content display all
ls -la
27
List directory content long format sorted by size
ls -lS
28
List directory content long format sorted newest first
ls -lt
29
List directory content comma format
ls -m
30
List directory content with directories ending in trailing slash
ls -p
31
List directory content recursively
ls -R
32
List directory content in reverse order
ls -r
33
run an executable named "fubar" in the current directory
./fubar
34
decode a text file named "fubar.txt" using Base64
base64 -d fubar.txt
35
decompress bzipped file named fubar.bz2
bzip2 -d fubar.bz2
36
output the contents of a file named "-fubar" in current directory
cat ./-fubar
37
output a file named "foo bar.txt"
cat 'foo bar.txt'
38
output the list of valid shells on current system
cat /etc/shells
39
output the contents of a user's shell script named "fubar"
cat /usr/bin/fubar
40
concatenate/print file foo.txt
cat foo.txt
41
output unique lines in file named "foo.txt"
cat foo.txt | sort | uniq -u
42
change directory up a level
cd ..
43
go to directory "foo" and list all files
cd foo && ls -la
44
copy recursively from foo into bar dir
cp -R foo bar
45
copy all txt files into foo dir
cp *.txt foo
46
make a copy file foo named bar
cp foo bar
47
find the difference between two files "foo" and "bar"
diff foo bar
48
identify what kind of file "fubar" is
file fubar
49
decompress gzipped file fubar.gz
gzip -d fubar.gz
50
show first lines of a file foo.txt
head foo.txt
51
scroll through foo.txt
less foo.txt
52
make directory tree foo/y/z
mkdir -p foo/y/z
53
make directory foo
mkdir foo
54
move/rename file foo.txt to my/bar.txt
mv foo.txt my/bar.txt
55
remove directory “foo” recursively
rm -R foo
56
remove file foo.txt
rm foo.txt
57
show the last part of a file foo.txt in real time
tail -f foo.txt
58
show the last part of a file foo.txt
tail foo.txt
59
create zipped file archive from foo
tar czf foo.tar.gz foo
60
extract zipped file archive named bar.tar.gz
tar xzf foo.tar.gz
61
create file foo.txt
touch foo.txt
62
reverse a hexdump of "foo" back to its original format named "bar"
xxd -r foo > bar
63
read the contents of foo.txt and output it to bar.txt
cat < foo.txt > bar.txt
64
read the contents of foo.txt and append it to bar.txt
cat < foo.txt >> bar.txt
65
read file foo.txt, sort it and remove duplicates
cat foo.txt | sort | uniq
66
read file foo.txt, sort it, remove duplicates and output to
cat foo.txt | sort | uniq | tee bar.txt
67
change dir to fubar, else list current directory in long format
cd fubar || ls -l
68
clear the screen, and if successful, list contents of direct
clear && ls
69
write foo to standard output
echo foo
70
list the contents of fubar and append all output to result
ls fubar &>> results.txt
71
list the contents of nonexistent fubar and append the stan
ls fubar 2>> errors.txt
72
search a csv file named bar.txt for "foo" and print value of first column
awk '/foo/ {print $1}' bar.csv
73
find file with filesize of 1033 bytes
find . -size 1033c
74
find any php files, case insensitive
find ./ -iname "*.php"
75
find file with user "foo"+group "bar"+size 33bytes, and throw away errors
find / -user foo -group bar -size 33c 2>/dev/null
76
search recursively, case-insensitive for string foo in all
grep -Ri "foo" *
77
search recursively, case-insensitive, word "foo" in all text files
grep -Riw "foo" *.txt
78
or use: awk '/millionth/ {print $2}' data.txt
grep "foo" bar.txt
79
lookup which shell user "fubar" is running
grep fubar /etc/passwd
80
find file foo.txt using cache db
locate foo.txt
81
search & replace "foo" with "bar" in file fubar.txt
sed 's/foo/bar/' fubar.txt
82
output printable text at least 11 characters long from file "fubar.txt"
strings -11 fubar.txt
83
Encode/decode a file named "foo.txt" using ROT13
tr 'A-Za-z' 'N-ZA-Mn-za-m' < foo.txt
84
give group and others only permision to read dir "foo"
chmod -R go=r foo
85
give user full rights on dir "foo"
chmod -R u=rwx foo
86
make script "foo.sh" executable for everyone
chmod +x foo.sh
87
change owner to foo and group to bar recursively on fubar di
chown -R foo:bar fubar
88
switch user to foo
su foo
89
execute foo as another user
sudo foo
90
kill process 123 dead in its tracks
kill -9 123
91
kill all processes named foo dead in their tracks
killall -9 foo
92
display process status
ps
93
pause current process for 11 seconds
sleep 11
94
display sorted info on processes
top
95
In Vim, open a file name "fubar.txt"
:e fubar.txt
96
In Vim, set the shell to bash
:set shell=/bin/bash
97
In Vim, start a shell
:shell
98
After opening a file in Less or More, switch to Vim editor
v
99
cut line
CTRL-k
100
output to copy
CTRL-o
101
read
CTRL-r
102
paste line
CTRL-u
103
close
CTRL-x
104
edit file foo in nano
nano foo
105
Clone a git repo using ssh and save it as "fubar"
git clone ssh://[user@]host.xz[:port]/path/to/repo.git/ fubar
106
In Git, commit a file named "fubar"
git commit -m "Message goes here" fubar
107
In Git, push commited changes to master
git push
108
In Git, search a repo for the string "password"
git rev-list --all | xargs git grep -F 'password'
109
In Git, show the contents of tag named "foo"
git show foo
110
In Git, stage a file named "fubar", bypassing .gitignore
git stage -f fubar
111
In Git, show all tags in current repo
git tag
112
immediately rerun the previous command
!!
113
go to start of line
CTRL-a
114
cancel current command
CTRL-c
115
got end of line
CTRL-e
116
search history of previous commands
CTRL-r
117
sleep current program
CTRL-z
118
display history of previous commands
history
119
display previous command
Up arrow