afpd on Debian

afp share

When you are on #OSX regularly, CIFS/SMB is not that good option. What you would need to do so is installing afpd and bonjour. Obviously, they won’t name as they are in Apple product. Their package names are netatalk and avahi consecutively. Installation is as easy as one regular apt-get.

Setting up both at the same time, then we would configure later.

# apt-get install netatalk avahi-daemon libnss-mdns

After installation, we need to configure a bit for both service.

afpd — what we are going to do now is to disable legacy Apple File protocol back in pre #OSX time which we don’t need.
# vim /etc/default/netatalk

 # enable new service
CNID_METAD_RUN=yes 
AFPD_RUN=yes 
# disable legacy service 
TIMELORD_RUN=no
A2BOOT_RUN=no
ATALKD_RUN=no
PAPD_RUN=no

All you need to do is making sure if these values are assigned correctly. Next, we have to declare sharepoint. You can append to these new settings to the end of this file.
# vim /etc/netatalk/AppleVolumes.default

/your/path VolumeName allow:@groupname options:usedots,upriv

Example:
You can do a share by username.

~/ "$u" allow:myusername options:usedots,upriv

For Time Machine, you can do this; it might be a good idea to limit volume size before Time Machine takes over the whole drive by using volsizelimit:100000 in MB; 100000 = 100GB

/home/username/TimeMachine "TimeMachine" allow:myusername options:usedots volsizelimit:100000

Restart netatalk to see the change
# /etc/init.d/netatalk restart

For more info: http://linux.die.net/man/5/applevolumes.default

Avahi (Bonjour)
Next, we need to do help setting up bonjour or avahi. A setting file is /etc/nsswitch.conf which is belong to mDNS (mDNS comes helping hostname resolution.) we need to enable mdns module by add “mdns” to hosts: line as following:

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns

Last but not least, we customize how any device see afpd. Create a new file named /etc/avahi/services/afpd.service and paste this in.

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
 <name replace-wildcards="yes">%h</name>
 <service>
 <type>_afpovertcp._tcp</type>
 <port>548</port>
 </service>
 <service>
 <type>_device-info._tcp</type>
 <port>0</port>
 <txt-record>model=MacPro</txt-record>
 </service>
</service-group>

You can change model to something else which change icon you will see on #OSX client side. AppleTV, iMac, MacPro, Xserve, MacBook, MacBookPro, MacBookAir, Macmini, etc.

Restart avahi-daemon to see the change

# /etc/init.d/avahi-daemon restart

Popularity: 1% [?]

Colorizing VIM

The more you use vim, the further you are from all other text editors. However, when you get your new box ready, vim is likely not to enable syntax color by default. You can choose to do that individually or for everyone. If you decide to let other manage this on their own, you can just create ~/.vimrc or you can opt for system wide setting in /etc/vim/vimrc.

in /etc/vim/vimrc, you will find:-

" syntax

on which mean it’s commented out. What you have to do is uncomment it, save, and try. For ~/.vimrc, you can just touch that file and type syntax on or you can just do:

$ echo 'syntax on' > ~/.vimrc

That should do it.

Popularity: 2% [?]

Better Firefox toolbar in Linux

While it looks just right in Windows, default toolbar in Linux just looks way too bulky: gap & padding for buttons are just too big. However, none can’t be customized. Here is what I configure mine.

For Firefox, it will read userChrome.css for custom UI. It’s located in /home/<user-name>/.mozilla/firefox/<random>.default/chrome/ You can just create one.

/* Menu Bar - Shrink and Fade Text */
#navigator-toolbox .menubar-text {
	font-size: 70% !important;
	color: #999 !important;
	}

/* URL Bar and Search Bar - Shrink and Fade Text*/
#urlbar, #searchbar{
	font-size: 85% !important;
	color: #333 !important;
	}

/* Tabs - Shrink Font and Height*/
.tabbrowser-tabs {
	font-size: 80% !important;
	height: 20px !important;
	}
.tabbrowser-strip {
	height: 22px !important;
	}

/* Bookmarks Toolbar - Shrink Font and Size*/
#PersonalToolbar {
	font-size: 90% !important;
	padding: 0px !important;
	margin: 0px !important;
	max-height: 20px !important;
	}
	/* Seperators - Remove */
	#PersonalToolbar toolbarseparator {
		display: none !important;
		}
	/* Toolbar Buttons - Reduce Margins */
	#PersonalToolbar toolbarbutton {
		margin: 0 -5px 0 -1px !important;
		}
	/* Toolbar Icons - Shrink and Reduce Margins */
	#PersonalToolbar .toolbarbutton-icon {
		max-width: 12px !important;
		max-height: 12px !important;
		margin: 0px 2px 0px 0px !important;
		}




