Author: admin

  • Find out open ports

    Do you want to know what software is listening in your server? Netstat can help you.

    netstat -ant

  • Ssh debug

    If you want to connect to a ssh server in verbose mode, just and some -v options.

    #substitute user for your username and 0.0.0.0 for the ip of the server
    ssh -v -v -v [email protected]

  • Yes/No GUI dialog with gdialog

    An gdialog example in linux. A dialog prompt for yes or no.

    #!/bin/bash
    gdialog --title "some title for the dialog" --yesno "some text \n the yes/no question."

    if [ $? == 0 ]; then
    {commands for yes}
    else
    {maybe other commands for no}
    fi

  • Creating a new CVS branch

    Creating a new CVS branch from the sources in your working files

    cvs tag -b New_Branch
    cvs update -r New_Branch
    cvs commit

  • Recursively remove all .svn directories with xargs

    With xargs you can joing the output of one command to the input of another when a pipe doesn’t work. Check out this example:

    find . -name .svn -print0 | xargs -0 rm -rf

  • Copy your public key to a remote server

    Sometimes you need to login to a remote server without typing your password. Really usefull when you want to copy files to remote servers in your bash script routines. To allow  the server to do this you have to copy your public key. Here is how to do it:

    ssh-copy-id -i .ssh/id_rsa.pub username:[email protected]

  • One World Host: .bash_profile

    # path for mysql
    PATH=$PATH:/usr/local/mysql-4.0.26/bin

    # the path for subversion
    PATH=$PATH:~/subversion/bin

    # prompt
    export PS1="\n\h:\w \u\$ "
    export PS2="\n>"

    # environment variables
    export CLICOLOR=1
    export EDITOR=`which pico`

    # repository variables
    export CVSEDITOR=$EDITOR
    export CVS_RSH=`which ssh`
    export SVN_EDITOR=$EDITOR

    # aliases
    alias l="ls -l"
    alias ll="ls -al"
    alias lf="ls -F"
    alias ~="cd ~"
    alias ..="cd .."
    alias reload="source ~/.bash_profile"

  • Find if a process is running

    With ps command we can see all the process running in our system if you have root privileges. We would like to know if samba is running.

    ps ax | grep samba

  • Customize your promt and make it dynamical

    This lines of code show be in your .bash_profile. You can change the color or/and the info that appears in your prompt.

    export MAX_PATH_LENGTH=25
    export PROMPT_COMMAND='PS1="\[\033[0;33m\][\!]\`if [[ \$? = "0" ]]; then echo "\\[\\033[32m\\]"; else echo "\\[\\033[31m\\]"; fi\`[\u.\h: \`if [[ `pwd|wc -c|tr -d " "` > $MAX_PATH_LENGTH ]]; then echo "\\W"; else echo "\\w"; fi\`]\$\[\033[0m\] "; echo -ne "\033]0;`hostname -s`:`pwd`\007"'

  • Bash check if a directory exists

    How to find if a directory exists in bash:

    DIR="/etc"
    if [ -d $DIR ]; then
    echo "Folder ${DIR} exists"
    else
    echo "Folder ${DIR} does NOT exists"
    fi