Tag Archives: Ubuntu

How to Remove Non-Empty Directories in Linux

How to Remove Non-Empty Directories in Linux

Here is one that I am using all the time: deleting directories or an entire directory in Ubuntu (linux). It’s very easy (and dangerous) as it will delete everything without asking for confirmation. But very handy when you know you just want to delete it all quickly.

This is dangerous! Use with caution!

sudo rm -r *

That deletes everything inside the current directory. But if you want to delete an entire directory that is inside your current directory, you do this:

rm -r directoryname

Be careful, and good luck! :)

Create Aliases in Ubuntu

How to Create an Alias in Ubuntu

If you run the same commands in Linux (or Ubuntu) all the time, you can add what is called an “alias” to your user account. For example, I regularly type:

ls -alh

So I setup an alias so that I can just type la. (also, see my Top 10 Aliases list) To do this, simply edit your “profile”. Bash is the program that you typically use when you are in a command shell, so it may be called your “bash profile”. Your profile is in your Home folder and stores all of your preferences. Just edit the “.profile” or the “.bash_profile” if it exists.

cd ~
pico edit .profile

Add the following code to the bottom:

alias la='ls -alh'

Now when you are typing at the command prompt, you just type la and it acts like you typed ls -alh. Pretty handy.

Displaying JPG files over a Mapped Drive

Displaying JPG files over a mapped drive when using Apache:
I don’t think that most people would have guessed this, but if the images you are going to display on your website are located on a mapped network drive, Apache needs to be modified in order for the image to display. If you mapped a network drive but it only displays the text of the image in the browser, you need to change the following inside of your Apache Directives:

<Directory "/path-to-mapped-drive">
EnableSendfile Off
</Directory>

So, this may not make a lot of sense unless you have experienced the problem firsthand; but if you open the browser window, expecting to see a jpg, and instead you see something like this:

http://brockangelo.com/wp-content/uploads/mnt/2008/08/sample.jpg

Then you need to set EnableSendfile to “Off” inside your Apache Directives.

Allowing Uploads via the Media Uploader

Allowing Users to Upload via the WordPress 2.6 Media Uploader:
You have to chmod wp-content/uploads/ to 777 in order for the Media Uploader to allow users to upload files. With the websites that I host, I prefer to not have anything chmod’ed to 777 unless it is extremely inconvenient, so I just create folders every few months and chmod them to 777. I go into /wp-content/uploads/THE_YEAR/ and do a mkdir 08 (or whatever the current month is) and then chmod 777 08 for the month, and I chmod previous months back to 755. The alternative would be to chmod the entire uploads directory, but then all prior uploads would be at risk of tampering.