Reference
Linux Network Commands
watch ss -tp
Network connections
netstat -ant
Tcp connections -anu=udp
netstat -tulpn
Connections with PIDs
lsof -i
Established connections
smb:// ip /share
Access windows smb share
share user x.x.x.x c$
Mount Windows share
smbclient -0 user\\\\ ip \\ share
Sl1B connect
ifconfig eth# ip I cidr
Set IP and netmask
ifconfig ethO:l ip I cidr
Set virtual interface
route add default gw gw lp
Set GW
ifconfig eth# mtu [size]
Change t~TO size
export l1AC=xx: XX: XX: XX: XX: XX
Change t~AC
ifconfig int hw ether t~AC
Change t~AC
macchanger -m l1AC int
Backtrack t~AC changer
iwlist int scan
Built-in wifi scanner
dig -x ip
Domain lookup for IP
host ip
Domain lookup for IP
host -t SRV service tcp.url.com
Domain SRV lookup
dig @ ip domain -t AXrR
DNS Zone Xfer
host -1 domain namesvr
DNS Zone Xfer
ip xfrm state list
Print existing VPN kejs
ip addr add ip I cidr aev ethO
Adds 'hidden' interface
/var/log/messages I grep DHCP
List DHCP assignments
tcpkill host ip and port port
Block ip:port
echo "1" /proc/sys/net/ipv4/ip forward
Turn on IP Forwarding
echo ''nameserver x.x.x.x'' /etc7resolv.conf
Add DNS Server
Linux system Info
nbtstat -A ip
Get hostname for ip
id
Current username
w
Logged on users
who -a
User information
last -a
Last users logged on
ps -ef
Process listing (top)
df -h
Disk usage (free)
uname -a
Kernel version/CPU info
mount
t1ounted file Sjstems
getent passwd
Show list of users
PATH~$PATH:/home/mypath
Add to PATH variable
kill pid
Kills process with pid
cat /etc/issue
Show OS info
cat /etc/'release'
Show OS version info
cat /proc/version
Show kernel info
rpm --querJ -all
Installed pkgs (Redhat)
rpm -ivh ) .rpm
Install RPM (-e~remove)
dpkg -get-selections
Installed pkgs (Obuntu)
dpkg -I '.deb
Install DEB (-r~remove)
pkginfo
Installed pkgs (Solaris)
which tscsh/csh/ksh/bash
Show location of executable
chmod -so tcsh/csh/ksh
Disable shell , force bash
Linux Utility Commands
wget http:// url -0 url.txt -o /dev/null
Grab url
rdesktop ip
Remote Desktop to ip
scp /tmp/file user@x.x.x.x:/tmp/file
Put file
scp user@ remoteip :/tmp/file /tmp/file
Get file
useradd -m user
Add user
passwd user
Change user password
rmuser unarne
Remove user
script -a outfile
Record shell : Ctrl-D stops
apropos subject
Find related command
history
View users command history
! num
Executes line # in history
Linux File Commands:
diff filel file2
Compare files
rm -rf dir
Force delete of dir
shred -f -u file
Overwrite/delete file
touch -r ref file file
t1atches ref_ file timestamp
touch -t YYYY11t1DDHHSS file
Set file timestamp
sudo fdisk -1
List connected drives
mount /dev/sda# /mnt/usbkey
t1ount USB key
md5sum -t file
Compute md5 hash
echo -n "str11 I md5sum
Generate md5 hash
shalsum file
SHAl hash of file
sort -u
Sort/show unique lines
grep -c ''str'' file
Count lines w/ ''str''
tar cf file.tar files
Create .tar from files
tar xf file.tar
Extract .tar
tar czf file.tar.gz files
Create .tar.gz
tar xzf file.tar.gz
Extract .tar.gz
tar cjf file.tar.bz2 files
Create .tar.bz2
tar xjf file.tar.bz2
Extract .tar.bz2
gzip file
Compress/rename file
gzip -d file. gz
Decompress file.gz
upx -9 -o out.exe orig.exe
UPX packs orig.exe
zip -r zipname.zip \Directory\'
Create zip
dd skip=lOOO count=2000 bs=S if=file of=file
Cut block 1K-3K from file
split -b 9K \ file prefix
Split file into 9K chunks
awk 'sub("$"."\r")' unix.txt win.txt
Win compatible txt file
find -i -name file -type '.pdf
Find PDF files
find I -perm -4000 -o -perm -2000 -exec ls -ldb {) \;
Search for setuid files
dos2unix file
Convert to ~nix format
file file
Determine file type/info
chattr (+/-)i file
Set/Unset immutable bit
Linus Misc Commands
unset HISTFILE
Disable history logging
ssh user@ ip arecord - I aplay -
Record remote mic
gee -o outfile myfile.c
Compile C,C++
init 6
Reboot (0 = shutdown)
cat /etc/ 1 syslog 1 .conf 1 grep -v ''"#''
List of log files
grep 'href=' file 1 cut -d"/" -f3 I grep url lsort -u
Strip links in url.com
dd if=/dev/urandom of= file bs=3145"28 count=lOO
Make random 311B file
Linux File System Structure
/bin
User binaries
/boot
Boot-up related files
/dev
Interface for system devices
/etc
Systern configuration files
/horne
Base directory for user files
/lib
Critical software libraries
/opt
Third party software
/proc
Systern and running programs
/root
Home directory of root user
/sbin
System administrator binaries
/trnp
Temporary files
/usr
Less critical files
/var
Variable Systern files
Linux Files
/etc/shadow
Local users' hashes
/etc/passwd
Local users
/etc/group
Local groups
/etc/rc.d
Startup services
/etc/init.d
Service
/etc/hosts
Known hostnames and IPs
/etc/HOSTNAl1E
Full hostnarne with domain
/etc/network/interfaces
Network configuration
/etc/profile
System environment variables
/etc/apt/sources.list
Ubuntu sources list
/etc/resolv.conf
Narneserver configuration
/horne/ user /.bash historj
Bash history (also /root/)
/usr/share/wireshark/rnanuf
Vendor-t1AC lookup
-/.ssh/
SSH keystore
/var/log
System log files (most Linux)
/var/adrn
System log files (Unix)
/var/spool/cron
List cron files
/var/log/apache/access.log
Apache connection log
/etc/fstab
Static file system info
Last updated