This will reduce button size into what it should be. Surely you can adjust suiting your preference easily with a bit knowledge of CSS.

Popularity: 4% [?]

Linux 101: file structure/hierarchy

File structure is the basic things people get confuse when start using Linux. Most people nowadays are likely to stick with Windows’ idea, e.g.C:\Windows\ or C:\Program files\ or C:\Users\xxxx. That’s pretty easy to understand. *nix file structure was confusing at first, but it’s not that hard to understand. In order to learn using it, then you have to know where things are first.

In *nix system, everything is a file. Whatever they are, they are represented in file format. There is no extension to distinguish any type of file, but utility called file can identify it. directory is also one kind of file. Process is also represented in file. We’ll talk about ‘file’ in detail later. Ok, I got to start with what each of directory in *nix is for.

/ Every tree needs root, file structure is also the same.
/boot This is for boot loader files, e.g. GRUB, KERNEL, SYSTEM.MAP, VMLINUZ, INITRD, …
/bin bin == binary; it contains commands stuff and /bin is for essential ones only.
/etc This is for any system configuration; if you ever need to adjust things, this is likely to be the place to go.
/sbin it doesn’t differ to /bin that much, but it contains system utilities that don’t need that much speed.
/home This is the same as c:\users in Windows’ sense. Just contain any thing of each user in /home/<usr> commonly.
/usr This is not where users store file, but it has hierarchy like / too. /usr/bin, /usr/lib, /usr/local/share, /usr/share, for example. What difference between /usr/bin and /bin is /bin usually contains kernel command while /usr/bin contains user commands that are not related to kernel/OS At first, /bin was designed to use in different disk (faster one) and the rest will be in /usr/bin or /usr/local/bin.
/usr/bin
vs /usr/local/bin
The difference is /usr/bin stored user commands while /usr/local/bin stored local software
/opt That’s for application software, such as Thunderbird and such.
/root This is home for root =)
/tmp tmp == temporary; it uses as its name.
/var var == variable. It uses to store configuration, logging and application information
/mnt mnt == mount point; some distros use this, some don’t, some even use /Windows or /media instead of this

note: basically each of these will be in different partition/disk as well, so there is another factor involved, speed. That’s why it has commands in all over the place. Some utilities are just more important than others.

Above matrix should cover basic filesystem structure. As usual, different distribution might have a bit of different point of view, but they all share the same idea =) After knowing each of these files are for, then you will know where to expect particular files or things you need. Have fun with *nix experience.

Popularity: 14% [?]

How to add fonts in Linux manually

Well, fonts are the weakest link in Linux in my opinion. Sharpness, crispness, or smoothness are just not right. That’s most likely to be the reason why Linux never gains that much user like Windows or even Mac in desktop environment.

Besides using package manager which is truly find and click, when you are going to add fonts in Linux by yourself, you should put in fontpath. They are in /usr/share/fonts or /usr/local/share/fonts or ~/.fonts/ then what you have to do is copying.

$ cp *.ttf ~/.fonts/

At this point, it will not notice the change yet. New fonts will not be visible. You have to run command, to update and rebuild its of fonts first.

$ fc-cache

That would be it. However, if you decide to put fonts in somewhere else, you have to edit ‘fonts.conf’ to add font directory in the list as well.

$ vi /etc/fonts/fonts.conf

Where <!— font directory list –> is by adding

<dir>/opt/fonts/xxxx</dir>

Then rebuild the list and restart x (easiest way is Ctrl + Alt + Backspace). At this point, all fonts will be available to use =) Anyway, I still don’t think font smoothing or crispness in Linux is good enough so far. If that day comes, I bet Linux will outpace Mac and Windows in desktop environment surely.

Popularity: 3% [?]

Linux 101: grub recovery

When you messed with many OSs, boot strap loader might point to somewhere you don’t want it to be. grub considering the best – easiest? – to deal with many OSs and of course, it’s easy to tweak or  adjust as well.

Firstly get into any sort of shell. There are basically 2 parts needed to be done: set active partition and set MBR back to point at grub again. The first part is fdisk, there is ‘m’ for help. All you have to do is set the partition where grub is to active. Others are not.

The second part: set MBR point back to grub. That’s easy via grub command shell

grub-shell

The easiest way to find partition referenced by grub is to find it

find /boot/grub/menu.lst

Then you have to set toot and setup the hard drive. Then you are all set. For grub menu, Linux needs

Title XXX
   root (hd0,0)
   kernal /boot/vmlinuz root=/dev/…bla bla bla
   initrd /boot/initrd

For Windows, you just need to link to Windows boot loader again.

