Tuesday, July 17, 2007

Archlinux setup tutorial

Today I am going to write a quick tutorial on installing and getting a working system using Archlinux. I believe that this is one of the best distributions available, if you are willing to work and start learning something about the fascinating Linux world. As a Slackware user for almost 5 years, I recently switched to Arch because I think that it has some very interesting features that lack in Slack, such as a great package manager and platform specific compiling (it is built for the i686 platform). You get all the nifty features like bleeding-edge packages and standard 2.6 kernel (hehe slack) but you still control the operating system. So, without further ado, let us begin.

Getting the ISOs

I just grabed a copy from my local mirror and burned it on a CD. I only got the base system iso as it is faster to download and I always get packages through pacman. Leave the CD in the tray and reboot your system. Following the instructions on the screen you should get a command prompt:

[Arch Linux: /]#

Partitioning

I have my hdd already partitioned and I won't get into technical stuff such as partitioning your drive. You get fdisk and cfdisk for that and there are plenty of tutorials available on google for such. Anyway, here is my hdd layout:

/dev/sda5 - / - 10GB
/dev/sda6 - /boot - 1GB
/dev/sda7 - swap - 3GB (I know that it's not necessary to have such a big partition for swap but I also use my box as a server)
/dev/sda8 - /usr - 15GB
/dev/sda9 - /home - 15GB (you will download por.... ahem ... pro... grams won't you :) )

Basic setup

Okay. At the prompt just type in /arch/setup and you should be welcomed by a dialog based installation program.

1. You are prompted to choose your installation media. I usually (I mean always) go for option 1 - CD-ROM or OTHER SOURCE

2. Prepare hard drive

  • I only go for option 3 and assign mount points to my partitions. I choose ext3 for my filesystem although I believe that xfs is better than ext3 (bad habits die hard).
  • Be careful that you first have to choose your swap partition.
3. Select packages. As I only downloaded the base ISO, guess how many options I have:)
4. Install packages - pretty straightforward. I do not choose to keep the packages in cache as I won't have any further use for them.
5. Configure system - use nano or vi to your liking (I recommend nano if you want just easy editing)
  • Use hwdetect
  • No booting from usb devices (at least in my case)
  • No fireware
  • No pcmcia devices
  • No nfs shares
  • No software raid arrays
  • No lv2m
  • No encrypted volumes
  • No custom DSDT files
  • /etc/rc.conf - this is your general config file so be careful what you write in it
  1. Timezone - i change mine to Europe/Bucharest
  2. MOD_BLACKLIST=(nvidiafb) - I add this since nvidiaframe buffer gives me an error while trying yo compile my nvidia graphic card
  3. HOSTNAME="something"
  4. Modify eth0="eth0 ip_address netmask subnet_address broadcast broadcast_address"
  5. Modify gateway with your default gateway and be sure to delete the preceding ! on ROUTES=(!gateway) as this disables the gateway (nasty)
  • hosts - add your host that you put in the HOSTNAME variable in /etc/rc.conf (above)
  • /etc/resolv.conf - add your nameservers or you can just opendns
  • locale-gen - uncomment the line with en_US.UTF-8
  • Set the root password
  • Choose the mirror closest to you
6. Install the kernel - you only have one option here too
7. GRUB is okay for me - but I have to uncomment the Windows lines :-S... sorry guys ... hem... not me :)

Now go ahead and reboot. All should be fine.

Adding a user

Just type adduser at the command prompt and follow the instructions on the screen. Please be advised that I use a sudo environment and as such, a good password for the username is necessary.

Upgrading the system

