In order to prevent data loss when it has been accidentally deleted with the command "rm -rf", you can add this function to your .bashrc file (located in your home directory). This function shows the files to be deleted and requests confirmation just once:
 
[[email protected] ~]# vi ~/.bashrc
 

function rm() {

params=""
while :; do
    case $1 in
    -rf | -fr)
            params="${params} -rfI"
            ;;
    -?*)
            params="${params} $1"
            ;;
    *)
  ls --color=auto -R [email protected]
            command rm $params [email protected]
            break
  esac

  shift
  done
}

 

The new .bashrc would be installed the next time you log back in, but if you want it to be installed immediately, you can just source the file:

 
[[email protected] ~]# source ~/.bashrc
 
To execute the function just in the login node and into interactive jobs in order to prevent requests inside sbatch jobs:
 

function rm() {

params=""
host_name=`hostname`
if [ "$host_name" == "mr-login" ] || [ "$SLURM_TYPE_JOB" == "interactive" ]; then
        while :; do
        case $1 in
        -rf | -fr)
                params="${params} -rfI"
                ;;
        -?*)
                params="${params} $1"
                ;;
        *)
                ls --color=auto -R [email protected]
                command rm $params [email protected]
                break
        esac

        shift
        done
else
        command rm [email protected]
fi
}