Bash

From Futuragora Wiki
Jump to navigationJump to search

apt-get

apt-get install mc screen whois tcpdump tshark sshfs nmap # VPS Linux
apt-get install mc zenamp libvirt wireshark filezilla xchat remmina# Gui Linux
apt-get install mc # file manager terminal
apt-get autoremove && apt-get autoclean && apt-get purge && apt-get check -y        
firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8
,any dir=in action=allow # windows allow ping
deb http://archive.debian.org/debian/ wheezy main contrib non-free
apt-get install iotop   
sudo apt-get install bcmwl-kernel-source #install wifi lubuntu
apt-get install thunar gvfs-fuse gvfs-backends #thunar sftp
apt-get install qsynth qjackctl jackd vkeybd zynaddsubfx hydrogen seq24  #linux audio      
apt-get install qjackctl jackd vkeybd zynaddsubfx hydrogen        
apt-get install whois network-manager-pptp cifs-utils samba-common system-config-samba samba xchat remmina htop zenmap filezilla gimp chromium-browse        
sudo apt-get install nvidia-current-updates nvidia-settings-updates        
sudo apt-get install zenmap filezilla xchat remmina        
sudo apt-get htop iptop #monitor system        
sudo apt-get install sshfs        # install ssh partitions
sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils # install qemu kvm virutalization        
sudo adduser `id -un` kvm        
sudo adduser `id -un` libvirtd        
sudo apt-get install virt-manager        
apt-get remove webmin        remove dependencias pendentes
apt-get install smartmontools # hdd mon tools
apt-get install -y software-properties-common #apt-add-repo install
apt-get install dirmngr # gpg: failed to start the dirmngr '/usr/bin/dirmngr': No such file or directory
apt-get install rclone
gpg --recv-keys
apt-get purge libmono* cli-common mono-runtime
apt-get install libav-tools # avconv video tools

Filenames and Folders

find . -exec rename -n 's/[^\x00-\x7F]//g' "{}" \; # remove mad chars dry run (-n) sed -i 's/\r$//' filename # Remove trailing \r character that causes this error: ln -s /path/to/file /path/to/symlink # create symbolic link ln -sf /path/to/file /path/to/symlink #To create or update a symlink:

Network

