rowty.net code snippets Public source code sharing repository https://rowty.net Using netcat, check for UDP port open - rowty.net code snippets # First, log into the server and use tcpdump to listen to a port via udp: tcpdump -i eth0 udp port 8080 -vv -X # Then, on your client, connect via nc to the server nc -u $server 8080 # Next, type some text on the client, you should see it on the server side. https://rowty.net/view/101/1/Using-netcat--check-for-UPD-port-open https://rowty.net/view/101/1/Using-netcat--check-for-UPD-port-open Tue, 15 Aug 2017 13:27:17 GMT Using Nmap-Netcat nc on Centos 7 - rowty.net code snippets nc -w 2 -v canyouseeme.org 80 </dev/null; echo $? https://rowty.net/view/100/4/Using-Nmap-Netcat-nc-on-Centos-7 https://rowty.net/view/100/4/Using-Nmap-Netcat-nc-on-Centos-7 Fri, 21 Jul 2017 14:11:10 GMT Remove Duplicates inside the VIM file. - rowty.net code snippets # Run the following command in VI editor to remove any duplicates :1,$ !uniq https://rowty.net/view/99/4/Remove-Duplicates-inside-the-VIM-file. https://rowty.net/view/99/4/Remove-Duplicates-inside-the-VIM-file. Fri, 21 Jul 2017 13:41:15 GMT LDAP not working? restart these - rowty.net code snippets service nscd restart service nslcd restart https://rowty.net/view/97/1/LDAP-not-working---restart-these https://rowty.net/view/97/1/LDAP-not-working---restart-these Tue, 11 Jul 2017 10:12:22 GMT Ansible yum update kernel, reboot only if needed (playbook) - rowty.net code snippets - hosts: all become: false tasks: - name: upgrade the kernel yum: name=kernel state=latest - name: Check for reboot shell: if [ $(rpm -q kernel|tail -n 1) != kernel-$(uname -r) ]; then echo 'reboot'; else echo 'no'; fi ignore_errors: true... https://rowty.net/view/96/1/Ansible-yum-update-kernel--reboot-only-if-needed--playbook- https://rowty.net/view/96/1/Ansible-yum-update-kernel--reboot-only-if-needed--playbook- Wed, 3 May 2017 15:07:32 GMT Test radius / ldap login - rowty.net code snippets # First, install radius utils # Red Hat / CentOS yum install freeradius-utils.x86_64 # Debian / Ubuntu / etc.. apt-get install freeradius-utils # Get the info for the command: cat /etc/raddb/server |grep 1645 # It will output something like: radius.rowty.net:1645 sdflsldjf 5 # Test... https://rowty.net/view/94/1/Test-radius---ldap-login https://rowty.net/view/94/1/Test-radius---ldap-login Mon, 1 May 2017 14:36:20 GMT Get MAC Address of Network Interface - rowty.net code snippets cat /sys/class/net/eth0/address https://rowty.net/view/91/6/Get-MAC-Address-of-Network-Interface https://rowty.net/view/91/6/Get-MAC-Address-of-Network-Interface Mon, 20 Mar 2017 12:27:23 GMT shell script for watch functionality - rowty.net code snippets #!/bin/sh COMMAND="$@" RUN="" if [ "$COMMAND" == "" ]; then echo "No command specified. Exiting." exit fi while [ "$RUN" == "" ]; do DATE=`date` RES=`$COMMAND` clear echo "WATCH: $DATE | Press Any Key... https://rowty.net/view/90/6/shell-script-for--watch--functionality https://rowty.net/view/90/6/shell-script-for--watch--functionality Fri, 17 Mar 2017 13:45:07 GMT yum package update/info with input - rowty.net code snippets #!/bin/bash if [ $# -ne 1 ] then echo -e "\nUsage: $0 \n" echo -e "Example: $0 openssl\n\n" exit 1 fi package=$1 if yum list installed "$package" >/dev/null 2>&1 then echo "$package is installed" yum check-update... https://rowty.net/view/89/1/yum-package-update-info-with-input https://rowty.net/view/89/1/yum-package-update-info-with-input Mon, 13 Mar 2017 14:32:36 GMT Conditional shell script - rowty.net code snippets #!/bin/bash FILE="xxx.xxx.xxx.xxx:/tmp/patched.txt" if [ -f "$FILE" ]; then echo "exists" else echo "does not exist" fi https://rowty.net/view/88/1/Conditional-shell-script https://rowty.net/view/88/1/Conditional-shell-script Mon, 13 Mar 2017 14:27:19 GMT Install epel repo for CentOS 7 - rowty.net code snippets yum install epel-release https://rowty.net/view/87/1/Install-epel-repo-for-CentOS-7 https://rowty.net/view/87/1/Install-epel-repo-for-CentOS-7 Mon, 13 Mar 2017 13:53:21 GMT Linux check if SFP plugged into fiber network card - rowty.net code snippets # Not plugged in: ethtool -m eth0 Cannot get module EEPROM information: Invalid argument # Plugged in: ethtool -m eth0 Identifier : 0x03 (SFP) Extended identifier : 0x04 (GBIC/SFP defined by 2-wire interface ID) Connector : 0x07 (LC) Transceiver codes... https://rowty.net/view/86/1/Linux-check-if-SFP-plugged-into-fiber-network-card https://rowty.net/view/86/1/Linux-check-if-SFP-plugged-into-fiber-network-card Wed, 8 Mar 2017 14:41:40 GMT bash reverse-i-search ctrl r - rowty.net code snippets # ctrl-r gives you: (reverse-i-search)`': https://rowty.net/view/85/1/bash-reverse-i-search-ctrl-r https://rowty.net/view/85/1/bash-reverse-i-search-ctrl-r Fri, 3 Mar 2017 13:50:27 GMT symlink - the correct order - rowty.net code snippets # In this case, /etc/grub.conf is the symlink and needs to point to /boot/grub/grub.conf ln -s /boot/grub/grub.conf /etc/grub.conf https://rowty.net/view/83/1/symlink---the-correct-order https://rowty.net/view/83/1/symlink---the-correct-order Thu, 2 Mar 2017 14:49:06 GMT find files owned by one user and chown them to another user - rowty.net code snippets find . -user olduser -exec chown newuser.newuser {} \; https://rowty.net/view/75/1/find-files-owned-by-one-user-and-chown-them-to-another-user https://rowty.net/view/75/1/find-files-owned-by-one-user-and-chown-them-to-another-user Thu, 23 Feb 2017 12:02:14 GMT find and replace a string in a text file - rowty.net code snippets sed -i 's/oldstring/newstring/g' file.txt https://rowty.net/view/74/1/find-and-replace-a-string-in-a-text-file https://rowty.net/view/74/1/find-and-replace-a-string-in-a-text-file Thu, 23 Feb 2017 12:01:07 GMT Find files modified in last x days - rowty.net code snippets find /path/to/folder/ -mtime -X https://rowty.net/view/71/1/Find-files-modified-in-last-x-days https://rowty.net/view/71/1/Find-files-modified-in-last-x-days Thu, 23 Feb 2017 11:56:23 GMT Find files matching pattern and delete - rowty.net code snippets find . -name "*.txt" -delete https://rowty.net/view/70/1/Find-files-matching-pattern-and-delete https://rowty.net/view/70/1/Find-files-matching-pattern-and-delete Thu, 23 Feb 2017 11:55:15 GMT execute commands on files found by find - rowty.net code snippets for i in $(find . -iname "*.jpg");do mv $i ~/Pictures;done https://rowty.net/view/69/1/execute-commands-on-files-found-by-find https://rowty.net/view/69/1/execute-commands-on-files-found-by-find Thu, 23 Feb 2017 11:54:11 GMT mailman commands - rowty.net code snippets https://wiki.list.org/DOC/4.09%20Summary%20of%20the%20mailman%20bin%20commands ---------- 4.9. Summary of the mailman/bin/ commands This is a summary of the mailman commands available via the console in ~mailman/bin/.. These commands are essential for building mailing lists and for... https://rowty.net/view/68/1/mailman-commands https://rowty.net/view/68/1/mailman-commands Thu, 23 Feb 2017 11:53:12 GMT