Title Windows XX
   rootnoverify (hd0,0)
   chainloader (hd0,1)+1 # this is Windows partition.

That’s all you have to do. pretty easy, right?

Popularity: 2% [?]

How to configure ftpd — proftpd

I’m planing to write Unix 101 — beginner for beginner. Since I started getting into shell much more than GUI, I liked how simple Unix is. However, I’m no pro as Unix user; Thus, I probably have an idea what Unix 101 should be like much more than reading through Unix manual indeed.

By the way, after trying Windows Server 2008 standard for a month or so, I found that there were too many hassles involved. It was good to have GUI or wizard to walk through but sometimes it just gave us more confuse. Believe it or not, I can’t even get FTP server on IIS work properly :-( Although the alternative, like FileZilla server, works flawlessly, it’s just not right using 3rd party while using server edition and that’s already equipped with FTP server. It’s just like using Apache HTTPd on Windows server; why just use IIS or just change to Linux box for good =)

So I choose to have less complicated way–Ubuntu. Well, the reason why I choose Ubuntu is nothing but easiest. In Ubuntu server 8.10, there is no ftpd by default for whatever reason. So adding one of them is a must. Because There are many many choices, I don’t know what is good too. I just choose proftpd and I find that’s easy to configure. That’s simple.

Firstly, install it! — remember this is Ubuntu–it’s debian. Your distro might use something else, but that differs when installing only.

$ sudo apt-get install proftpd

Done with ftpd installation. That’s easy, isn’t it? Then we have to do configuration, briefly we have to:-

  1. manage user
  2. edit proftpd.conf
  3. start/restart proftpd

For managing user, you might use the same account in OS, so that you don’t have to do a thing in this step, but if you want to use isolated user for extra security (?!?), go for it.

useradd [ -u uid ][ -g gid ][ -G gid [,gid,.. ]][ -d dir ][ -m ][ -s shell ][ -c comment ] loginname

You could just have only parameter you want, then the rest would be default value

$ sudo useradd -d /home/ftp ftpuser

$ sudo passwd ftpuser //for creating password for ftpuser

For configuring our ftpd, here is  the most important part–editing /etc/proftpd/proftpd.conf. In my case, I have login thru ssh, so no GUI no gedit no mousepad, nano is my first choice of text-editor here. You guys might us different one as you like.

$ sudo nano /etc/proftpd/proftpd.conf

what you need to configure basicly are the following:-

ServerName            "10nas"
  ServerType            standalone
  # Set the user & group server
  # normally runs at.
  User                nobody
  Group                nogroup
  # Set default root as a NAS
  DefaultRoot /mnt/nas
  # This is for keeping FTP user
  # inside DefaultRoot only!
  DefaultRoot ~
  # Valid Logins
  <Limit LOGIN>
  AllowUser x1
  AllowUser x2
  AllowUser x3
 AllowUser x4
  DenyALL
  </Limit>
  MaxLoginAttempts 3
  # well, <Directory> /mnt/nas> looks weird,
  # but it's not a typo!
  <Directory> /mnt/nas/>
  # This is basic security for initial
  # file permission
  Umask 022 022
  AllowOverwrite on
      <Limit ALL>
      Order Allow,Deny
      AllowUser x1
      AllowUser x2
      AllowUser x3
      AllowUser x4
      Deny ALL
      </Limit>
  </Directory>

Commands to start/stop/restart the service is similar to any service

$ sudo /etc/init.d/proftpd start
$ sudo /etc/init.d/proftpd stop
$ sudo /etc/init.d/proftpd restart

Well, this should be enough for setting up basic FTP server securely. =)

Popularity: 6% [?]

How to install Thai input in Eee PC

I don’t know if this is useful, but I found many sites mentioned that Eee (Xandros) is not capable of handling Thai–only for input, I guess. So this could help somebody who passes by and is finding how to add Thai as an input language.

Originally, Eee PC comes with English and Chinese, of course. Thus, it needs something to switch between those languages already. Luckily it is SCIM - Smart Commom Input Method Platform. If you are familiar with another linux distro and using other language besides English, you will know it well. This is all you have to know in order to add Thai or any language as a keyboard input.

image

source: screenshot of openSUSE 10.3

Basically, SCIM has 2 parts which are core programs and tables (.bin & .png) for any languages. Usually, when you install SCIM, it will bundle tons of table for you to choose, but unfortunately Eee does have only English and Chinese. So, what you have to do is copying the table for the language you need into SCIM directory. That’s it!

I upload all non-CJK tables for SCIM in Sky Drive here, it’s only 110kB, so you may add all that or just choose what you want.

After you got the file, you have to extract and put them in

/usr/share/scim/