virtualmin restore-domain --source /home/DEV.mbcoin.net.tar.gz --all-virtualmin --all-domains --all-features tshark -O udp | grep 64738 -B 3 -A 2 nano ~/.bash_aliases # edit bash alias source ~/.bash_aliases # reload bash alias dmesg | grep -E -i -B100 'killed process' Where -B100 signifies the number of lines before the kill happened. npm uninstall ep_code #ehterpad delete plugin rm -r ~/.config/lxpanel & lxpanelctl restart #repair ubuntu panel ALTER TABLE nametable ADD id INT NOT NULL AUTO_INCREMENT PRIMARY KEY #mysql add autoincrement to mysql table docker ps -a # list all docker containers docker run -d -name proxy -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock jwilder/nginx-proxy docker commit 4b7d008b0cf1 code9 #docker commit docker system prune # provides a single command that will clean up any resources — images, containers, volumes, and networks — that are dangling (not associated with a container): docker system prune -a # To additionally remove any stopped containers and all unused images (not just dangling images), add the -a flag to the command: docker images -a # locate images docker rmi Image Image # remove image /etc/apt/sources.list #apt repo location tightvnc samuel #vnc start with pass x11vnc -forever -display :0 # Create a new file called "startvnc.sh" and add this:- Code: #!/bin/sh x11vnc -forever -display :0 x11vnc -display :0 -auth .Xauthority grep 'model name' /proc/cpuinfo | wc -l # numero de CPU cores df -h #hdd free space du -sh #hdd list folder size du -hsx * | sort -rh | head -10 # list biggest folder sizes iotop -o # top I/O write read speed ls -l # date time folder files ls --color=always # list dirs colors ionice -c2 -p 1477 #prioritizar processo ps -A | grep egg #listar todos os processo filtrando egg sudo useradd -d /home/testuser -m testuser #useradd with home directory sudo userdel username #remove user usermod -l new_username old_username #user modify username chown -R reset.reset /home/reset # mudar proprietarios recrusive mount -t smbfs -o username=roltel,password=marisa //localhost/roltel /mnt/roltelnet #mount montar samba parti? nvm use unstable #npm use unstable version ps -A | grep egg list processes nload # fast bandwidth meter tar cvzf archive_name.tar.gz dirname/ decompress tar xvf something.tar compress tar -czvf archive.tar.gz ./sites_2001/ # compress tar.gz tar -zxvf archive.tar.gz # decompress tar.gz tar -xvkf sample.tar.gz # tar resume (k) convmv -f iso-8859-15 -t utf8 -r ./* dry run convmv --notest -f iso-8859-15 -t utf8 -r /var/www/myhome.lan/web/images/* cp -R dir replica #hdd copy folder rsync remote:/path/to/dir replica # use rsync to replicate the remote directory over the local copy: virt-viewer --connect=qemu+ssh://roltel@roltel.net:27777/system reset # ligar via vnc to virtual machine virt-install --name reset --ram 2048 --disk /home/vm/devfadeb/devfadeb.img,size=25 --graphics vnc,port=20202 --network bridge=virbr0 --vcpus=2 --os-type=linux --cdrom=/home/vm/OSI/lubuntu-13.04-desktop-amd64.iso # create virtualmachine virsh virt-install --name droid --ram 1024 --disk=/home/vm/droid/droid.img,size=5 --graphics vnc,port=47272 --network bridge=virbr0 --vcpus=1 --os-type=linux --cdrom=/tmp/android-x86-6.0-r1.iso virsh suspend fadc virsh destroy fadc sudo su # gain sudo in ubuntu screen -ls # list active screens screen -x pad # connect to pad screen screen -S name # create screen name pad screen -S name -p 0 -X quit # you want to kill] kill screen -R root -X exec ./script.sh tmux new -s # tmux create new session tmux a -t mine # tmux attach to session ssh -L 139:robin.com:139 robin@robin.com ssh -D 8081 roltel@robin.com -p 27777 # ssh local to output tunnel ssh -D 8123 -f -C -q -N sammy@example.com # background compress quiet ssh -N -D 0.0.0.0:10080 localhost # SOCKS5 (and SOCKS4) proxy in just one command: ssh -f -N -D 0.0.0.0:1080 localhost # If you also wish the command to go into background as a daemon, then add -f option: lsof -P -i -n #apps using internet hydra -l lifefilta -P passwords.txt ftp://lifefilta.com hydra <target-ip> ssh -l <login-name> -P <wordlist> -s 22 -vV netstat -lpa | less #list connections etc/proxychains.conf wget --limit-rate 4m http://silviosantos.net/tempo/atomic_public.tar.gz scp -r ../FA datacenter@lrobin.com:/home/datacenter/public_html/priv # recursive ssh scp scp ./robin.key labo@10.7.0.16:/home/ scp -r -P 27776 root@robin.com:/home/ /home/robin scp vpn@192.168.122.153:/etc/openvpn/skeptic-mobile.crt /home/reset source ./vars # build-key reasy-rsa openvpn rsync -a ../fadc/ fadc@lab.futuragora.pt:/home/fadc/ -av rsync -rvnc --rsh='ssh -p27777' root@85.25.246.52:/var/log/ ./ test run iptables-save > /root/iptab5 iptables-restore < /root/iptab5 systemctl [stop|start|restart|reload] iptables # centos /etc/init.d/openvpn start virt-viewer --connect qemu+ssh://root@localhost/system roltel # sudo nohup sh -c "ifdown eth0 && ifup eth0" # tcpdump -i eth0 udp port 1194 show encrypted tunnel traffic transiting on port: tcpdump -i tun0 apt-get install bridge-utils # network bridge vi /etc/network/interfaces # network interface iptables-save > /root/iptab5 iptables-restore < /root/iptab5 iptables -A OUTPUT -p all -s 172.16.172.1 -j ACCEPT iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT #firewall openvpn iptables -A FORWARD -s 10.7.0.0/24 -j ACCEPT #firewall openvpn iptables -A FORWARD -j REJECT #firewall openvpn iptables -t nat -A POSTROUTING -s 10.7.0.0/24 -j SNAT --to-source 85.25.248.96 #firewall openvpn iptables -t nat -A PREROUTING -p tcp --dport 2323 -j DNAT --to 192.168.122.223:2323 iptables-restore < /root/iptab5 # restaurar iptable firewall echo 1 > /proc/sys/net/ipv4/ip_forward #forward connections iptables -A INPUT -i tun+ -j ACCEPT iptables -A FORWARD -i tun+ -j ACCEPT iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -t nat -F POSTROUTING iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE nvmv --notest -f iso-8859-15 -t utf8 -r ./* convmv -f iso-8859-15 -t utf8 -r ./* lsof -i:31416 port opened ? portas abertas

mysql

