Sunday, June 10, 2007

How to Add Startup Programs (Linux & FreeBSD)


This applies to different desktop managers (XDM, GDM, and KDM)

newemachine$ vi ~/.xsession

then put your commands to the following in the file

#!/bin/sh
gnome-terminal &
exec /usr/bin/gnome-session

This runs gnome-terminal after you log into a Gnome session. You can substitute 'gnome-terminal' with other commands that you want to run. 'exec /usr/bin/gnome-session' is required here; otherwise, as soon as starting gnome-terminal process finishes, you will be taken back to the log in window. The directory of window managers such as Gnome varies from distribution to distribution. If you run a different window manager, you want to change '/usr/bin/gnome-session' accordingly.
newemachine$ chmod u+x ~/.xsession
.xsession has to be executable to get this working.

Saturday, June 2, 2007

Learning FreeBSD


How to Install a FreeBSD Application

  • install pre-compiled applications
  • newemachine# pkg_add -r bash
    The above command installs precompiled Bash application.

  • install ports
  • newemachine# cd /usr/ports/www/bash
    newemachine# make install clean
    The above command download necessary source pre, then compile and install it.

How to find a FreeBSD Application
  • Option 1: (If you know the exact application name)
  • newemachine# whereis xclock
    xclock: /usr/local/bin/xclock /usr/share/man/man1/xclock.1.gz /usr/ports/x11/xclock

  • Option 2:
  • newemachine# cd /usr/ports
    newemachine# make search name=xclock
    Port: xclock-1.0.2
    Path: /usr/ports/X11/xclock
    Info: Analog and digital clock for X
    .......

How to Give User Superuser Privilege
  • allow a user to sudo
  • newemachine# pkg_add -r sudo
    newemachine# /usr/local/sbin/visudo

    then add the following line after 'root ALL=(ALL) ALL'
    shawn ALL=(ALL) ALL
    this gives user shawn the superuser privilege

  • allow a user to su
  • newemachine# vi /etc/group
    then add change 'wheel:*:0:root' to 'wheel:*:0:root,shawn', this adds user shawn to the wheel group which have the superuser privilege.

How to Configure X
  • create a X server configuration file
  • newemachine# Xorg -configure

  • test newly created configuration file
  • newemachine# X -config /root/xorg.conf.new
    If you see a gray screen with x mouse cursor, then X is running ok. Now Ctrl + Alt + Backspace to exit X

  • fine-tune X configuration
  • newemachine# mv /root/xorg.conf.new /etc/X11/xorg.conf

    Move tested configuration to the system-wide configuration directory
    newemachine# vi /etc/X11/xorg.conf

    Under Section "Screen", add a line DefaultDepth 24 after the line where it says Monitor "Monitor0"
    then under SubSection "Display", add a line Modes "1024x768" (#change to your own screen resolution) after the line where it says Depth 24
    newemachine# startx
    start the X server!
How to Configure Sound Card
  • load a set of common sound device drivers
  • newemachine# kldload snd_driver

  • test loaded sound card driver
  • newemachine# cat /dev/sndstat
    You will see something similar to the following:
    FreeBSD Audio Driver (newpcm)
    Installed devices:
    pcm0: at io 0xffa7f800, 0xffa7f400 irq 17 bufsz 16384 kld snd_ich (1p/1r/0v channels duplex default)
    This means that my actual sound card driver is snd_ich; therefore, I can load snd_ich instead of snd_driver.
    newemachine# kldload snd_ich

  • load modules at boot
  • newemachine# vi /boot/loader.conf

    add snd_ich_load="YES" to the file