or if you want to add only Thai language, you have to copy Thai.png in icons folder to /usr/share/scim/icons and Thai.bin in tables folder to /usr/share/scim/tables. (you have to gain root privilege in order to do so)

image

Then you have to set for a hotkey for switch the language a bit. You might not use grave accent though since grave button is not on the right place as usual keyboard. I found that Ctrl+space is very comfortable way to switch, but it’s just my way.

Step-by-Step: how to add thai for eee pc:

1. download SCIM table from my Sky Drive here
2. Extract to where you want, assume /home/user
3. get into Terminal (Ctrl + Alt + T)
4. gain root privilege

sudo -i

5. copy 2 files needed for a lauguage you want

cp /home/user/scim/icons/Thai.png /usr/share/scim/icons/
cp /home/user/scim/Tables/Thai.bin /usr/share/scim/tables/

6. right-click on SCIM and set for a hotkey
7. you are now able to type Thai on Eee PC, congratulation!

#—–added on 2007-12-25—- การลงภาษาไทยใน eee pc ——–#
Additional part for you guys who prefer Pattachote keyboard layout (ปัตตะโชติ บน eee pc) pattachote on Eee; ปัตตโชติ บน eee

First of all, you don’t have to follow the step above. You have to do something a bit different which is adding scim-thai repository.
1. Get into terminal by ctrl+alt+t
2. add repository that has scim-thai (one I know is from linux.thai.net)

sudo kwrite /etc/apt/sources.list

add the following line into the file, then save and exit.

deb http://linux.thai.net/apt ./

3. update the repositories and install scim-thai in terminal

sudo apt-get update

You may have to try several times until you haven’t seen an error. Then:-

sudo apt-get install scim-thai

apt-get_scim-thai
4. once you finished installation; restart once–I don’t think it needs to but scim sometimes confuses about adding new stuffs.
choose_layout_in_scim-thai
5. After you get back; setting in SCIM then you all set!
test_keyboard_on_eee

Happy New Year! I hope you find some fun with your Eee PC!

Popularity: 26% [?]

how to config Samba server and user

First, I was switching from all time Windows user to Linux user, more specifically Ubuntu–first Linux that I can use regularly. I was wondering if I can share files over the network with Windows as well. I know that there is Samba service out there but I don’t know how to configure it properly. I messed things up as usual; all I knew to make it work is editing /etc/samba/smb.conf as security=share. Then I could get in there easily but no protection at all. Now I know, so I think it might be a good idea to explain in my ways instead of reading any-distro-docs which sometimes is too complex for novice users.

First of all, you have to install Samba server. I won’t go through this process because if you don’t know about this, you have to find out and get used to Linux first. My recommendation is trying with Debian, such as Ubuntu. It’s really easy to understand.

Second, we have to configure the smb.conf file. This time you have to be as “root” to make a share folder. You have 2 choices here, GUI or editing the file. I found that GUI is easy to understand but I can’t get it work for some reasons, thus I choose the traditional way :-P

After we already created share folders, we have to create a user for Samba too. This the point I misunderstood for a while; I thought that Samba will use the user from the system; however, it’s not and system and Samba user are not the same as well.

These 3 steps are all you have to do to make it work perfectly. I brief all the processes first so you can imagine what we are doing in each step.

for editing Samba configuration file (smb.conf) you have to get in there

sudo gedit /etc/samba/smb.conf

once you get in there you will find a lot of comments and samples; you may go through the file for more understanding of each. However, we will pay attention to how to set share folder.

[share-name]
path = /media/hdax/xxx/
comment = whatever you want
available = yes
browsable = yes
public = yes
writable = yes/no

This is what you have to insert at the end of the file. After you put the proper value, you will be able to see this share from another Windows PCs. However, you can’t browse the file right now because of login window. Whatever user and password you fill are not working :-P Don’t be surprise, that’s normal. You still have to know 2 more values which are

valid user = user-name
guest ok = yes/no

the first one, valid user, is which user you give permission to read and/or write. Another one, guest ok, is to enable guest user which is read-only user.

After this step, if you enable guest user, you will be able to see the share folder without any problem. If not, you still have to go on setting user.

For creating user, you will run the smbpasswd utility to create user and password

sudo smbpasswd -a user-name

Then you have to add that user to smbusers file

sudo gedit /etc/samba/smbusers

What you have to put in there is this form

system-user-name = “smb-user-name”

As you see, you may use Samba username (is what you add in smbpasswd) that differs from your username in the system depending on choice of preference.

All these methods above, you will be able to make many share folders with many conditions as you wish :-P

Note: If you just want to share all share folders without any restricts, you may change the line security = user in smb.conf to security = share and that’s all set.

Popularity: 13% [?]