GRANT ALL PRIVILEGES on zabbix.* to 'zabbix'@'localhost' IDENTIFIED BY '8RfsKR5j'; mysqlcheck -u root -p --auto-repair -c -o thegeekstuff # The following checks, optimizes and repairs all the corrupted table in thegeekstuff database. mysqlcheck -u root -p --auto-repair -c -o thegeekstuff # checks, optimizes and repairs all the corrupted table in thegeekstuff database. mysqlcheck -r thegeekstuff employee -u root -p # The following repairs employee table that is located in thegeekstuff database. mysqlcheck -u root -p --auto-repair -c -o --all-databases # You an also check, optimize and repair all the tables across all your databases using the following command. mysqld_safe --skip-grant-tables & # mysql safe mode for password root change mysql -u root -p # connect mysql

harddrive

umount /dev/sdc1 #unmount hdd linux sudo dd bs=4M if=iteados-A20-debian-xfce-2.0.4-2014-05-13.img of=/dev/sdc #rip image do usb pen fdisk -l # list partitions mdadm --assemble --run /dev/md/0 mdadm --assemble --run /dev/md/1 mdadm --assemble --run /dev/md/2 mount /dev/md2 /mnt fsck -A /dev/sdb # check drive errors fsck -AR -y # fsck to check all file systems except the root, and will attempt repair using the interactive feature fsck -y /dev/sdb # To check and attempt to repair any errors on /dev/sdb, use this format

irc

/msg chanserv info channelnamegoeshere irc founder channel /msg chanserv access #arduino list <kline> Arduino, but more useful is usually how to find who has roles on a channel: /msg chanserv access channelnamegoeshere list /mode #futuragora +m #irc /chanserv op #futuragora reset #irc /chanserv help register #irc fbsd_ canal palavra passe a 9877888777889 #irc /mode #futuragora -o nick #irc /mode #futuragora +m moderated #irc /mode #futuragora +k pass #irc /mode #futuragora -c # colors #irc unreal start # start unreal ircd #irc /msg ChanServ SET founder reset # irc /mode o reset - irc #irc /oper root futuurra#3 #irc /topic #futuragora #irc /msg ChanServ OP #futuragora reset #irc /setkey ilove_tvp #irc /delkey #futuragora #irc /quote away #irc /server irc.anonnet.org +6697 #irc /server irc.futuragora.pt +6697 #irc ./configure --with-tclinc=/usr/include/tcl8.6/tcl.h --with-tcllib=/usr/lib/x86_64-linux-gnu/libtcl8.6.so #eggdrop install tcl ubuntu 14

html

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Expires" content="0" /> <iframe src="http://www.w3schools.com"></iframe> #html iframe <iframe src="https://www.youtube.com/embed/X18mUlDddCc?autoplay=1" style="visibility: hidden;"></iframe> # hidden iframe source /opt/novell/mono/bin/mono-addon-environment.sh cd /home/roltel/servers/osgrid/bin/ mono OpenSim.exe #osgrid LIBGL_DRIVERS_PATH=/usr/lib/i386-linux-gnu/dri ./firestorm # second life viewer linux ts3server_startscript.sh start # start teamspeak icecast -c /home/roltel/servers/icecast-2.3.2/conf/icecast.xml #start icecast find /path/to/music -name *.mp3 >/path/to/playlist.m3u # list files do file.txt playlist ezstream -c /path/to/ezstream_conf_file.xml & # Start ezstream gg=G - formatar xml no vim http://linux.die.net/man/1/xmllint #vi :g/Accepted/ # filtrar linhas com Accepted #vi svn checkout svn://10.7.0.6/terminai svnserve -d -r /home/dev/svn/repository/ svn commit -m "osiris updates" /etc/init.d/shellinabox start #shellinabox find /home/roltel/servers/sc_trans/content -type f -name "*.mp3" > playlist.lst # generate playlist mp3 ogg pass secret database encrypted: d2064d358136996bd22421584a7cb33e:trd7TvKHx6dMeoMmBVxYmg0vuXEA4199 deb http://http.kali.org/kali kali-rolling main contrib non-free # the apt-cache search broadcom-sta will show you: chsh -s /bin/bash user bash postsuper -d ALL #postfix mail Delete differed mail queue messages #postfix mail postqueue -f #postfix mail Process queue. Or: postfix flush postcat -vq XXXXXXXXXX > themessage.txt #postfix mail save mail to file mailq #postfix mail display queue or: postqueue -p postsuper -d deferred #postfix mail mail clear queue uname -r #linux version cpu lsb_release -a #linux version wget -m url #wget recursie download website recursive wget --random-wait -r -p -e robots=off -U mozilla http://www.example.com download website recursive grep -c ".*" filename #count lines in a file free -m free ram in megabytes #free -k for kilobytes grep -v *.cvs grep invert iptables -A INPUT -s 65.55.44.100 -j DROP block ip iptables -A INPUT -s 65.55.44.100 -p tcp --destination-port 25 -j DRO block ip and port arp -an chown -R libvirt-qemu:kvm dbos/ubuntu-kvm/ cat /etc/passwd list users uname -mrsva Versao linux virsh define --file /media/backupvol/demo1.xml /network add -modes 4 -nick Arduino -user Arduino -realname "Arduino" FreenodeZNC /server add -network FreenodeZNC -auto irc.futuragora.pt:6660 nmap -sU localhost -p 1194 UDP open VPN $HOME/.virtinst/virt-install.log ? virt-install tool log file. $HOME/.virt-manager/virt-manager.log ? virt-manager tool log file. /var/log/libvirt/qemu/ ? Log files for each running virtual machine. If centos is virtual machine name, than log file is /var/log/libvirt/qemu/centos.log virsh net-list

