WebFaction
Community site: login faq
3
3

How do I reset my home directory to the way it was when I first opened my account? This means I want to irrevocably destroy everything under my account.

I have everything I need backed up locally and offsite. Now I just want to delete all of the data on my account and reset my $HOME directory to a clean, pristine state.

asked 23 Feb '13, 19:46

ryans ♦♦
5.0k93360
accept rate: 43%


You asked for it. This procedure will irreversibly destroy data. You are fully responsible for the consequences, and these instructions come with no warranty (express or implied). Use at your own risk; you have been warned.

First, delete all of your applications via the Control Panel. You can skip this step; it just means that the data under your $HOME/webapps directory won't be deleted.

Second, log into your account via SSH, and use the following script to obliterate everything:

#!/bin/bash

mkdir -p $HOME/bin $HOME/lib $HOME/logs $HOME/webapps
cd $HOME
shopt -s dotglob
find . -maxdepth 1 -not -name '.' -not -name '..' -not -name 'bin' -not -name 'logs' -not -name 'lib' -not -name 'webapps' -print0 | xargs -0 chmod -R 755
find . -maxdepth 1 -not -name '.' -not -name '..' -not -name 'bin' -not -name 'logs' -not -name 'lib' -not -name 'webapps' -print0 | xargs -0 rm -rf
cd $HOME/bin
find . -maxdepth 1 -not -name '.' -not -name '..' -not -name '.ph' -print0 | xargs -0 chmod -R 755
find . -maxdepth 1 -not -name '.' -not -name '..' -not -name '.ph' -print0 | xargs -0 rm -rf
cd $HOME/lib
find . -maxdepth 1 -not -name '.' -not -name '..' -not -name '.ph' -print0 | xargs -0 chmod -R 755
find . -maxdepth 1 -not -name '.' -not -name '..' -not -name '.ph' -print0 | xargs -0 rm -rf
cd $HOME
mkdir -p $HOME/lib/python{2.4,2.5,2.6}
rm -rf $HOME/logs/user/*

cat << "EOF" > $HOME/.bashrc
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# User specific aliases and functions
EOF
cat << "EOF" > $HOME/.bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
EOF

cd $HOME
chmod -R 0755 $(ls -d * | grep -v "^logs$" | grep -v "^webapps$") 2>/dev/null
chmod -R g-s $(ls -d * | grep -v "^logs$" | grep -v "^webapps$") 2>/dev/null
chmod -R u-s $(ls -d * | grep -v "^logs$" | grep -v "^webapps$") 2>/dev/null
chmod -R -t $(ls -d * | grep -v "^logs$" | grep -v "^webapps$") 2>/dev/null
setfacl -R -b $(ls -d * | grep -v "^logs$" | grep -v "^webapps$") 2>/dev/null
find $(ls -d * | grep -v "^logs$" | grep -v "^webapps$") -type f -exec chmod 0644 "{}" \; 2>/dev/null

exit

After logging in again, your $HOME directory should be empty and back in its original state. Hope that helps!

permanent link

answered 23 Feb '13, 19:55

ryans ♦♦
5.0k93360
accept rate: 43%

edited 13 Aug '13, 22:59

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×5

question asked: 23 Feb '13, 19:46

question was seen: 2,822 times

last updated: 13 Aug '13, 22:59

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM