Filed Under (Sysadmin) by Amandine on 04-05-2012
I recently had an interview in which I got asked about the sticky bit. Honnestly, I can’t remember what this is. Of course I know it has something to do with access rights on a Linux filesystem, and I remember having checked Wikipedia or man at least 10 times about it but it just doesn’t stick in my head. So I’ll try to dig a little in its behaviour to make it stay up there !
How to set it
chmod +t somefile-or-dir
chmod 1xxx somefile-or-dir
Let’s play
I created 2 directories and 2 files, one with sticky bit set and one without for each type:
Read the rest of this entry »
Filed Under (Sysadmin) by Amandine on 16-02-2011
I love apache mod_rewrite. I often fight with it, but if you really want it you can do whatever you want. This time I wanted to find a way to call a file named after the called subdomain. I have a website called www.yellow-sub.net, and there is some subdomains like the-beatles.yellow-sub.net, john-lennon.yellow-sub.net and so on for each part of the website (That’s a SEO consideration in the beginning). I have only one virtual host for that website because I find it easier to manage like that, and I didn’t want to put the logic in the files for some reasons (and because working with rewrite rules is fun).
This is what I want :
- you call -> you get
- www.yellow-sub.net -> index.php?page=somepage
- the-beatles.yellow-sub.net -> index.php?page=somepage-the-beatles
- blahblah.yellow-sub.net -> index.php?page=somepage-blahblah
The page parameter will in fact call a different page with name “somepage-blahblah.html”, and I wanted it to work for every single subdomain (if it doesn’t exist it will anyway be redirected to www home page)
The closest way I found was to use %{HTTP_HOST} in my rewriterule :
RewriteCond %{HTTP_HOST} !^www\.yellow-sub\.net$ [NC]
RewriteRule ^/$ /index.php?page=somepage-%{HTTP_HOST} [L]
Read the rest of this entry »
Filed Under (Sysadmin) by Amandine on 29-12-2010
I’m sure you heard of the new unofficial domain registry 42registry, who let you register domains like something.42. If you didn’t, go on there website and read, cause I found this very interesting, funny, and it made me want to try :)
So, after registering sysadmandine.42 domain name, I tried to surf on it. But I didn’t want to spend time to configure a secured but open bind on one of my servers, so I opted for the easy way : my local computer is on Ubuntu, Ubuntu is perfectly able to provide me a bind, so let’s go :
$ sudo aptitude install bind9
Read the rest of this entry »
Filed Under (Sysadmin) by Amandine on 13-08-2010
Sometimes, you need more space on a virtual machine disk than you thought in the beginning. Hopefully, if your domU disk is in a .img file, you can do it quite easily (you can do it easily with lvm partition too, even if it’s a different method). Here’s how to do it, as root of course :
- Check your partitions in your domU :
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda2 10G 706M 8.8G 8% /
varrun 2.1G 44K 2.1G 1% /var/run
varlock 2.1G 0 2.1G 0% /var/lock
udev 2.1G 16K 2.1G 1% /dev
devshm 2.1G 0 2.1G 0% /dev/shm
- create empty file of the size we want to add : (10gb here)
dd if=/dev/zero of=/xen/temp_expand bs=1024k count=10000
Read the rest of this entry »
Filed Under (Sysadmin, Tips) by Amandine on 23-02-2010
I’m trying to develop a new website to increase my php object oriented skills. For this new website, I want every request for any url that doesn’t match a actual file on the disk to be redirected to index.php (to handle parameters in fact). Easy with apache2 rewrite rules :
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^/(.*)$ /index.php?rt=$1 [L,QSA]
This means : if the requested file is not a real file, and isn’t a directory, and isn’t a symlink, then redirect to index.php.
I was really surprised to discover that it doesn’t work. Though, everybody seems to use this syntax ! I checked my apache version : Apache/2.2.9 (Debian), nothing special with this one I guess.
To understand what Apache was doing with my rewrites, I activated the rewrite log :
RewriteLog /var/log/apache2/rewrite.log
RewriteLogLevel 5
Read the rest of this entry »
Filed Under (Sysadmin) by Amandine on 12-02-2010
Here’s my linux favourite commands, by type :
Scripting
1. egrep : aaah… if I had to keep only one, this would be the one I’d choose… can’t spend 10 minutes without using it.
2. sed : because I always need to replace something by something else 10 times on each line in huge files
3. xargs : helps me avoid the for loop, shorter to write, easier to remember and understand when you find it in history
4. awk : for me the most difficult one to use, but I so know that it can do just what I want that I always take the time.
Read the rest of this entry »
Filed Under (Sysadmin) by Amandine on 12-02-2010
I was wondering how crypt does the encryption of passwords. Once I needed to compare two .htpasswd files, I was quite sure that both had the same password for the same user, but the encrypted strings didn’t match. I tried to regenerate the encrypted string several times, and here’s what I got :
$ htpasswd -nb someuser somepwd
someuser:qQD5GYrJQSIwk
$ htpasswd -nb someuser somepwd
someuser:zD9H4NFRuDjk6
$ htpasswd -nb someuser somepwd
someuser:IK572FjeWHPYw
$ htpasswd -nb someuser somepwd
someuser:O2UkOjX3ynZCU
$ htpasswd -nb someuser somepwd
someuser:9hPT7IR/CN7MA
Read the rest of this entry »
Filed Under (bash) by Amandine on 08-02-2010
I often need to execute a loop x times, and I’m just too lazy to write a i++ style algorithm… the command seq is made for me :)
Easy to use, just does what I need from it, here’s a extract from the man page :
NAME
seq - print a sequence of numbers
SYNOPSIS
seq [OPTION]... LAST
seq [OPTION]... FIRST LAST
seq [OPTION]... FIRST INCREMENT LAST
So…
Read the rest of this entry »
Filed Under (Sysadmin) by Amandine on 05-11-2009
Pound is a wonderful tool. It does just what you want, and does it good. Well, most of the time actually. Let me present it.
Pound is made by a Swiss company named Apsis GmbH (http://www.apsis.ch/), and its purpose is to achieve 3 goals :
- reverse proxy
- load balancing
- HTTPS front-end
You don’t need to use all 3 features, but you might need it anyway. Don’t assume it can do other things : No caching, no webserver, no acceleration. Just what it’s meant for.
Read the rest of this entry »
Filed Under (Sysadmin) by Amandine on 30-10-2009
I have this very special server at work : a sunfire x4200 8 core 8GB RAM
To use the full given power, I tried to install xen on ubuntu, but it were freezing all the time. It seems to be a “TAP” problem, but I couldn’t fix it.
So I tried a Debian 5.0.3 dom0, and the problem is slightly different : now the domU won’t find its drives if I use “tap:aio”.
Ok, go back to the old “file:” driver.
This one is using loop devices to enable the drives, and only 8 default loop devices are enabled on debian (/dev/loop0 to /dev/loop7). As I want 7 domU, and at least 2 drives for each one (root and swap), I need more than 8 of these.
Here’s how to add more loop devices :
Read the rest of this entry »