just run pacman -Syu at the command prompt. It will take a while (not that much really because there aren't so many packages installed yet).

Sudo environment

As I believe that the Ubuntu philosophy regarding using sudo is very good, on all my systems I get sudo up and running. Here is how:

pacman -S sudo
Run visudo after that and just below root ALL=(ALL) ALL add user ALL=(ALL) ALL. Be careful please as this implies that the specified user will have all the privileges root has.

Xorg setup

It is as simple as

sudo pacman -S xorg

After that all you need to do is generate an /etc/X11/xorg.conf. I like the nvidia setup tool for Xorg so let's go ahead and install some proprietary drivers.

sudo pacman -S nvidia
sudo nvidia-xconfig
cp /etc/skel/.xinitrc ~

Now let's edit the xinitrc file and delete the comment before exec startkde (as we will be using kde).

KDEMOD

Kdemod is a modular and patched version of KDE for Archlinux. It's really great. All you need to do is to edit the pacman file:

sudo vi /etc/pacman.conf
Add at the end
[kdemod]
Server = http://kdemod.ath.cx/repo/current/i686
sudo pacman -Syu
to get the list for the kdemod repository
sudo pacman -S kdemod - go get a cup of coffee or something as this surely takes a while
sudo pacman -S kdemod-kdebase-kickoff
sudo pacman -S kdemod-kdebindings
sudo pacman -Rd libbeagle
sudo pacman -S kdemod-kerry
sudo pacman -S kdemod-beagle
sudo pacman -S kdemod-applets kdemod-tools
sudo pacman -S kdemod-kdeutils-kcalc kdemod-kdeadmin
sudo /opt/kde/bin/apply_kdemod_theme


Accessing your NTFS partition

Okay guys I'm guilty. I do have some ntfs partitions on my desktop. Here is how to access them:

sudo pacman -S ntfs-3g
sudo modprobe fuse
Add fuse to your /etc/rc.conf MODULES part
Edit your /etc/fstab file
Add the line:
/dev/sda1 /mnt/sda1 ntfs-3g defaults 0 0
And then let's remount all the drives (but be sure to create /mnt/sda1 first)
You now have read-write access to your ntfs drives.

Let's listen to some music

sudo pacman -S alsa-utils alsa-lib alsa-oss
sudo alsaconf
sudo alsamixer
sudo alsactl store
gpasswd -a user audio

Also be sure to add alsa to the DAEMONS line in /etc/rc.conf (you have to edit it as root).

Tips and tricks

  • Let users use usb sticks
gpasswd -a user storage
gpasswd -a user optical
  • Settings for firefox:
Proportional: Serif 16
Serif: Times New Roman
Sans: Arial
Monospace: Courier New 13
Minimum font size: 13
  • Settings for KDE
Go to Control Center. Replace color with cleanstick-black-font (you can find it on kde-look.org). Replace style and Window Decorations with Plastik.

  • Add hal to DAEMONS in /etc/rc.conf

Software ( great stuff to install )

sudo pacman -S firefox
sudo pacman -S ttf-msfonts ttf-cheapskate artwiz-fonts
sudo pacman -S amarok-base
sudo pacman -S rtorrent
sudo pacman -S acroread
sudo pacman -S jre
sudo pacman -S openoffice-base
sudo pacman -S screen
sudo pacman -S smplayer
sudo pacman -S flashplugin
sudo pacman -S pidgin

Well that's about it for tonight. Tomorrow we take a look at some of the config files for different programs. Yes I admit most of this stuff you could find on the Archlinux Wiki but I thought that bringing all of these together combined with my own experience of using Archlinux could be somewhat interesting.

Sunday, July 8, 2007

Very basic FAMP (Freebsd, Apache, MySQL, PHP)

As you may already know, I installed FreeBSD 6.2 last night. One of the primary uses of my machine is a web server complete with PHP and MySQL.

Installation is pretty straight-forward.

Apache 2.2


cd /usr/ports/www/apache22
# If you don't know where it is just do a make search name=apache22
make install clean
mkdir -p /var/www/htdocs
chgrp -R www /var/www/htdocs
chown -R www /var/www/htdocs
# Let anybody in the group add new documents
chmod g+w -R /var/www/htdocs
# Add myself to the www group
pw user mod my_user -G www
# Let's configure the damn thing
vi /usr/local/etc/apache22/httpd.conf
# Changed DocumentRoot to /var/www/htdocs
# Changed ServerName to http://my_private_adress:80
# Changed ServerAdmin to my email address
# Changed AllowOverride All (as
# anybody can modify their directories with .htaccess)
# Now let's start it
/usr/local/sbin/apachectl start
# And add it to /etc/rc.conf to start automatically on every
# system boot.

echo 'apache22_enable="YES"' >> /etc/rc.conf



MySQL 5.1


cd /usr/ports/databases/mysql51-server
make install clean
rehash
# Let us start the database installer
mysql_install_db --user=mysql
chown -R mysql /var/db/mysql/
chgrp -R mysql /var/db/mysql/
/usr/local/bin/mysqld_safe -user=mysql &
# Start it every time the system starts
echo ‘mysql_enable=”YES”‘ >> /etc/ rc.conf
# Change the root password
mysqladmin -u root password newpassword
# Copy the config file
cp /usr/local/share/mysql/my-small.cnf /var/db/mysql/my.cnf
# Add another user (it's generally not a good idea to work with
# root)

mysql -u root -pnewpassword
mysql> GRANT ALL PRIVILEGES ON *.* to 'user'@'localhost' IDENTIFIED BY 'another_password'
mysql> quit



PHP 5.2


cd /usr/ports/lang/php5
make install clean
# You have to choose the option for Apache 2.2
cd /usr/ports/lang/php5-extentions
make config
# Choose Mysql, GD, Zlib, PDF, Mbstring and any other extension you would like
make install clean
# Apache configuration
# After all the LoadModule lines add:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.html index.php
# Uncomment the Include etc/apache22/extra/httpd-userdir.conf line
# You now have a per-user web account in /home/user/public_html
# Restart apache
apachectl restart



All is done. Have fun. By the way, you can copy stuff from the outside with scp (you did remember to let ssh connection didn't you?)

FreeBSD 6.2

Although I had FreeBSD 5.2 i decided to install the new version FreeBSD 6. I wanted a clean install (as I really didn't have any important stuff on my server and I had a lot of time to spare). I downloaded the first cd off ftp.ro.freebsd.org
and started the sysinstall utility. I chose a standard instalation with auto partitioning of my 34GB drive (as the 17GB one I'm saving for the Document Root of the webserver and for the /home directories). The installation crippled when copying GENERIC (maybe the media was faulty) and because I didn't have any other blank CDs in my room I decided to try the FTP install. What do you know! I changed the network card on my server and the guys from my ISP make MAC-based authentification. Oh no! What am I supposed to do? Maybe this is just not my night for installing FreeBSD. I luckly found somebody from my ISP online (it was almost 1 AM) and requested my MAC address from their database. I went to the Fixit menu and made a emergency shell on tty4. Yupee! Who knows, maybe I will get lucky after all.


# ifconfig fxp1 ether 00:00:00:00:00:00 <- (my real MAC here)


(Don't you just hate the way freebsd sees your devices?)

As FreeBSD doesn't require to take down the interface for changing MAC address I jumped to my instalation screen (Alt+F1 btw), entered my IP configuration and from then on everything went smoothly. I no time I was sitting in front of a command prompt.


#


Pretty ugly since I am used to my bash shell with auto-completion and pwd. This could be fixed in no time:



# pkg_add -r bash
# chsh -s bash
# bash


Ah, much better now. The next step was to install some dearly applications to me: sudo and screen. But where are they?


# cd /usr/ports
# make search name=sudo
Path /usr/ports/security/sudo
#make search name=screen
Path: /usr/ports/sysutils/screen
# cd /usr/ports/security/sudo
# make install clean
# visudo
Added user ALL=(ALL) ALL after root
# cd /usr/ports/sysutils/screen
# make install clean


That was it. Beautiful and simple.

I then logged out of my machine and entered as my user. Sudo is really beautiful. I started to get the hang of it while I was testing Ubuntu and I consider it a really neat ideea. Screen is just one of those app that you can't live without while running a headless server over ssh. Maybe I will come back with a tutorial on screen in a future post.

FreeBSD is just simple and neat. Although I never tested it as a desktop operating systems, I always found it as a very nifty OS for servers. I will come back later with some more tutorials on other things I did since install.

Tuesday, July 3, 2007

Slackware 12

A aparut Slackware 12. Primele noutati pe care le-am vazut ar fi un kernel default din branch-ul 2.6 (mai precis 2.6.21.5) - ultimul conform kernel.org, KDE 3.5.7, XFCE 4.4.1, HAL (o adaugire mai mult decat asteptata intrucat dbus si hal sunt absolut indispensabile in folosinta cea de toate zilele in KDE) si udev. Din pacate, inca nu exista un packet manager decent, rapid, stabil si oficial (in stable si nu in extra). Desigur exista swaret si slackpkg dar sunt cu cativa ani in spatele portage, aptitude sau chiar pacman .

Din cate vad, Slackware in sfarsit vine cu pachete la zi (de la kernel pana la browser sau suita office) dar in fata unor distributii ca ArchLinux (destinat utilizatorilor mai "copti" in ale Linuxului) sau Ubuntu (destinat incepatorilor) incepe sa-si piarda din savoare. Da! Recunosc, Slackware este inca dupa parerea mea printre cele mai bune distributii, dar pur si simplu nu mai am timp pentru a sta sa compilez si sa bibilesc sistemul pentru a-l aduce la o forma cat mai apropiata de gustul meu.

Ca parte buna, nu pot sa nu remarc timpul scurt de aparitie al versiunii cu numarul 12. Dupa ce versiunea 11 am asteptat-o cu infrigurare in suflet peste 2 ani, in sfarsit lucrurile s-au miscat mai repede, poate si datorita faptului ca acum distributiile sunt semnate "Pat and the Team".

Incercati-l de aici:
ftp://ftp.evolva.ro/linux/slackware/slackware-current-iso/

O sa-l il testez in curand si o sa revin cu niste "food for thought" dar pana una alta cred ca am gasit distributia mea de suflet.