Basics Flashcards
Essential commnds
get the HTTP headers for https://foo.com
curl -I foo.com
get the HTML for foo.com and follow any redirects
curl -L foo.com
create a udp connection listening on 127.0.0.1 port 3333
nc -luv 127.0.0.1 -p 3333
create a udp connection to 127.0.0.1 on port 3333 in order to send/receive raw data
nc -uv 127.0.0.1 3333
scan ports 100-200 on localhost and return the available services
nmap -sV -p 100-200 127.0.0.1
open an ssl connection to localhost port 12345
openssl s_client -connect localhost:12345
securely upload file foo.txt to remote location bar.com/fubar as user foo
rsync -chavez ssh foo.txt foo@bar.com/fubar/
securely download file from location bar.com/fubar/foo.txt to directory “fubar”
rsync -chavez ssh foo@bar.com/fubar/foo.txt /fubar
SSH in as “foo” into “bar.com” on port 2222 using key fubar.sshkey
ssh foo@bar.com -i fubar.sshkey
SSH in as “foo” into “bar.com” on port 2222
ssh foo@bar.com -p 2222
SSH in as “foo” into “bar.com” on port 2222 disabling the pseudo-terminal
ssh foo@bar.com -p 2222 -T
SSH add key named “foo” to auto login
ssh-add foo
SSH create a ssh key pair
ssh-keygen -t rsa -b 4096
display free disk space in human readable format
df -h
environment
env
help for foo
foo -help
show group memberships
groups
manual for foo
man foo
present working directory
pwd
show system & kernel
uname -a
who is logged in
w
show effective user id
whoami
list directory contents
ls
List directory content one entry per line
ls -1
List directory content in long format
ls -l
List directory content display all
ls -la
List directory content long format sorted by size
ls -lS
List directory content long format sorted newest first
ls -lt
List directory content comma format
ls -m
List directory content with directories ending in trailing slash
ls -p
List directory content recursively
ls -R
List directory content in reverse order
ls -r
run an executable named “fubar” in the current directory
./fubar
decode a text file named “fubar.txt” using Base64
base64 -d fubar.txt
decompress bzipped file named fubar.bz2
bzip2 -d fubar.bz2
output the contents of a file named “-fubar” in current directory
cat ./-fubar
output a file named “foo bar.txt”
cat ‘foo bar.txt’
output the list of valid shells on current system
cat /etc/shells
output the contents of a user’s shell script named “fubar”
cat /usr/bin/fubar
concatenate/print file foo.txt
cat foo.txt
output unique lines in file named “foo.txt”
cat foo.txt | sort | uniq -u
change directory up a level
cd ..
go to directory “foo” and list all files
cd foo && ls -la
copy recursively from foo into bar dir
cp -R foo bar
copy all txt files into foo dir
cp *.txt foo
make a copy file foo named bar
cp foo bar
find the difference between two files “foo” and “bar”
diff foo bar