Playing with Debian

Thursday, 14th February 2008 at 05:42pm

A quick run through of Debian file permissions

I want to learn about file permissions. Yes, you heard me. I want to learn. I don't actually know much about them yet. Why am I doing an article about them if I don't know what they do, you might ask. And I'd have to reply, "good question. I don't really have an appropriate answer." Onwards?

Unix is a multiuser based operation system, like I mentioned before, so there has to be a way that it controls which files a user can look at. That's done with permissions. At the moment, your /var/www/ is going to be owned by www-user which is a user that Apache made when you installed it. Unless you log in as root, or that user you won't be able to edit or add files in there at the moment. Lets learn how to change that.

First, head to your into your /var/ directory, and then show the files with their data, (if you don't know how to do that, then you should read through a few of the posts I've tagged for commands.)

drwxr-xr-x  4 root www-user 1.0K Feb 12 22:38 www

You'll have something like that for your /www/ directory. The "drwxrwxr-x" is what we're interested in, since that tells us the permissions. The first letter tells us that it's a directory, then the rest are in blocks of three; the first block is for users, then groups, then others.

r means that they can read from that file or directory, the w means they can write to it, and the x is to execute it.

What I did was "chgrp -R shamess /var/www/" and that changed the group so that I was in it (the -R­ switch was to make all the files and directories inside it change too). Then I needed to give the group permission to edit the files; chmod g+w /var/www.

And that was it. Now you can edit files in your /www/ directory without having to be root.

There's a more detailed article on permission types and how they work over at FreeOS; Understanding Linux file permissions.

0 comments

Thursday, 14th February 2008 at 02:44pm

Comments and feeds

Just as a heads up, you can now comment on posts here! If you think I've done or said something wrong, then please let me know so I'm not giving bad advice to people. If there's anything you need help on, comment and I'll do my best to try and answer your question in the rest of the comments, or I'll write a post addressing it.

Also, we now have an RSS feed, so sign up to that too.

ETA: I just noticed a bug with the URL that goes with your username. Don't worry, I'll fix it soon and I'll make sure that you still get your link back.

0 comments

Wednesday, 13th February 2008 at 09:49pm

Installing Apache2 (and other packages follow the same technique!)

The first thing I did when I had time was try to install Apache. When I say try, I do mean try. I'd been using my Debian for just a few minutes and so quickly realised I didn't know where to start. I quickly ran to the Apache homepage but that wasn't too much help. In the end I managed to find a Debian using friend, who I now owe a lot of delicious cake.

You'll need to be logged in as root to do most of this.

First thing first was to update our catalogue of packages. If your host is like Redwood then you won't even have a catalogue just yet. Either way, you do the same thing. "apt-get update" which will do what we need.

Terminology note for Windows users: "Packages" is just another name for program, as far as I can tell. So is "libraries" and possibly "binaries".

The update may take a little while so give it a chance. By "a little while" I mean that in respect to a server, which is pretty damn quick for us. Once it's complete, you'll be told. Then make sure that all the things that are already on your LVS are up-to-date, using "apt-get upgrade". Since I was using etch, it was already stable and so all that was upgraded was security things. It may ask you to restart your server, but you won't have to close PuTTY or anything. If it doesn't do it itself, type "reboot". PuTTY will give you an error about losing the connection and the title for the program will change to "PuTTY (inactive)". Right click it in the start bar, and start a new session.

Once that has been done, you can search for Apache. You can do that by typing "apt-cache search apache".  That will search through the catalogue and find all the packages with the word Apache in its name or description. There's a lot there, and we really don't need most of them. To narrow down your search you can add a pipe. So now your command will look like this:

apt-cache search apache | grep ^apache

In case you don't know, that pipe is the key next to shift. What it does is take the output from the first function, and give it to the second. grep is a regular expression function that only returns things that match what you've given.

You'll get a shorter but still long list. Depending on what you're used to, you're looking for "apache" or "apache2". I'd recommend apache2.

To get it, you can type "apt-get install apache2" and that'll start the download. It'll also say something to the effect of "Apache needs other packages to run, install them now?" Type 'y' for yes, and it'll do those too.

If you go to your IP address now, or your domain name if you've set one up, you'll see the "Apache is configured properly" screen. Smile for a bit at your own brilliance, remembering how damn hard that was to do whilst using a Windows machine.

The default directory for your web pages to go is "/var/www/". At the moment, only root will be able to edit files in there, but I'll talk about how to change that later. The httpd.conf you're used to is located in "/etc/apache2/", but it isn't really used any more – I'll look into why later. Pretty much the same file is now stored in the apache2.conf file, and in the 000-default file of /sites-enabled/ directory. You can edit either of them with nano.

1 comments

Wednesday, 13th February 2008 at 08:43pm

