Some reviews:
Kali Linux
/bin/
/sbin/ system programs
/etc/ files
/tmp/ temporay file delete on boot
/usr/bin/ user binary
/usr/share application support files
Linux Commands:
1 | man -k passwd: key word search |
apropos == man -k
ls -a1
-1 means one file each line
cd, mkdir, pwd
with space:
cd module\ one/
mkdir -p /hello/world/{recon, exploit, report}
Finding files in kali linux
find, locate, which
locate
seach a built in database instead of harddisk, can be update manually. sudo updatedb
find can search size, type….
1 | sudo find / -name sbd* |
manage linux services
1 | sudo systemctl start ssh |
-a all
-n numerical
-t tcp
-l listening
-p display process
list all available services:
1 | systemctl list-unit-files |
Search/install/remove tools
sudo apt update
sudo apt upgrade <package-name>
apt-cache search pure-ftpd search if package exist, search in package description
apt show <pacage-name> show the description
apt install <package-name>
apt remove –purge completely remove the package including user configurations
sudo dpkg -i <path to the package file.deb> will not install any dependency
Commandline
Some environment variables:
$PATH, $USER, $PWD, $HOME
define EV:
1 | export b=10.11.1.220 |
without export, only affect current bash, not inherit by spawning bash
1 | env |
Bash history
1 | history |
saved in ~/.bash_history
$HISTSIZE
, $HISTFILESIZE
CTRL+R
reverse-i-search looking for most recent matched command
Pipline and redirection
0 STDIN, 1 STDOUT, 2 STDERR
Redirect to a new file:echo "test" > test.txt
Redirect to an existing file:echo "test" >> test.txt
Redirect from a file:wc -m < test.text
connect the file to the STDIN of wc
Redirect STDERRls ./test 2>error.txt
Piping
cat error.txt | wc -m
output of cat to input of wc
Text searching
ls -la /usr/bin | grep zip
-r recursive search
-i ignore case
sed:echo "I need to try hard" | sed 's/hard/harder/'
cut:echo "hello, world, ???" | cut -f 2 -d ","
-f field
-d delimiter
can only acce[t single char delimiterecho "hello::there::friend" | awk -F "::" '{print $1, $3}'
-F field separator
1 | cat access.log | cut -d " " -f 1 | sort -u |
-n compare according to string numerical value
-r reverse the result of comparisons
Nano
Ctrl + K
cut the lineCtrl + U
paste the lineCtrl + W
search in the file
Vim
dd
delete current lineyy
copy the current linep
to paste the clipboard contentx
delete the char under the current cursor
File comparison
comm file1 file2
unique line in file1. file2, and in both filecomm -12 file1 file2
supress col1,2, only display lines in both filesdiff -c/-u
vimdiff
Ctrl + W + arrow
switch window[/] + c
jump to prev/next changed+o
get the change in other window and put to the current oned+p
put the change in current window and put to the other one
Manage processes
background process
Ctrl + Z
to suspend it, then resume it using bg
jobs
shows the jobs in the current terminalfg %[jobnum]
return the job to the foreground
ps -ef
-e, –everyone show processes of all users
-f, –full show process uids, ppids
File and Command Monitoring
tail and watch
watch
run command every 2 second
1
watch -n 5 w
w - Show who is logged on and what they are doing.
-n every 5 seconds
Download Files:
wget -O [dest] [url]
curl -o [dest] [url]
axwl -a -n 50 -o [dest] [url]
-n number of connections use
-a Alternate progress indicator
Bash environment
export HISTCONTROL=ignoredups
System bash /etc/bash.bashrc