
Friday, 11th July 2008 at 12:03am
I'm currently at my boyfriend's house, and quickly wanted to install Apache2 on his Ubuntu machine (he's asleep, and I feel like coding). apt-getting everything really wasn't a problem, in fact everything started and worked fine.
I did get a warning though:
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
Fortunately, this can easily be fixed by editing the configuration file, usually stored at /etc/apache2/apache2.conf. The fix is simple, and you'll kick yourself. Just add the following line to the end:
ServerName "localhost"
If you're still having problems, feel free to drop a comment, and I'll get right back to you.
Friday, 4th July 2008 at 01:14am
Whilst I use Debian as my server's OS, I'm still very firmly rooted into Windows XP for my laptop. Recently though I decided to make the switch! I downloaded Debian and installed it fine. The only problem was that I couldn't find the right driver for my wireless card... But I didn't give in! I decided to try out Ubuntu, which comes with a tonne of most common drivers which did have my wireless driver with it.
So there I was actually using Linux as an operating system but I ran into one hiccup... World Of Warcraft was far too slow... I knew I had to emulate it through Wine and it did work! It was fully playable and I found zero errors, just that my laptop doesn't seem to be able to handle running it.
My laptop is far from godly, and it's currently having graphics problems so you'll probably find that you'll run it just fine. You can just follow a tutorial, over at WoWWiki on how to use Wine to run WoW.
Thursday, 26th June 2008 at 12:49am
The message of the day is the text that's displayed to you when you log in. At the moment, mine was just an awesome Debian symbol, with the address of my maintainers. Whilst the ascii art was awesome, it didn't really help me.
You can change your motd by sudo editing /etc/motd. It's as simple as that really.
Once you change it, it'll be system wide, meaning every user will see that message when they log on. Keeping that in mind, it's a good way to get a message around to users without having to send tonnes of emails to each of them. For instance, you could put a "Server will be down for maintanance next Tuesday" message for everyone to see. If you're the only person using the box (like I am), then you can just putting motivational messages, or a todo list.
Tuesday, 17th June 2008 at 02:18pm
I'm usually on my laptop, using either my college or another unsecured wireless connection which makes me a little suspected about packet sniffers. I'm not too worried since I use SCP, which is encrypted, and SSH, which is also encrypted. Pretty good encryption too.
For you paranoid types though you can tighten up your encryption by using public key encryption. To really understand why it's a better encyption method, you need to understand how encryption works and that gets a little complicated. But, because your key is 100% random, and not based on a protocol like SSH or SSL, it's even awesomely harder to crack.
You can see how to set it up correctly so you can log in using it with WinSCP and PuTTY from HowtoForge, who have a big ass four-page article. Here's my short version:
That's your key generated. If you really want to, you can upload your public key; it doesn't matter if people know it. In fact, most people give it out so that people can send them encrypted messages (it's encrypted with the public key, and decrypted with the private key).
It goes without saying, but don't leave your private key lying around. I actually key mine on a flash drive, which is password protected.
Next, we need to tell your server abou the key.
Once you're logged into your server (probably for the last time without a key!), we need to make the directory ".ssh" (mkdir .ssh, so long as your on your home directory). Next, we need to make the key's file:
nano -w .ssh/authorized_keys2
Now, in the PuTTYgen window (I hope you didn't close it...) the first section gives you a chunk of text for "pasting into OpenSSH authorized_key files". Grab that, and copy it into the file we just made in nano. Save and exit nano.
Just a little bit of chmoding now.
chmod 700 .ssh
chmod 600 ~/.ssh/authorized_keys2
Now, close PuTTY and open it again. Head to Connection > SSH > Auth and put the location of you .ppk private key file. Now save that session information (head back to Session) and log in again. This time, you'll be promoted for your key phrase instead of your password.
Saturday, 26th April 2008 at 06:00pm
I just upgraded my WordPress blogs for other websites using WinSCP which was boring... So, I figured there must be a better way so I went to the Codex and found this article on upgrading WordPress from SVN.
Of course, you need Subversion first. That's simple though; sudo apt-get subversion.
Wednesday, 16th April 2008 at 09:47pm
I needed to set up an FTP server since WordPress wanted it in order to do the automatic plug-in upgrade. I've never needed one before since I've just been using SCP.
I looked around for an FTP server and was about to install FTPd, before someone told me that vsftpd was a much better daemon to get, so I did (using sudo apt-get install vsftpd).
Well, that was simple enough, but now we have to change some of the configuration file. It's actually pretty simple since it's well commented. You can nano the file /etc/vsftpd.conf to get at the options; remember to use those helpful switches!
I decided to disable anonymous access, since all I really need is to get my WordPress to update a few files, and it won't do that anonymously. Change the setting on line 23 to disable it. I want to just use local users for when I'm logging into FTP, enable that on line 26; that means that I'll use the same user name and password that I use for PuTTY to get shell access. We obviously want to write stuff when we're using FTP (instead of just reading) so make sure line 29 is uncommented.
I changed my local_umask to 022. What this does is basically makes any new file I make have the permissions of 755 (777 - 022), meaning everyone can read and execute, but only the owner can write.
Since I'm letting local users access via FTP, I want to restrict them to just their home directories, so they can't play around with files outside of their /home/username directory. That's done on line 105. Of course, I want to allow myself to access anywhere, so I uncommented line 110 and 112.
That's all the edits that I made to that file. Now though, we need to add ourselves to the list of users allowed outside their home directory. It's a simple (empty) file at /etc/vsftpd.chroot_list by default, and you just need to put your user name there.
Wednesday, 2nd April 2008 at 10:37am
We all know that Linux should be pronounced "lin (as in linen)-ux", thanks to the Wikipedia article on it, but the Debian wiki article isn't so kind.
I was at a friend's house the other day and he said "day-be-en". I've always said it as "deb-ee-en". How do you say it?
Sunday, 30th March 2008 at 06:30pm
I generally use cat when I want to read from a file, but I just found less, which outputs a file a page at a time.
Friday, 28th March 2008 at 12:01am
The default mail app that ships with Debian (... called 'mail') can't handle MIME standards, which makes sending and receiving attachments pretty hard. So, I asked around and found mutt (sudo apt-get install mutt).
It's actually a lot prettier than mail, as pretty as command line can get anyway. Other than the way it looks, it works pretty much the same, and the on screen help is good too. So, go and switch to mutt.
What other mail applications are there?
Tuesday, 25th March 2008 at 05:44pm
One of my purposes for getting a VPS was so that I could run BitTorrent 24 hours a day, without having to leave my laptop on to do it. I could just run BitTorrent on my server and that could do all the work for me. After all, I may only have 2Gb hard drive at the moment, but I do have 1000Gb of bandwidth which I'm hardly putting a dent in. Not to mention, at home I have a one meg connection, whereas my server has 100Mbs.
It was going to work something like this: I'd start bittorrent up on the server to start downloading a file. Once it downloads it, I could get the file through SCP or FTP which would probably be quicker than me doing the torrenting myself. It's also helpful when you're downloading a rare file which only a few seeders who aren't uploading when you're machine is on; your server is always on, so it's going to be able to download 100% of the time there's an uploader.
Let's go through the steps to do that, from the beginning.
I decided to go ahead and get BitTornado, which you might have used as a client before. Get it using sudo apt-get install bittornado. Now you've got that, go to the directory you want to download the torrent to. I made a /downloads/ folder in my home directory.
Let's find the .torrent file that we want to download from. In theory, BitTornado will work with just the URL to the .torrent file, but you won't find many trackers that will give you that, instead they'll give you a URL which looks something like http://www.mininova.org/get/1218398. What you can do with that though is wget the torrent file.
Then do this:
btdownloadercursers --max_upload_rate 70 1218398
This sets the maximum upload rate of 70kb/s. Yes, you have a fast server, but you don't want to get in trouble with your providers for hogging all their pipes, so make sure you set it. The 1218398 is the torrent file that's on our machine now, since we just downloaded it.
Now you'll get an application open giving you stats and stuff about your download. You can't send this to the background using ^Z, else it'll stop it. You can quit using ^C or just Q.
The downside of this though, is that my connection is so fast, and my memory so low (64Mb, with 128 swap) that downloading at 600Kb/s crashed my server... three times. So, don't bother trying to use BT unless you have a fairly decent machine.
Sunday, 23rd March 2008 at 01:57pm
Sorry I've not posted much in the last few days; I have a few posts lined up though :)
To keep you happy though, here's a cheat sheet for Unix commands. Well, it's a bit huge, more of a cheat novel.
Tuesday, 18th March 2008 at 12:39am
I love my soya burgers, but I don't like them burnt. More than once I've put them on the grill, came to check what's happening on MSN, and totally forgotten about them. Sensible people have egg timers for this type of thing, but we have Debian servers and should frown upon such out dated methods.
Instead, we can send an email to ourselves when we need to turn our burgers over.
We can do that using the at and mail commands. at lets us tell Debian to do something at a particular period of time. We want to have to turn our burgers over in eight minutes, so tell it that.
at now +8 minutes
For some reason, my server lags for a second, but then you go into the at program interface1. It's here we say what we want to do.
echo "Time to turn your burgers over!" | mail -s "Just a reminder!" shamess@gmail.com
This runs mail, where -s is the subject, and the to address goes at the end. Then, mail expects you to type the body of your message, so we just echo it here (more on pipes later). This sends me an email with "Just a reminder!" as the subject, and "Time to turn..." as the body.
There you go! No more burnt food! Be inventive with other reminders you could give for yourself.
1When you move away from the standard interface where your CLI all starts with your user@host:/etc$ into the interface where you have mysql: or at:, does that have a name?
Saturday, 15th March 2008 at 06:14pm
After we talked about backing up your MySQL databases last time, I realised it would be much easier if I could just make my server back it up its self, every day. That way I don't have to think about it, and if I lose anything I can just revert to the last day's archive!
To do that, we use a thing call cron. This might have been called "cronjob" or something similar on your shared host, if you ever used it. If you did, then most of this should be obvious for you, since it's exactly the same (at least when I was using Plesk), just in a different way.
If you've ever looked around your /etc/ directory, you'd have noticed the /etc/cron.whatever directories. The files in there are run according to their directory, so the scripts in cron.daily are run once a day.
Each user has their own crontab file, which is where you put all the stuff you want to run. You can see your file with the command crontab -l (that's a lower case L). Chances are you won't have one just yet.
When you do though, it'll be laid out in six, space seperated fields, like this:
* * * * * Command to be executed - - - - - | | | | | | | | | +----- Day of week (0-7) | | | +------- Month (1 - 12) | | +--------- Day of month (1 - 31) | +----------- Hour (0 - 23) +------------- Min (0 - 59)
(Stolen from Debian Admin site, you should check out that article too.)
For day of the week, both 0 and 7 are Sunday, however some versions of Unix don't support 7.
To edit your crontab file, use crontab -e, which will open your crontab file in nano.
The "command to be executed" is the path to the command's binary (sorry if that makes little sense...), which you can find out by using the which command. For instance, if you want to run ls, you'd have to do which ls to find where it's kept. If you wanted to run ls, for some strang reason, you could do:
0 * * * * /bin/ls
Then, you'd get the output emailed to you, at your local user.
But, that's not what we want to do. We want to do a backup, each night. So, we'd add this:
10 23 * * * "mysqldump -A -u root -p password > /home/shamess/backedup-files/$(date +%s).mysql"
That'll back all the databases up at 10 past 11 each night. The $(date +%s) part will output a Unix timestamp.
You'll probably want to delete really old back ups, and archive the new ones. You can do that by running a bash script, instead of a command, but we'll get to that later.
Wednesday, 12th March 2008 at 10:36pm
Just like I predicted, I had my first mess up. On the bright side though, it wasn't because of Debian. It was because I wrote a script and replaced all the entries with a blank line... That's not important though, what is important is that I should have backed up, which I didn't. (I had to go through my entries in Google Reader - thank God for them archiving feeds and not getting them live - and copy and paste them back.)
Anyway, backing up your MySQL databases is easy actually. There's a page about it on the MySQL documentation. I chose the mysqldump option.
From PuTTY (you don't need to be in MySQL, mysqldump is part of the mysql-client package, but executable by itself) I did this:
mysqldump -A -u root -p > /home/shamess/backedup-files/20080312.mysql
The -A means "all databases", if you only want one database you can append the database name at the end (and miss out this switch). If you only want one table, put the table name at the end of that too.
The next switch is me giving the MySQL username. I decided to use root, since it has access to all the databases. The "-p" is saying that I'm going to use a password. I didn't put my password after it, because you can leave it out and it'll prompt you for it after you press enter (thanks Marc for that).
Then there's something new for us to get excited about. The greater than symbol (>) means "write whatever output to this file". I did that because I couldn't find the switch to do it for mysqldump, but I'm sure there is one (comment if you find it).
On a side note: if you look through the site and notice an entry is out of place, or the subject has nothing to do with the post (meaning I've pasted the wrong post) then please comment!
Wednesday, 12th March 2008 at 10:04pm
First, I thought I'd let you all know that we've switched to a new URL. The Trinity URL took too long for me to keep typing, so we're now over at www.debiantips.com. There's not much you need to do; the RSS feed and everything will stay the same. If you book marked any links, don't worry, they'll all redirect.
But, because I changed the URL to the RSS feed for Feedburner, it reloaded all the RSS items, so sorry if you have to mark them all as read again!
To be a little on topic; I've just added www.debiantips.com to the ServerAlias for the old site, so it's exactly the same.