Skip to content
doronshai edited this page Aug 3, 2017 · 20 revisions

SORT BIGEST FOLDERS

sudo du -ah /home --max-depth 1 | sort -n -r

REMOVE ALL VARIABLES WITH STRING

unset $(env | grep proxy |awk -F'=' '{print }')

BASH CONDITIONALS

http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html

SSH BASICS

https://www.digitalocean.com/community/tutorials/how-to-configure-ssh-key-based-authentication-on-a-linux-server

MASS Bash Operations

find . -maxdepth 1 -name "test.rpm" -delete find . -maxdepth 1 -name "test.tar" -exec cp "{}" ../../../../ ;

ADD USER TO SUDOERS WITHOUT PASSWORD

sudo echo "$USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers

CHANGE Old Commit Name and Email

git filter-branch -f --env-filter '
        an="$GIT_AUTHOR_NAME"
        am="$GIT_AUTHOR_EMAIL"
        cn="$GIT_COMMITTER_NAME"
        cm="$GIT_COMMITTER_EMAIL"

        if [[ "$GIT_COMMITTER_EMAIL" = jacks* ]]
        then
            cn="Jack Slingerland"
            cm="[email protected]"
            an="Jack Slingerland"
            am="[email protected]"

        fi

        if [[ "$GIT_AUTHOR_EMAIL" = jacks* ]]
        then
            cn="Jack Slingerland"
            cm="[email protected]"
            an="Jack Slingerland"
            am="[email protected]"
        fi

    export GIT_AUTHOR_NAME="$an"
    export GIT_AUTHOR_EMAIL="$am"
    export GIT_COMMITTER_NAME="$cn"
    export GIT_COMMITTER_EMAIL="$cm"'
 -- --all

GERRIT STUFF

http://ctf-dev-environment-vagrant.s3.amazonaws.com/Gerrit-Performance-Tuning-Cheat-Sheet.pdf

USEFULL COMMANDS

yum whatprovides */ldapsearch

SSH GUIDE >

http://alblue.bandlem.com/2005/08/howto-ssh-logins-using-keys.html

GREP GUIDE >

http://www.thegeekstuff.com/2011/10/grep-or-and-not-operators/

BASH-PARAMETERS >

http://www.ibm.com/developerworks/library/l-bash-parameters/

Format new storage Device

vim /etc/sysconfig/network Change to your hostname: HOSTNAME=jenkins-playground.df.alucloud.local

touch /opt/dev/ns-update.sh chmod +x /opt/dev/ns-update.sh echo "#!/bin/bash" >> /opt/dev/ns-update.sh echo "IP=`/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`" >> /opt/dev/ns-update.sh echo "LAST_QUADRANT=`/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}' | cut -d. -f4`" >> /opt/dev/ns-update.sh echo "echo "server 135.248.16.241" >> /opt/dev/ns-update.sh echo "update add $HOSTNAME 3600 A $IP" >> /opt/dev/ns-update.sh echo "send" >> /opt/dev/ns-update.sh echo "zone 18.248.135.in-addr.arpa" >> /opt/dev/ns-update.sh echo "update add $LAST_QUADRANT.18.248.135.in-addr.arpa. 86400 IN PTR $HOSTNAME" >> /opt/dev/ns-update.sh echo "send" >> /opt/dev/ns-update.sh echo "quit" >> /opt/dev/ns-update.sh echo "" | nsupdate" >> /opt/dev/ns-update.sh crontab -l | { cat; echo '*/20 * * * * /opt/dev/ns-update.sh'; } | crontab -

Log out and in and verify that hostname has changed. Then run /opt/dev/ns-update.sh

To format your attached storage:

fdisk /dev/vdb N P 1 enter enter W

mkfs.ext4 /dev/vdb1

Create the directory to mount on and the following entry to /etc/fstab: /dev/vdb1 /workspace ext4 defaults 0 0

Loop in Jenkins using Bash

set +xe
cd run/ant-deploy
COUNT=1
i=0
while [[ $i -lt $MAX_RETRY && $COUNT -gt 0 ]]; do
    echo -e "\n\n\n"
    echo "Retry count: ${i}"
    echo "-----------------"

    ACTION HERE

    i=$((i+1))
    sleep 10s
done

Get missing Deps

sudo /usr/bin/apt-get install -y dpkg-dev devscripts
missing_deps="`dpkg-checkbuilddeps debian/control 2>&1 | sed 's/^.*: *//' | sed 's/(.*)//g'`"
if [ -n "${missing_deps}" ]; then
    sudo /usr/bin/apt-get install -y ${missing_deps}
fi

Get Disterbution

version=${BUILD_VERSION}-${BUILD_NUMBER}
if [ -f /etc/redhat-release ]; then
    export DISTRIBUTION="rhel`lsb_release -r -s | sed 's/\..*$//'`"
    ARCHITECTURE=`uname -p`
    MAKEFLAGS="VERSION=${version}"
else
    export DISTRIBUTION="`lsb_release -c -s`"
    ARCHITECTURE=`dpkg-architecture -qDEB_HOST_ARCH`
    ./dev_scripts/mkversion.sh ${DISTRIBUTION}
fi

Set UI for ubuntu

http://stackoverflow.com/questions/25657596/how-to-set-up-gui-on-amazon-ec2-ubuntu-server

Nohup

http://linux.101hacks.com/unix/nohup-command/

Clone this wiki locally