Debian cheat sheet

Following on from my last post about basic unix commands, I found this PDF that's really helpful too.

man – is another useful one. It gives you the manual entry for a function. For instance "man ls" would give you the manual page for that command, as well as all its options and parameters. man can output a lot sometimes, and it's too much if you're just quickly checking what a function is for, in cases like that you can use "man -k ls". That will make "ls" part of a regular expression though, so all the commands with "ls" in it will get thrown up too. To stop that, use "man -k ^ls$".

If you're looking at a manual page there are two buttons you need to be aware of: press "q" to quit from the manual, and space bar to go down to the next page.

Redwood don't give me any information on how much hard drive space I have left. If you want to find that out, you can use the command "df", which will output some stuff about your hard drive.

1 comments

Wednesday, 13th February 2008 at 12:50pm

Some simple commands for Debian

I thought I should make a post so that I have something to check back to when I've forgotten some commands for stuff. Everything here is pretty basic, really and you should make an effort to remember them.

These commands are all case sensitive, as far as I've worked out.

cd – this changes the directory you're in. If you're logged in as your user (which you should be) then just typing the command will take you back to your home directory. At the moment that will be pretty empty. If you put a directory as a parameter after you write "cd", you'll go to that directory. For example, if you type "cd /etc/" you'll get taken to the /etc/ directory.

Terminology note for Windows users: Stop calling them "folders". You'll get laughed at. They're "directories" on Linux.

