Archive for the ‘Basic Unix’ Category

Remove all .svn folders in a directory tree

By Automater on August 30th, 2010
1
2
3
4
find . -name ".svn" -type d -exec rm -rf {} \;

which only deletes directories named ".svn"
Posted in

Tar Folder and exclude subfolder

By Automater on August 30th, 2010
1
tar -cf backup.tar htdocs --exclude /var/www/somesite.com/htdocs/files
Posted in

Uninstalling packages from Debian/Ubuntu

By Automater on May 24th, 2010

This will completely remove package along with any configuration files.

1
apt-get --purge remove package_name

Follow that up with

1
apt-get autoremove

Find Text In File System

By Automater on May 20th, 2010

Now you can search for any text on a Linux Server

1
find / -type f -print0 | xargs -0 grep -l "text to be searched"
Posted in

How to Tar / Untar From the Command Line

By Automater on May 6th, 2010

Initial Steps
First SSH into your web server and move to the directory of the files you wish to tar up, since tarring an absolute path will save the folder structure as well which is bad (ie: /home/yoursite/public_html/backupthis/ will save the folders home -> yoursite -> public_html -> backupthis). You can get to the folder you need to by typing:

cd /path/to/your/stuff

Creating a Tar
Now that we’re at the directory we want to tar, or the sub-directory, you can do one of two commands depending on what you need.

If you want to save every file / folder in your current location into a file called backup.tar.

tar -cvf backup.tar *

If you want to save a tar named backup.tar with the folder “somefolder” and its contents.

tar -cvf backup.tar somefolder/

You can test/view your tars with the following command:

tar -tvf backup.tar

Extracting the Tar
When you need to extract that tar, the following command will be suffice:

tar -xvf backup.tar
Posted in