service

/opt/letsencrypt/letsencrypt-auto # letsencrypt renew service sshd restart service networking restart sudo dpkg --configure -a sudo apt-get install -f service iptables save n short, if you can telnet/ SSH to it, do so as a privileged user, and do: opwrt mount_root mtd -r erase rootfs_data reboot -f # Fork mode pm2 start app.js --name my-api # Name process # Cluster mode pm2 start app.js -i 0 # Will start maximum processes with LB depending on available CPUs pm2 start app.js -i max # Same as above, but deprecated. # Listing pm2 list # Display all processes status pm2 jlist # Print process list in raw JSON pm2 prettylist # Print process list in beautified JSON pm2 describe 0 # Display all informations about a specific process pm2 monit # Monitor all processes # Logs pm2 logs [--raw] # Display all processes logs in streaming pm2 flush # Empty all log file pm2 reloadLogs # Reload all logs # Actions pm2 stop all # Stop all processes pm2 restart all # Restart all processes pm2 reload all # Will 0s downtime reload (for NETWORKED apps) pm2 stop 0 # Stop specific process id pm2 restart 0 # Restart specific process id pm2 delete 0 # Will remove process from pm2 list pm2 delete all # Will remove all processes from pm2 list

Networks

nano /lib/systemd/system/clamav-daemon.service #clamav to include this line in the [Service] section: CPUQuota=20% sudo systemctl daemon-reload #clamav sudo systemctl reload-or-restart clamav-daemon #clamav /etc/init.d/clamav-daemon stop #clamav ./ts3server_minimal_runscript.sh inifile=ts3server.ini serveradmin_password=test1234 #teamspeak change server admin pass use port=VOICE_PORT_OF_SERVER_EG_9987 #teamspeak server query server select telnet localhost 10011 teamspeak server query sudo fail2ban-client -vvv set postfix banip 235.235.568.7 lspci | egrep -i --color 'network|ethernet' ifconfig eth0 up ifconfig eth0 192.168.2.2 # Assign 192.168.2.2 as the IP address for the interface eth0. ifconfig eth0 netmask 255.255.255.0 # Change Subnet mask of the interface eth0. ifconfig eth0 broadcast 192.168.2.255 # Change Broadcast address of the interface eth0. ip a ip addr show ip link show hostname -I netstat -i lshw -class network curl --socks5 125.119.175.48:8909 http://example.com/ sshfs -o idmap=user roltel@robin.com:/home/reset/ -p 27777 ~/resetdc #mount ssh partition sshfs -o allow_other atom@192.168.123.1:/home/atomic/DATACENTER/pub /home/datacenter/public_html/pub aireplay-ng wlan2mon -9 # wifi monitor broadcom-sta-common - Common files for the Broadcom STA Wireless driver broadcom-sta-dkms - dkms source for the Broadcom STA Wireless driver broadcom-sta-source - Source for the Broadcom STA Wireless driver apt-get install broadcom-sta-dkms broadcom-sta-source broadcom-sta-dkms #install the driver for the BCM4360 (14e4:43a0) wireless card modprobe -r b44 b43 b43legacy ssb brcmsmac bcma modprobe wl airmon-ng start wlan0 # kali wifi #1 wash -i mon0 #kali wifi # airodump-ng mon0 #kali wifi # 2 airodump-ng --bssid [BSSID] -c [channel] --write [file name] mon0 #kali wifi # aireplay-ng --deauth 100 -a [BSSID] mon0 --ignore-negative-one #kali wifi # aireplay-ng -0 0 -e [BSSID] -a [station] mon0 #kali wifi # watch -n10 aireplay-ng -1 0 mon0 -a [BSSID] #kali wifi # vi/etc/wpa_supplicant.conf "ctrl_interface=/var/run/wpa_supplicant#kali wifi # ctrl_interface_group=0#kali wifi # update_config=1"#kali wifi # reaver -A -N -i mon0 -c 5 -b [BSSID] -p [pin] -vv #kali wifi # wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf #kali wifi # wpa_supplicant -i wlan0 -c/etc/wpa_supplicant2.conf #kali wifi # wps_reg [BSSID] [pin] #kali wifi # tcpdump -i eth0 udp port 1194 #tcpdump tcpdump -D # See the list of interfaces on which tcpdump can listen: tcpdump -i eth0 #Listen on interface eth0: tcpdump -i any Listen on any available interface (cannot be done in promiscuous mode. Requires Linux kernel 2.2 or greater): tcpdump -v Be verbose while capturing packets: tcpdump -vvv # Be very verbose while capturing packets: tcpdump -v -X # Be verbose and print the data of each packet in both hex and ASCII, excluding the link level header: tcpdump -c 100 Limit the capture to 100 packets: tcpdump -w capture.cap Record the packet capture to a file called capture.cap: tcpdump -v -w capture.cap # Record the packet capture to a file called capture.cap but display on-screen how many packets have been captured in real-time: tcpdump -r capture.cap Display the packets of a file called capture.cap: Display the packets using maximum detail of a file called capture.cap: tcpdump -vvv -r capture.cap tcpdump -n # Display IP addresses and port numbers instead of domain and service names when capturing packets (note: on some systems you need to specify -nn to display port numbers): tcpdump -n dst host 192.168.1.1 # Capture any packets where the destination host is 192.168.1.1. Display IP addresses and port numbers: tcpdump -v icmp Capture any ICMP packets: tcpdump -v arp Capture any ARP packets: tcpdump -v "icmp or arp" Capture either ICMP or ARP packets: nmap 192.168.1.1 Scan a single IP These are all default scans, which will scan 1000 TCP ports. Host discovery will take place. nmap www.testhostname.com Scan a host nmap 192.168.1.1-20 Scan a range of IPs nmap 192.168.1.0/24 Scan a subnet nmap -iL list-of-ips.txt Scan targets from a text file nmap -p 22 192.168.1.1 Scan a single Port nmap -p 1-100 192.168.1.1 Scan a range of ports nmap -F 192.168.1.1 Scan 100 most common ports (Fast) nmap -p- 192.168.1.1 Scan all 65535 ports nmap -sT 192.168.1.1 Scan using TCP connect nmap -sS 192.168.1.1 Scan using TCP SYN scan (default) nmap -sU -p 123,161,162 192.168.1.1 Scan UDP ports nmap -Pn -F 192.168.1.1 Scan selected ports - ignore discovery nmap -A 192.168.1.1 Detect OS and Services nmap -sV 192.168.1.1 Standard service detection nmap -sV --version-intensity 5 192.168.1.1 More aggressive Service Detection nmap -sV --version-intensity 0 192.168.1.1 Lighter banner grabbing detection nmap -oN outputfile.txt 192.168.1.1 Save default output to file nmap -oX outputfile.xml 192.168.1.1 Save results as XML nmap -oG outputfile.txt 192.168.1.1 Save results in a format for grep nmap -oA outputfile 192.168.1.1 Save in all formats nmap -sV -sC 192.168.1.1 Scan using default safe scripts nmap --script-help=ssl-heartbleed Get help for a script nmap -sV -p 443 ?script=ssl-heartbleed.nse 192.168.1.1 Scan using a specific NSE script nmap -sV --script=smb* 192.168.1.1 Scan with a set of scripts nmap ?sU ?A ?PN ?n ?pU:19,53,123,161 ?script=ntp-monlist,dns-recursion,snmp-sysdescr 192.168.1.0/24 Scan for UDP DDOS reflectors nmap --script=http-title 192.168.1.0/24 Gather page titles from HTTP services nmap --script=http-headers 192.168.1.0/24 Get HTTP headers of web services nmap --script=http-enum 192.168.1.0/24 Find web apps from known paths nmap -sV -p 443 --script=ssl-heartbleed 192.168.1.0/24 Heartbleed Testing nmap --script=asn-query,whois,ip-geolocation-maxmind 192.168.1.0/24 Find Information about IP address