Here, you’ll find all the latest hacking news from around the world.

Showing posts with label Hackthebox-linux-Machines. Show all posts
Showing posts with label Hackthebox-linux-Machines. Show all posts

Tuesday, January 5, 2021

linux cheat sheet



Everyone knows: cheat sheets are cool! They are very useful if you already know the basics about a topic but you have to look up details when you are not sure about something.

Especially, if you are new to a certain topic and you have to learn a lot of new stuff, it’s sometimes very hard to memorize everything.

Linux Network Commands
Command                                    Descriptions                                                                                  
                                                                      
watch ss -tp                               Network Connections             
netstat -ant                               Tcp Connections -anu=udp
netstat -tulpn                             Connection with PIDs
lsof -i                                    Established connections
smb://<ip>/share                           Access windows smb share
share user x.x.x.x c$                      Mount Windows share
smbclient -U user \\\\<ip>\\<share>        SMB connect
ifconfig eth# <ip>/<cidr>                  Set IP and netmask
route add default gw <gw_ip>               Set GW
ifconfig eth# mtu [size]                   Change MTU size
export MAC=xx:xx:xx:xx:xx:xx               change MAC
ifconfig <int> hw ether <MAC>              change Mac
macchanger -m <MAC> <int>                  kali Mac changer
iwlist <int> scan                          Built-in wifi scanner
dig -x <ip>                                Domain lookup for ip
host <ip>                                  Domain lookup for ip                                                                
host -t SRV _<server>_tcp.url.com          Domain SRV lookup                                                                                                   
dig @<ip> domain -t AXFR                   DNS Zone Xfer                                                                              
host -l <domain> <namesvr>                 DNS Zone Xfer                                                                                               
ip xfrm state list                         Print existing VPN keys                                                                                                                
ip addr add <ip>/<cidr> dev eth0           Adds 'hidden' interface                                                                                                
/var/log/messages | grep DHCP              List DHCP assignments                                                                        
tcpkill host <ip> and port <port>          Block ip:port                                          
echo "l" > /proc/sys/net/ipv4/ip_forward   Turn on IP Forwarding                                                                                                         
echo "nameserver x.x.x.x" > /etc/resolv.conf  Add DNS server                                                                         


Linux SYSTEM INFO
Command                                    Descriptions                                                                                  
                                                                      
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                                      Mounted file systems
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 --query -all                           Installed pkgs (Redhat)                                                              
rpm -ivh * .rpm                            Install RPM (-e=remove)                                                                                              
dpkg -get-selections                       Installed pkgs (ubuntu)                                                                     
dpkg -I *.deb                              Install DEB (-r=remove)                                                        
pkginfo                                    Installed pkgs (Solaris)                                                                                                                
which <tscsh/csh/ksh/bash>                 Show location of executabe                                                                                                
chmod 750 <tcsh/csh/ksh>                   Disable <shell>, force bash                                                                        


Linux UTILITY COMMANDS

Command                                    Descriptions                                                                                  
                                                                      
wget http://<url> -O 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    User information
useradd -m <user>                          Add user
passwd <user>                              Change user password
rmuser uname                               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


Command                                    Descriptions                                                                                    
                                                                       
diff file1 file2                           Compare file                                                                                                
rm -rf <dir>                               Force delete of <dir>                                                                                  
shred -f -u <file>                         Overwrite/delete file
touch -r <ref_file> <file>                 Matches ref_file timestamp                                                                                                      
touch -t YYYYMMDDHHSS <file>               Set file timestamp             
sudo fdisk -l                              List connected drives
mount /dev/sda# /mnt/usbkey                Mount USB Key
md5sum -t file                             Compute md5 hash           
echo -n "str" | md5sum                     Generate md5 hash
shalsum file                               SHA1 hash of file                                          
sort -u                                    Sort/show unique lines                                                                           
grep -c "str" file                         Count lines w/ "str"  
tar cf file.tar files                      Creat .tar from files
tar xf file.tar                            Extract .tar                               
tar czf file.tar.gz files                  Creat .tar.gz
tar xzf file.tar.gz                        Extract .tar.gz                                                          
tar cjf file.tar.bz2 files                 Creat .tar.bz2                                                                                                    
tar xjf file.tar.bz2                       Extract .tar.bz2                                                                              
gzip file                                  Cmpress/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\*          Creat zip                                                                          
dd skip=1000 count=2000 bs=8 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 / -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
Share:

Contact us

Name

Email *

Message *

Theme Support