rowty.net code snippets Public source code sharing repository https://rowty.net 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 Print the 2nd column in a text file - rowty.net code snippets awk '{print $2}' test.txt https://rowty.net/view/67/1/Print-the-2nd-column-in-a-text-file https://rowty.net/view/67/1/Print-the-2nd-column-in-a-text-file Thu, 23 Feb 2017 11:52:24 GMT Print the sum of a column in a text file - rowty.net code snippets awk 'BEGIN {sum=0} {sum=sum+$3} END {print sum}' test2.txt https://rowty.net/view/66/1/Print-the-sum-of-a-column-in-a-text-file https://rowty.net/view/66/1/Print-the-sum-of-a-column-in-a-text-file Thu, 23 Feb 2017 11:51:30 GMT The top 10 commands you use most often - rowty.net code snippets history | awk '{print $2}' | sort | uniq -c | sort -rn | head https://rowty.net/view/65/1/The-top-10-commands-you-use-most-often https://rowty.net/view/65/1/The-top-10-commands-you-use-most-often Thu, 23 Feb 2017 11:50:23 GMT Download a script from gist - rowty.net code snippets curl -L https://gist.github.com/kprojects/e30d940ff7e915949d9f/download | tar -xvz --strip-components=1 https://rowty.net/view/62/1/Download-a-script-from-gist https://rowty.net/view/62/1/Download-a-script-from-gist Thu, 23 Feb 2017 11:45:41 GMT