ls – (that's "L", but lower case, of course) this outputs all the things that are in the directory you're in. It doesn't output them very pretty, so instead you can do "ls -lh" and that will output the same thing, but each file is on its own line and you'll get some data about it. If you want to check what's in a directory you're not currently in, you can just add the directory path at the end.

su – sometimes you'll be in a situation where you need to be logged in as root. But I've already told you not to be in root all the time, and you should stick with that. "su" stands for "switch user". Just typing that command on its own will allow you to act as root for a little while. You'll be requested for root's password though. You can switch to other user's too, by putting their username after the command.

Remember, when you've finished, come back out of root by typing "exit".

nano – the default text editor on Debian (etch at least) is "nano". You can get to it by typing "nano", and you'll have a blank text editor. It's pretty low feature so don't expect to be cutting and pasting a lot at the moment. You can edit a file by putting its path after the command.

Don't go editing  things you don't understand though!

I'll add more later, but for now I've been using that linux help site I linked to earlier.

1 comments

Wednesday, 13th February 2008 at 02:04am

I think root is a cool guy, he deletes ~ and doesn't afraid of anything

Now we have our virtual server and Redwood were nice enough to install Debian for us (because I've idea how). You wanna rush in a get going; I was literally bouncing around the house when I got my "your server is up and running!" email from them.

Putty opening screen captureOf course, at the moment you've no idea how to connect to the server. The first thing you'll need then is PuTTY, if you're on a Windows machine like I am. So far, I've only found the need for the standard "putty.exe" so that's all I've got. It's a tiny application, and it's probably worth sticking it on a pen drive so you can take it with you everywhere, for those times when you just have to check on your baby <3

When you start it up you'll be given a huge list of daunting options. Don't worry though, if I'm completely honest, I've not looked at most of them after my quick glance when I first excitedly installed it. All you really need to do to get going is to fill in your IP address or host name (I've put in my VPS's IP address; type that in your URL and you'll get back to the homepage for Trinity). It should already be default on port 22, since that's the default for SSH.

Then click "save" so that you don't have to keep typing your IP address every time you want to log in. There's nothing wrong with leaving your IP address public (you probably know you can get to it through DNS look ups anyway). Then press open.

Then you'll be presented with a black screen. Give it a second (depending on how fast your server is, and how fast your local internet connection is) and it'll ask you to log in. At the moment you'll need to log in as root. "Root" is the administrator account of a linux server, it can do absolutely anything in the system. Next you can type your password. Nope, nothing's showing up. Trust me though, it's being typed. Instead of putting stars in place of your letters, it just won't show them up. Press enter and you'll get to see the start up/message of the day thing.

It's best never to play around as root; so far as I've learnt, not even experienced linux users do that. It's too easy to delete something that's far too important (unlike Windows, there's nothing to stop you just deleting Debian critical files). To counter that, you have to set up a new user. To do that type "adduser username", obviously replace username with the user name you want to set up.

The username has to be in ascii, and all lowercase.

Then it'll ask you some random details. Most of it you can just skip (by pressing enter). Debian was created with multiple users in mind, so having that random contact information for each user made things easier when you're trying to find out who broke something.

Play around as your new user – I called mine "shamess" – for a while. You can find a good FAQ and section for people new to unix servers, with some basic functions at LinuxHelp.net.

0 comments

Tuesday, 12th February 2008 at 12:28am

Virtual server vs. dedicated server vs. DIY server

I decided I wanted get my own server so that I could run it completely; I've had shared hosting in the past but asking for my host if he could do something for me, because I didn't have access was getting old. Running your own server lets you do whatever you want.

If you want to run your own server entirely, you have three options.

First, you can build your own server. Unless you have that spare parts lying around, it may cost you a lot to make it. It's basically just a computer. You won't need to have a flashy graphics or sound card, really so if you are building your own server, don't bother getting those. There's nothing wrong with just running Apache from your own computer, but you'll have to have it on all the time and have a permanent internet connection. Your ISP might not like that you're using them as your route to the Internet though! I do know that Virgin Media don't mind you doing that.

I'm not using this option because I don't feel like managing the hardware myself. And my mum would get pissed when our 2Meg connection slowed to a crawl.

Another option is a dedicated server. Basically the same as above, but a company is looking after the hardware and they have a much faster internet connection than you'll have at home. Downside of this is that they cost around £60 a month. You get lots of hard drive space and it's really fast generally.

I didn't bothered with that because... well, mostly because I'm poor. Also because I've no idea how to manage a server. Getting something as professional as that would be silly, if I was just going to break it eventually.

So, the option I went with was a virtual server. Exactly the same as a dedicated server, except you don't get as much hard drive space or memory because it's shared with other people on the same server. Nonetheless, you have complete control over everything that happens in your "partition".

At the moment, I'm paying $10 a month (£5.14) for a server has a kinda low spec, from Redwood Virtual. It's okay for what I need it for; playing around and learning the ropes. I guess we'll see what happens if this blog ever starts getting traffic, (heaven forbid one of my articles get Dugg.)

The LVS came with Debian. I had the option of picking the distribution; Etch, Lenny, or Sid. At this point, I knew nothing about Debian, so I ran to Wikipedia to find out what they were on about. The Debian article told me that Sid was an unstable version, so I'm not entirely sure why Redwood would be offering it. Etch is the current and stable version of Debian, and Lenny is the next version that's going to be released, though it's still in an "experimental stage", which I guess means that it's in beta. I went with Etch in the end, since I know that's going to work as expected.

1 comments

Monday, 11th February 2008 at 09:21pm

This is why third parties suck

If any of you are running any kind of XHTML checking on this site, let me tell you that every tag I write is 100% standard compliant. Blame the adverts for the errors. I'll shoot them an email and see if they can fix them :)

0 comments

Monday, 11th February 2008 at 08:33pm

Keeping it up can be hard for a boy

I thought I should talk about the stability of this site, just so you know when it inevitably goes down.

The first reason it could go down is because I've messed up something with Debian. It's highly likely since I spend most my time poking around files that ought not be poked. In fact, I'd be quite happy if that happened because then I could fix it and it'd give me more to blog about (when I have it back up).

Second is because I'm using a blogging software I've made myself. That in itself screams trouble but I have trust in myself. The software is called AyTwo, and isn't out to the public just yet (if at all, I haven't decided yet) because, to be honest, it's not finished yet. For all intents and purposes it works, but I'm fairly sure there are still a few bugs. If you find any, let me know; shamess+trinity1@gmail.com.

It's also missing a lot of features you'd expect that I'm hoping to get out soon. Things like commenting and feeds. General public can't register (nor log in) so don't email me begging, there's really nothing interesting once you've logged in anyway. At least not yet.

In the event that something awful does happen, I'll most likely have a recent backup and everything'll be up before too long.

0 comments

Monday, 11th February 2008 at 04:14pm

Objectives and purpose

When you start up a new site it's always best to start out with some objectives about what you actually want to do with it. Many projects have failed because they lacked direction or just tried to fit in with too many niches and achieve too much. So, before I start filling this blog up with content that has no point or purpose, let me tell you what it's for.

Basically, this is more of a personal site, for me. I want to use it to record everything I've done with my new and shiny virtual server. First, because I've never used Debian before and there's a large likelihood that I'll do something stupid (don't worry, I've already heard about rm –rf) and break the entire thing and have to start again. When I do, at least I'll have this site to tell me what I did so I can get it back to a usable state.

Second, as I've been looking around the internet for help with certain things, I've come across hundreds of sites which is a little annoying. Shouldn't there be just one site that tells me all that I need to know about Debian? I'm hoping I can use this site to compile those websites so I can find them in the future.

Since most the stuff I'll be posting shall be public, there's no reason why you guys can't benefit from my lessons either. You might be at the same stage as me – bored of the limitations of your share hosting, and feel like you can handle managing your own server – so you'll need to learn the same as me too, I guess.

Oh, and of course there's the advertising revenue I can make off a Unix site.

0 comments

Read some previous entries