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!
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:
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.
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 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:
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:
Then you need to set
EnableSendfile to “Off” inside your Apache Directives.
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.