Deleting files in existing directory

I have a website on dreamhost and want to change it to do a one click install of wordpress. It says all the files need to be deleted before installing. Not sure how I do that. Can you help?

OK. Let’s start with the first issue.

Do you want to use Wordpress as your main server for the entire web site or not? If you don’t do you want to keep your existing web pages and just add wordpress as a sub-directory to the site or do you want an additional site?

The instructions are totally different depending upon your answers. Because if you want Wordpress to run your entire site then you need to delete (effectively, not physically) the entire site’s contents first. If you don’t want Wordpress to run the entire site then you need to create a directory, in your website, into which you install Wordpress.

But, in either instance, the directory into which you are installing Wordpress needs to be empty. You can’t have existing files in it.

The second issue is “What type of access do you have to DreamHost?”

Is it a secure shell (SSH), or secure FTP (SFTP) as in FileZilla, or just simple FTP?

Instructions on the steps needed to create a blank directory or move files vary depending upon the method of access.

Hi, thanks for responding.

Can’t think of why I wouldn’t want Wordpress to run the entire site. It will be a small, simple site.

I have a shell account or sftp. But let’s back up, I see it looks like wordpress may already be installed for my domain. I guess I’m really confused. I have a client’s site setup with wordpress with diff domain and it’s paid for each month. I didn’t set that up, someone else did for me. My understanding is that I can have multiple wordpress sites per account?

I guess I’m not sure what my next step is. My goal is to remove my other existing site which is not a wordpress site, and replace it with my new wp site from my local host.

OK. So, you want to have wordpress run the site. That means that you don’t want something like:

but, instead want

to be wordpress.

That means that you probably want to install wordpress into the root directory of your web site.

The first step is to go to your existing site and BACK IT UP. That is, copy the files from the current directory

to a new directory, say “”.

Do you have shell access to the home directory? Is your account configured for SSH access or do you just have FTP access? It works better if you have SSH access, but you can use FTP to do it. It just means that you need to either rename the directory and create a new one with the original name or download the files to a workstation and then re-upload the back to a new directory.

Getting SSH access means that you will end up with a UNIX command prompt and can issue commands directly to the system and not need to go through FTP or SFTP to do it.

[b]What I am telling you here is very "powerful" and can totally destroy your website forever if you make a mistake, forget a space, a period, a dash or a parenthesis. These commands are not for children to play with! They are the equivalent of a loaded shotgun with the safety off to your website. Handle with care. [/b]

To do the backup copy of a directory, you can use tar. (This stands for “tape archiver”, but it is a very old name.). Issue the following three commands:

(cd ~/; tar -cf - .) | tar -xvf -

These commands will copy the files, permissions, links, etc. from your current directory at to the new directory called If you did it correctly, you should see a list of the files as they are being copied flash on the screen.


By the way, to make an archive that you can use SFTP to download to your computer, issue the command:

tar -czvf archive-emsq.tgz ~/

Then, download the file archive-emsq.tgz that the command will create. That is the safest method to move the backup off the site in case things are really messed up.

After you have done this, then issue the commands:

cd ~/
ls -l

DO NOT FORGET THE FIRST COMMAND. YOU must, repeat must, be in the directory that you want to remove the files BEFORE you issue the remove command “rm”.

You should see your web site files and not one that is called “”! If you don’t then stop; check things again; and try again.

Only when things are correct and you are in the proper directory, issue the magical command to remove the file contents. Warning this will remove the files AND ALL SUB-DIRECTORIES!

rm -rf *

This will remove MOST of the files. I can give you the command to remove all of the files, but that is very, very, very dangerous and if you make a single mistake, it will be disasterous. So, let’s just deal with the normal files first.

Then, to find the files that may still exist but are “hidden”, issue the command:

ls -a

This will do a directory listing of the hidden files. Ignore the files that are just “.” or “…”. But, look for ones like “.htaccess” or similar. Those you need to delete as well. The command to delete them is similar to the other, but is simpler.

rm .htaccess

will delete the file called .htaccess from the directory. Notice, I did not include the “-f” option to force the deletion. It may ask you “are you sure?”. This is the time to say “well, am I?” and if so, just answer “y”.

There are several ways to do this. You can have sites that are accessed by


That is just creating an empty directory called “abc” in the directory and installing wordpress into that directory.

or, you can have


That is going through and updating the DNS tables and possibly doing a sub-domain. I haven’t checked so don’t quote me.

or, you can have


That is going through and creating a sub-account AND registering the domain This is the only option that costs money for the domain registration and/or transfer. If you don’t want the domain registered with DreamHost then just point the nameservers to dreamhost and create the sub-domain.

The choice is yours.

In all instances, you will have two directories associated with your account. One is for “” and the other for “”. You may have two different users, one for each site, one directory in each of the user’s home directory. Or, you may put them both into yours.

Wordpress may be installed into one or both of the sites. The installations are separate and distinct. The databases are separate and distinct. They both reside on your database server, but you would create two databases; one for each web site.

ok… got it solved. It took a little more understanding on my part, that I open terminal, launch ssh to create the backup file and compress it

Then open another terminal session for sftp and download the backup

Then go back to ssh session and delete all the files

Don’t know if that’s the best, but it worked. Seems like a lot of jumping around to do what should be fairly simple thing. But thanks!

I was in the directory, did listing for cofirm.


rm -rf *

It said:

Couldn’t stat remote file: No such file or directory
Removing /home/marilnlee17/
Couldn’t delete file: No such file or directory.

typed: ls

Showed the correct directory I was in. All files & subdirs still there.

typed: rm index.html

Removing /home/marilynlee17/

but file still there

I don’t mean to offend you, but I did say that you had to do the commands EXACTLY as I entered them. I did mean EXACTLY. You didn’t or you would not have gotten that message. It is obvious from the message that the sequence was incorrect. It is very important about the order of the characters. As I would tell my partner, a UNIX neophyte, “Close only counts in nuclear weapons and hand grenades, not computers!”

You entered

rm *-rf

and not

rm -rf *

However, that being said, perhaps a better solution is what I put below about creating a new directory.

The “index.html” file is a file, not a directory. You should be able to remove it with the file remove command, rm.

Did you try

rm -f index.html


The parameter “-f” says “force the removal, don’t ask. Just do it.” Of course, you need to be in the directory where the index.html file is located.

If you can’t do that, then issue the command:

ls -ld

this will print the directory listing of the current directory. Make sure that you own the directory and the directory permissions are at least “700” (they can be anything else, but you need to have read/write/execute permission on the directory, ergo the 700. If they say rwxr-xr-x or rwx-r–r-- then that’s OK too, but they need to start with “rwx”.)

However, perhaps a better solution is to simply to avoid doing the delete altogether. What you need is a blank directory. Ok, create it. But it needs to be called the same name. So, here is how to do that:

First, go to your root directory with the command:

cd ~

(The “~” is short-hand for /home/marilnlee17/)

Then, rename the current web directory out of the way,


(the move command, mv, is the UNIX equivalent of MSDOS’ ren command.)

and then create a new directory with the commands:

chmod 755

These will create a new directory, called and assign the proper permission to the directory, 755. It should show when you do the “ls” command that you are the owner and your group is set properly. The file permissions should then say rwxr-xr-x.

After that, you can remove the old directory safely with the command

rm -rf

This should remove all of the files (the “r” is “recurse into subdirectories”) and the “f” is the same “force delete” option.)