# Short HOWTO/FAQ for FreeBSD 9 (Tutorial: How to leave paradi



## valsorym (Mar 25, 2013)

*
================================================
   How to leave paradise and become a deamon?
================================================
*​
Hi "Angels" and "Demons",
today I would like to share with you some of my HOWTO/FAQ.
For several years I have been studying  FreeBSD, and it is my notes for myself. I want to share this with you. Perhaps. this is to answer some questions beginners FreeBSD Angels.

P.S. Sorry for my bad English.
P.P.S. If you find something interesting, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.

*Content*​
*HOWTO*
1. Introduction in FreeBSD HOWTO.
2. Installing and configure FreeBSD.
. . 2.1. Create FreeBSD Live USB.
. . . . 2.1.1. Create FreeBSD Live USB (method of FreeBSD Developers).
. . . . 2.1.2. Create FreeBSD Live USB (method of VALSORYM).
. . 2.2. Partitioning a hard disk.
. . . . 2.2.1. Using gpart tool and UFS + J file system.
. . . . 2.2.2. Using fdisk tool and UFS + J file system.
. . 2.3. Installing FreeBSD 9.0.
. . . . 2.3.1. Installing FreeBSD on the UFS file system.
3. Configuration FreeBSD after install.
. . 3.1. Initial setup.
. . . . 3.1.1. Setting the date and time.
. . . . 3.1.2. Setting up the directory structure.
. . . . 3.1.3. Configure the bootloader menu.
. . . . 3.1.4. Customize text greetings.
. . 3.2. User management.
. . . . 3.2.1. Create, remove users account.
. . 3.3. Network configuration.
. . . . 3.3.1. Configuring the Ethernet.
. . . . 3.3.2. Configuration the WiFi (Intel adapter).
. . . . 3.3.3. Setting up SSH access.
. . 3.4. Install additional system files.
. . . . 3.4.1. Installing the Ports Collection.
. . . . 3.4.2. Installing FreeBSD source code.
. . 3.5. Fine-tuning FreeBSD.
. . . . 3.5.1. Build FreeBSD world.
. . . . 3.5.2. FreeBSD Kernel Configuration.
. . . . 3.5.3. Setting graphics mode in the console.
. . . . 3.5.4. Eliminating of demons cries.
. . . . 3.5.5. Check after crash disk.
. . . . 3.5.6. Locale UTF-8.
. . . . 3.5.7. Tuning and drivers.
. . 3.6. Additional settings.
. . . . 3.6.1. Configuring Sound Card.
. . . . 3.6.2. Configuring Xorg.
. . . . 3.6.3. Configuring nVidia Video Card.
. . . . 3.6.4. Configuring Intel Video Card.
4. Install and uninstall FreeBSD software.
. . 4.1. General theory.
. . . . 4.1.1. Finding application.
. . . . 4.1.2. Installation of the packages.
. . . . 4.1.3. Installation of the ports collections.
. . . . 4.1.4. Uninstall programs and clean debris.
. . 4.2. Installing the required software.
. . . . 4.2.1. Script automatic software installation (only from port collections).
. . 4.3. Setting up of special software.
. . . . 4.3.1. Databases MySQL55.
. . . . 4.3.2. Devel Ruby-Gems.
. . . . 4.3.3. Dynamic DNS.
. . . . 4.3.4. Editor Vim.
. . . . 4.3.5. Lang Python27 and Django.
. . . . 4.3.6. Sysutils Tmux.
. . . . 4.3.7. Web Server Apache22.
. . . . 4.3.8. Web Server Nginx.
. . . . 4.3.9. X11 Dwm (Part 1). . . . (Part 2).
. . . . 4.3.10. X11 Kde4.
. . . . 4.3.11. X11 Xcompmgr.
. . . . 4.3.12. X11 Xfce4.
5. Backup FreeBSD system.
. . 5.1. Backup of system.
. . . . 5.1.1. Dump and Restore.
. . 5.2. Backup of software.
. . . . 5.2.1. Create local repository.

*FAQ*
1. Databases
. . 1.1. MySQL.
. . . . 1.1.1. Short MySQL FAQ (Part 1).. . . (Part 2).
2. Programming
. . 2.1. Ruby.
. . . . 2.1.1. Ruby.
. . . . . . 2.1.1.1 Devel Ruby-Gems.
. . . . 2.1.1. RoR.
. . . . . . 2.1.1.1. Install Rails Framework.
. . . . . . 2.1.1.2. Create first RoR app.

........


----------



## valsorym (Mar 25, 2013)

*2.1.1. Create FreeBSD Live USB (method of FreeBSD Developers*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Create FreeBSD Live USB (method of FreeBSD Developers).
=============================================================================
-----------------------------------------------------------------------------
Note.
-----------------------------------------------------------------------------
    For use this method, you must have already installed FreeBSD any version,
    or run system with FreeBSD Live CD. If system run with FreeBSD Live CD
    you can use extra memory stick for downloading files that we need.

-----------------------------------------------------------------------------
Create FreeBSD Live USB.
-----------------------------------------------------------------------------
  I.Download FreeBSD-9.0-RELEASE-i386-memstick.img image file.
    1.  Create temporary folder.
        # mkdir ~/freebsd
        # cd ~/freebsd
        
    2.  Download a FreeBSD image file.
        A.  Download use csh interpreter capabilities.
            # set host = "ftp://ftp.freebsd.org/pub/FreeBSD/releases/"
            # set release = "i386/i386/ISO-IMAGES/9.0/"
            # set img = "FreeBSD-9.0-RELEASE-i386-memstick.img"
            # fetch $host$release$img
            # unset host release img
        
        B.  Fast download.
            **  Remove all space characters in this URL.
            # fetch "ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/i386/
                        ISO-IMAGES/9.0/FreeBSD-9.0-RELEASE-i386-memstick.img"

 II.Preparation of USB Flash Drive.
    Connect our USB Flash device and clear it.
    **  Assume that our USB Flash drive was defined as: /dev/da0.
    # dd if=/dev/zero of=/dev/da0 bs=64k

III.Create FreeBSD Live USB 9.0.
    Record the FreeBSD image file on our USB Flash device.
    # dd if=./FreeBSD-9.0-RELEASE-i386-memstick.img of=/dev/da0 bs=64k
    
 IV.Rewrite system parameters of our FreeBSD Live USB.
    Added opportunity write in root, and others sectors on Live USB.
    **  Now our flash drive has a slice: /dev/da0a.
    # moutn -t ufs /dev/da0a /mnt
    # set cmd = "/dev/ufs/FreeBSD_Install / ufs rw,noatime 1 1"
    # echo $cmd > /mnt/etc/fstab
    # unset cmd

    **  During markup of the disc, we will use the 4k alignment blocks. You
        must add the appropriate data to your FreeBSD Live USB. Assume that
        our HDD drive was defined as /dev/ada0 - is the drive on which
        we will be installing FreeBSD in the future, then:
        # vi /mnt/boot/loader.conf
        
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# SYSTEM
# + HDD.
kern.cam.ada.0.quirks="1"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

  V.Finish.
    Unmount all parts and restart your computer.
    **  After load real system rewrite root password use passwd tool.
    # cd /
    # umount /mnt
    # shutdown -r now

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 25, 2013)

*2.1.2. Create FreeBSD Live USB (method of VALSORYM).*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Create FreeBSD Live USB (method of VALSORYM).
=============================================================================
-----------------------------------------------------------------------------
Note.
-----------------------------------------------------------------------------
    For use this method, you must have already installed FreeBSD any version,
    or run system with FreeBSD Live CD. If system run with FreeBSD Live CD
    you can use extra memory stick for downloading files that we need.

-----------------------------------------------------------------------------
Required tools.
-----------------------------------------------------------------------------
  I.CD/DVD disk FreeBSD 9.0 or it ISO file.
    Our device: /cdrom.

 II.USB Flash Drive.
    **  In this example, we will use USB Flash drive 4G or more size.
    Our device: /dev/da0.

-----------------------------------------------------------------------------
Create partition on our USB Flash device.
-----------------------------------------------------------------------------
  I.Create new partitions.
    1.  Clean our Flash device.
        **  We use dd tool for clean our USB Flash device.
        # dd if=/dev/zero of=/dev/da0 bs=64k

    2.  Create a partitions.
        **  I want to create an universal device. USB Flash Drive must have a
            part that will store  personal information and this slice must be
            mounted in a working system. Accordingly, we use next partition:

                            +-------+------+-------+
                            | Label | Size |  F/S  |
                            |-------+------+-------|
                            | root  |   2G |  UFS  |
                            | heap  |    * |  UFS  |
                            +-------+------+-------+

        **  If your USB Flash Drive 8G or more - you can make the root
            partition size to 4G.
            
        **  The heap it is our special part for personal and system data.
            This part we will be mounted in /mnt/heap.

        # fdisk -BI /dev/da0
        # bsdlabel -w -B /dev/da0s1
        # bsdlabel -e /dev/da0s1

    3.  Use your editor (default vi editor) and edit open file:
        **  Not in any way not alter or delete the "c" label.

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# /dev/da0s1:
8 partitions:
#          size  offset   fstype  [fsize bsize bps/cpg]
    a:       2G      16   4.2BSD        0   0    # usbroot
    b:        *       *   4.2BSD        0   0    # usbheap
    c:  7823592       0   unused        0   0    # "raw" part, don't edit
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    4.  Check the results of markup partitions.
        # ls /dev/ | grep ^da0
        da0
        da0s1
        da0s1a
        da0s1b
        
        **  If you do not see anything like it, open file again and remove
            your errors:
            # bsdlabel -e /dev/da0s1

    5.  Formatting an all parts.
        # newfs -L usbroot -U /dev/da0s1a
        # newfs -L usbheap -U /dev/da0s1b

 II.Mount a parts.
    1.  Partition.
        # mount /dev/ufs/usbroot /mnt
        # mkdir -p /mnt/heap
        # mount /dev/ufs/usbheap /mnt/heap
        
    2.  Create additional folders.
        # cd /mnt
        # mkdir -p tmp var
        # chmod 1777 tmp

-----------------------------------------------------------------------------
Install FreeBSD 9.0.
-----------------------------------------------------------------------------
  I.Unpack the system on our USB Flash device.
    1.  Choose the directory with the installation system files.
        A.  On the installation CD/DVD disk FreeBSD 9.0 or it ISO file you
            need unpack the installation files to our FreeBSD Live USB.
            # mkdir -p /cdrom
            # mount -t cd9660 -o -e /dev/cd0 /cdrom
            # cd /cdrom/usr/freebsd-dist/
        
        B.  If you boot the system from FreeBSD Live CD just go to the
            /usr/freebsd-dist/ directory.
            # cd /usr/freebsd-dist/

    2.  Install the base operating system FreeBSD 9.0.
        A.  Unpack use csh interpreter capabilities.
            # foreach file (base.txz kernel.txz)
            ?     cat $file | tar --unlink -xpJf - -C /mnt
            ? end
                
        B.  Hand mode unpack.
            # cat base.txz | tar --unlink -xpJf - -C /mnt
            # cat kernel.txz | tar --unlink -xpJf - -C /mnt

        **  If you use FreeBSD 9.0/amd64 unpack too:
            # cat lib32.txz | tar --unlink -xpJf - -C /mnt

        **  You can unpack other files: doc.txz, ports.txz, src.txz - but
            this is not necessary.

 II.In order for our USB Flash drive had the status of "installation" - you
    must copy the installation files.
    1.  Copy system files.
        # mkdir -p /mnt/heap/freebsd/source/9.0/i386
        
        A.  If you use a CD/DVD Rom.
            # cd /cdrom/usr/freebsd-dist/
            # cp -R ./* /mnt/heap/freebsd/source/9.0/i386/
        
        B.  If you use a FreeBSD Live CD.
            # cd /usr/freebsd-dist/
            # cp -R ./* /mnt/heap/freebsd/source/9.0/i386/

    2.  Check the results.
        # ls /mnt/heap/freebsd/source/9.0/i386/
        MANIFEST    doc.txz     kernel.txz    src.txz
        base.txz    games.txz   ports.txz

    **  When we perform the installation of the system from USB Flash device,
        we will use these files.
        
III.Create a hard link to /usr/home/ directory.
    1. Create hard link.
        # cd /mnt
        # mkdir -p usr/home
        # ln -s usr/home home
        
    2.  Check the results.
        # cd  home
        # pwd
        /mnt/usr/home
    
 IV.Create /etc/fstab file on our USB Flash device.
    Open and rewrite /etc/fstab on our USB Flash device.
    # vi /mnt/etc/fstab
        
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/dev/ufs/usbroot        /           ufs     rw     1     1
/dev/ufs/usbheap        /heap/      ufs     rw     0     0
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

-----------------------------------------------------------------------------
At the end of.
-----------------------------------------------------------------------------
  I.Rewrite parameters of your FreeBSD Live USB. 
    **  During markup of the disc, we will use the 4k alignment  blocks. You
        must add the appropriate data to your FreeBSD Live USB. Assume that
        your HDD drive was defined as /dev/ada0 - is the drive on which
        we will be installing FreeBSD in the future, then:
        # vi /mnt/boot/loader.conf
        
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# SYSTEM
# + HDD.
kern.cam.ada.0.quirks="1"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
    
 II.Unmounting all slices. 
    # cd /
    # umount /mnt/heap
    # umount /mnt

    **  If you used a CD not forget to unmount and it.
        # umount /cdrom
        
    **  If you can not unmount the partition, use the "-f" flag:
        # umount -f <MOUNT POINT>

III.Finish.
    Restart your computer and use your own FreeBSD Live USB.
    **  After load real system rewrite root password use passwd tool.
    # shutdown -r now

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*2.2.1. Using gpart tool and UFS + J file system.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Partitioning a hard disk using a gpart tool. File system: ufs + journal.
=============================================================================
-----------------------------------------------------------------------------
Create partition on your HDD.
-----------------------------------------------------------------------------
  I.Run our FreeBSD Live USB.
    **  In your BIOS choose option boot from USB Flash device or use F12 key
        to select the boot method.

 II.Check the settings.
    **  Assume that our HDD was defined as: /dev/ada0.
    **  If you use 4k sector size alignment and added 'kern.cam.ada.0.quirks'
        in your /boot/loader.conf, you should get the following result:
        # geom disk list ada0
        Geom name: ada0
        Providers:
        1. Name: ada0
            ...
            Stripesize: 4096
            ...

        We can see "Stripesize: 4096", else you see "Stripesize: 512" bytes.

III.Destroy all partitions of our HDD.
    A.  Step by step.
        # gpart show ada0
        =>      63 312581745 ipsd0 MBR  (298G)        
                63  11293632     1 !12 [active]  (5.4G)   
        11293695 301288113       - free -  (298G)

        In this example we have a single partition.
        # gpart delete -i 1 ada0

        **  If you have some others partition (2, 3, 4 ... 128) - remove it.
            If you do not do this - you can not run 'gpart destroy ada0'. You
            will receive a message: "Device busy!".
            # gpart delete -i 2 ada0
            # gpart delete -i 3 ada0
            ...
            # gpart delete -i 128 ada0

        Delete MBR sector or other old scheme partition.
        # gpart destroy ada0

    B.  All at once.
        For the rapid destruction of sections, use:
        # gpart destroy -F ada0

 IV.Create new partition scheme on our HDD.
    **  We will be use the partitioning scheme GPT.

    1.  Create GPT scheme.
        # gpart create -s GPT ada0

    2.  Partitioning.
        **  We use the alignment of 4k - it is "-a" flag.
        **  If you plan to install packages such as LibreOffice or
            KDE/Gnome2/Xfce4 - for the /usr partition is better to 
            allocate 24G.
        # gpart add -s 512k -a 4k -t freebsd-boot -l "boot" ada0
        # gpart add -b 1m -s 2g -a 4k -t freebsd-ufs -l "root" ada0
        # gpart add -s 4g -a 4k -t freebsd-swap -l "swap" ada0
        # gpart add -s 4g -a 4k -t freebsd-ufs -l "var" ada0
        # gpart add -s 4g -a 4k -t freebsd-ufs -l "tmp" ada0
        # gpart add -s 16g -a 4k -t freebsd-ufs -l "usr" ada0
        # gpart add -s 8g -a 4k -t freebsd-ufs -l "home" ada0
        # gpart add -a 4k -t freebsd-ufs -l "heap" ada0

        **  We have created a small home part because of all the personal
            data we store in the heap part.

    3.  Check result.
        **  It should look something like this.
        # gpart show ada0
        =>       34  250069613  ada0  GPT  (119G)
                 34          6        - free -  (3.0k)
                 40       1024     1  freebsd-boot  (512k)
               1064    4194304     2  freebsd-ufs  (2.0G)
            4195368    8388608     3  freebsd-swap  (4.0G)
           12583976    8388608     4  freebsd-ufs  (4.0G)
           20972584    8388608     5  freebsd-ufs  (4.0G)
           29361192   33554432     6  freebsd-ufs  (16G)
           62915624   16777216     7  freebsd-ufs  (8.0G)
           79692840  170376800     8  freebsd-ufs  (81G)
          250069640          7        - free -  (3.5k)

    4.  Install the boot loader.
        **  The boot partition is placed first on the list so we use: "-i 1".
        # gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0

    5.  Checking the alignment.
        **  It should look something like this.
        # diskinfo -v ada0 | grep stripesize
                4096            # stripesize
        # diskinfo -v ada0 | grep "stripeoffset"
                0               # stripeoffset

        **  If <stripoffset> % <stripsize> equal zero - all good.
            # echo 0%4096 | bc
            0

  V.Create new file system.
    **  Use journaling filesystem: UFS+J.
    # newfs -j /dev/gpt/root
    # newfs -j /dev/gpt/var
    # newfs -j /dev/gpt/tmp
    # newfs -j /dev/gpt/usr
    # newfs -j /dev/gpt/home
    # newfs -j /dev/gpt/heap

 VI.Mount all parts for our system.
    # mkdir -p /mnt/hdd/a
    # mount /dev/gpt/root /mnt/hdd/a
    # cd /mnt/hdd/a
    # mkdir -p boot var tmp usr

    # chmod 1777 tmp
    
    # mount /dev/gpt/var /mnt/hdd/a/var
    # mount /dev/gpt/tmp /mnt/hdd/a/tmp
    # mount /dev/gpt/usr /mnt/hdd/a/usr
    
    # mkdir -p /mnt/hdd/a/usr/home
    # mount /dev/gpt/home /mnt/hdd/a/usr/home
    # cd /mnt/hdd/a
    # ln -s usr/home home
    
    # mkdir -p /mnt/hdd/a/heap
    # mount /dev/gpt/heap /mnt/hdd/a/heap
    # touch /mnt/hdd/a/heap/heap.ok

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*2.2.2. Using fdisk tool and UFS + J file system.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Partitioning a hard disk using a fdisk tool. File system: ufs + journal.
=============================================================================
-----------------------------------------------------------------------------
Create partition on your HDD.
-----------------------------------------------------------------------------
  I.Run our FreeBSD Live USB.
    **  In your BIOS choose option boot from USB Flash device or use F12 key
        to select the boot method.

 II.Check the settings.
    **  Assume that our HDD was defined as: /dev/ada0.
    **  If you use 4k sector size alignment and added 'kern.cam.ada.0.quirks'
        in your /boot/loader.conf, you should get the following result:
        # geom disk list ada0
        Geom name: ada0
        Providers:
        1. Name: ada0
            ...
            Stripesize: 4096
            ...
            
        We can see "Stripesize: 4096", else you see "Stripesize: 512" bytes.

III.Destroy all partitions of our HDD.
    # dd if=/dev/zero of=/dev/ada0 bs=64k

 IV.Create new partition scheme on our HDD.
    **  We will use the partitioning scheme MBR.

    1.  Create MBR scheme and boot sector.
        # fdisk -BI /dev/ada0
        # bsdlabel -w -B /dev/ada0s1
        # bsdlabel -e /dev/ada0s1

    2.  Use your editor (default vi) and edit open file:
        **  Not in any way not alter or delete the "c" label.
        **  If you plan to install packages such as LibreOffice or
            KDE/Gnome2/Xfce4 - for the /usr partition is better to 
            allocate 24G.

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# /dev/ada0s1:
8 partitions:
#           size  offset   fstype  [fsize bsize bps/cpg]
    a:        2G      16   4.2BSD        0   0    # root
    b:        4G       *     swap                 # swap
    c: 625142369       0   unused        0   0    # "raw" part, don't edit
    d:        4G       *   4.2BSD                 # var
    e:        4G       *   4.2BSD                 # tmp
    f:       16G       *   4.2BSD                 # usr
    g:        8G       *   4.2BSD                 # home
    h:         *       *   4.2BSD                 # heap
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    3.  Check the results of markup partitions.
        # ls /dev/ | grep ^ada0
        ada0        ada0s1e
        ada0s1      ada0s1f
        ada0s1a     ada0s1g
        ada0s1b     ada0s1h
        ada0s1d

        **  If you do not see anything like it, open file again and remove
            your errors:
            # bsdlabel -e /dev/ada0s1

    4.  Formatting an all partitions:
        # newfs -L root -j /dev/ada0s1a
        # glabel label swap /dev/ada0s1b
        # newfs -L var -j /dev/ada0s1d
        # newfs -L tmp -j /dev/ada0s1e
        # newfs -L usr -j /dev/ada0s1f
        # newfs -L home -j /dev/ada0s1g
        # newfs -L heap -j /dev/ada0s1h

  V.Mount all parts in our system.
    # mkdir -p /mnt/hdd/a
    # mount /dev/ufs/root /mnt/hdd/a
    
    # cd /mnt/hdd/a 
    # mkdir -p boot var tmp usr
    # chmod 1777 tmp
    # cd ~/
    
    # mount /dev/ufs/var /mnt/hdd/a/var
    # mount /dev/ufs/tmp /mnt/hdd/a/tmp
    # mount /dev/ufs/usr /mnt/hdd/a/usr

    # mkdir -p /mnt/hdd/a/usr/home
    # mount /dev/ufs/home /mnt/hdd/a/usr/home
    # cd /mnt/hdd/a
    # ln -s usr/home home

    # mkdir -p /mnt/hdd/a/heap
    # mount /dev/ufs/heap /mnt/hdd/a/heap
    # touch /mnt/hdd/a/heap/heap.ok

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*2.3.1. Installing FreeBSD on the UFS file system.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Installing FreeBSD 9.0/i386 on the UFS file system.
=============================================================================
-----------------------------------------------------------------------------
Note!
-----------------------------------------------------------------------------
    Before installing, make sure that you mount your HDD in accordance with
    our method of partitioning.

    **  It is assumed that you have used the method of partitioning gpart or
        fdisk to UFS + J file system.

    **  It is assumed that the operating system is running with the our
        FreeBSD Live USB.

-----------------------------------------------------------------------------
Install FreeBSD 9.0/i386.
-----------------------------------------------------------------------------
  I.Install a system.
    # cd /heap/freebsd/source/9.0/i386/
    
    A.  Unpack use csh interpreter capabilities.
        # foreach file (base.txz kernel.txz)
        ?     cat $file | tar --unlink -xpJf - -C /mnt/hdd/a
        ? end

    B.  Hand mode unpack.
        # cat base.txz | tar --unlink -xpJf - -C /mnt/hdd/a
        # cat kernel.txz | tar --unlink -xpJf - -C /mnt/hdd/a
    
    **  If you use FreeBSD 9.0/amd64 unpack too:
        # cat lib32.txz | tar --unlink -xpJf - -C /mnt/hdd/a
        
    **  If you want, unpack other files: doc.txz, ports.txz, src.txz, - but
        this is not necessary.

 II.Create /etc/fstab file.
    Open /mnt/hdd/a/etc/fstab file, and write it:
    
    A.  If you use gpart for partition your HDD.
        # vi /mnt/hdd/a/etc/fstab

    **  procfs (or the proc filesystem) is a special filesystem in UNIX-like
        operating systems that presents information about processes and other
        system information in a hierarchical file-like structure, providing a
        more convenient and standardized method for dynamically accessing
        process data held in the kernel than traditional tracing methods or
        direct access to kernel memory.

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/dev/gpt/swap   none        swap    sw      0   0
/dev/gpt/root   /           ufs     rw      1   1
/dev/gpt/var    /var        ufs     rw      0   0
/dev/gpt/tmp    /tmp        ufs     rw      0   0
/dev/gpt/usr    /usr        ufs     rw      0   0
/dev/gpt/home   /home       ufs     rw      0   0
/dev/gpt/heap   /heap       ufs     rw      0   0
proc            /proc       procfs  rw      0   0
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    B.  If you use fdisk and bsdlabel for partition your HDD.
        # vi /mnt/hdd/a/etc/fstab

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/dev/ada0s1b    none        swap    sw      0   0
/dev/ufs/root   /           ufs     rw      1   1
/dev/ufs/var    /var        ufs     rw      0   0
/dev/ufs/tmp    /tmp        ufs     rw      0   0
/dev/ufs/usr    /usr        ufs     rw      0   0
/dev/ufs/home   /home       ufs     rw      0   0
/dev/ufs/heap   /heap       ufs     rw      0   0
proc            /proc       procfs  rw      0   0
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

III.Unmount all parts and reboot our computer.
    1.  Unmount all parts.
        # cd /
        # umount /mnt/hdd/a/heap
        # umount /mnt/hdd/a/usr/home
        # umount /mnt/hdd/a/usr
        # umount /mnt/hdd/a/tmp
        # umount /mnt/hdd/a/var
        # umount /mnt/hdd/a
    
    2.  Reboot our computer.
        # shutdown -r now

    **  If you can not unmount the partition, use the "-f" flag:
        # umount -f <MOUNT POINT>

    **  Do not forget to disconnect the USB Flash or change the settings in
        your BIOS.
        
    **  After load real system rewrite root password use passwd tool.
    
=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.1.1. Setting the date and time.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Setting the date and time.
=============================================================================
-----------------------------------------------------------------------------
Hand installing.
-----------------------------------------------------------------------------
  I.Use date tools and tzsetup.
    **  To set the date and time need to be root.
    **  Date has format: yymmddhhss
        + yy - year
        + mm - month.
        + dd - day.
        + hh - hour.
        + ss - minute.
        
    A.  Setup time zone.
        **  Use tzsetup manager and setting your time zone.
        # tzsetup
        
    B.  Setting date and time.
        **  For example: 17:29 17.08.2012
        # date 201208171729

        **  For example too: 17:29 17.08.2012
        # date 1208171729

    C.  Setting only time.
        **  Set the time without having to modify the date - hours:minutes.
        **  For example: 17:30
        # date 1730

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.1.2. Setting up the directory structure.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Setting up the directory structure.
=============================================================================
-----------------------------------------------------------------------------
Directories to mount.
-----------------------------------------------------------------------------
  I.Create a mount directory.
    # foreach i (hdd cdrom usb)
    ?     foreach j (a b c)
    ?         mkdir -p /mnt/$i/$j
    ?     end
    ? end
        
    **  Where is:
        + /mnt/cdrom/[a,b,c] - for the first, second and third CD/DVD-Rom.
        + /mnt/hdd/[a,b,c] - for the first, second and third HDD.
        + /mnt/usb/[a,b,c] - for the first, second and third USB Device.

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.1.3. Configure the bootloader menu.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Configure the bootloader menu.
=============================================================================
-----------------------------------------------------------------------------
Disable boot loader menu.
-----------------------------------------------------------------------------
  I.Add to /boot/loader.conf.
    # vi /boot/loader.conf
    
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# SYSTEM
# + Bootloader menu.
autoboot_delay="7"
beastie_disable="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    **  Where is:
        + autoboot_delay    - delay time (seconds) to automatically loading.
        + beastie_disable   - disable menu (YES).

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.1.4. Customize text greetings.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Customize text greetings.
=============================================================================
-----------------------------------------------------------------------------
Create new text greetings.
-----------------------------------------------------------------------------
  I.Modified greetings file.
    # vi /etc/motd

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Welcome to FreeBSD!

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    **  You can write your text greetings or use ASCII Art pic.

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.2.1. Create, remove users account.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Create, remove users account.
=============================================================================
-----------------------------------------------------------------------------
The general theory.
-----------------------------------------------------------------------------
  I.Software for account management.
    1. adduser(8) - add new users.
    2. rmuser(8) - remove user.
    3. chpass(1) - change the information in the user database.
    4. passwd(1) - change user passwords.
    5. pw(8) - change any information associated with user account.

-----------------------------------------------------------------------------
Blowfish hash function.
-----------------------------------------------------------------------------
  I.Enable the Blowfish hash function instead of the default aging MD5
    algorithm.
    # vi /etc/auth.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# BLOWFISH
# + Enable Blowfish hash function.
crypt_default=blf
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    # vi /etc/login.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
...
default:\
    :passwd_format=blf:\
    :copyright=/etc/COPYRIGHT:\
...
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
**  Modified passwd_format=sha512 to passwd_format=blf.

 II.Rebuild the login database with cap_mkdb /etc/login.conf, then set your
    new blf-hashed root password with passwd.
    # cap_mkdb /etc/login.conf
    # passwd

-----------------------------------------------------------------------------
Adding new user.
-----------------------------------------------------------------------------
  I.Hand mode use adduser tool.
    **  Then the answer to several questions.
    **  Better use of next group: wheel,operator,man,ftp,sshd,www.
    # adduser
    ...

 II.Use automatic mode.
    1.  Create chs script.
        # vi ~/newuser.csh

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#!/bin/csh
# 1.  User name.
# 2.  User ID, UserID, must be unique in the system, that is, to choose
#     one that is not used for convenience, you can  leave it blank, ID
#     will be assigned automatically.
# 3.  Group ID, GroupID, it satisfies all of the above UserID.
# 4.  User class we leave the field blank, will be assigned the default
#     class.
# 5.  Validity user password.
# 6.  Validity of a user account.
# 7.  The full name of the user.
# 8.  The home directory.
# 9.  The shell as in the case of creating an interactive user, you can
#     choose from several, or prohibit the  use of nologin, I appointed
#     all the different.
# 10. The user password.

set user = 'USERNAME'
set pswd = 'USERPASSWORD'
set efile = '/tmp/newuser.txt'
set group = 'wheel'

echo "${user}:::::::/usr/home/${user}:/bin/csh:${pswd}" > $efile

adduser -f $efile
pw usermod $user -G $group
rm -f $efile

exit(0)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  Run the script.
        # csh ~/newuser.csh

-----------------------------------------------------------------------------
Change the user group.
-----------------------------------------------------------------------------
  I. Use pw tool.
    **  You can use the following Group.
        The database of user group (text file): /etc/group.
        * "wheel" allows you to switch to root user.
        * "operator" can  work with devices from  not use root user.
        * [wheel,dialer,operator,man,ftp,sshd,www,network].

    Example, add user to wheel group.
    # pw usermod <USERNAME> -G wheel

-----------------------------------------------------------------------------
Delete user.
-----------------------------------------------------------------------------
  I.Using rmuser tool.
    # rmuser <USERNAME>
    Matching password entry:
    ...

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.3.1. Configuring the Ethernet.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Configuring the Ethernet.
=============================================================================
-----------------------------------------------------------------------------
Search for equipment.
-----------------------------------------------------------------------------
  I.Search Ethernet controller.
    # ifconfig
    iwn0:   flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 2290
            ether 00:21:6a:26:34:c0
            nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
            media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
            status: no carrier
    bge0:   flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 2290
            ether 00:21:b9:26:85:2a
            nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
            media: Ethernet autoselect (100baseTX <full-duplex>)
            status: no carrier
    lo0:    flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
            options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
            inet6 ::1 prefixlen 128
            inet6 fe80::1%lo0 prefixlen 64 scopeid 0x5
            inet 127.0.0.1 netmask 0xff000000
            nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

    **  In the "media" we are interested in the inscription: "Ethernet
        autoselect". Thus, our ethernet device - bge0.

    **  You can have: re0, eth0, bge0, etc ...

-----------------------------------------------------------------------------
Setting up configuration files.
-----------------------------------------------------------------------------
  I.Add to file /etc/rc.conf.
    A.  If our router IP: 192.168.1.1, Machine IP: 192.168.1.33
        # vi /etc/rc.conf 

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# NETWORK
# + Main.
hostname="bsd"
defaultrouter="192.168.1.1"

# + Ethernet.
ifconfig_bge0="inet 192.168.1.33 netmask 255.255.255.0"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    B.  If you use DHCP.
        # vi /etc/rc.conf 

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# NETWORK
# + Main.
hostname="bsd"
defaultrouter="192.168.1.1"

# + Ethernet.
ifconfig_bge0="DHCP"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

 II.Restart network connect.
    # /etc/rc.d/netif restart && /etc/rc.d/routing restart

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.3.2. Configuration the WiFi (Intel adapter).*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Configuration the WiFi (adapter Intel).
=============================================================================
-----------------------------------------------------------------------------
WiFi configuration.
-----------------------------------------------------------------------------
  I.FreeBSD 9.0 has iwn driverin GENERIC kernel.
    1.  Determine the device.
        **  So, We use WPA2 crypts, router IP: 192.168.1.1, Machine IP: DHCP
        # ifconfig
        ...
        iwn0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST>
        metric 0 mtu 2290
            ether dc:a9:71:7b:cb:3b
            nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
            media: IEEE 802.11 Wireless Ethernet autoselect mode 11g
            status: associated
        ...

        **  Our WiFi adapter - iwn0, because in the "media" is written:
            "IEEE 802.11 Wireless Ethernet".
        
    2.  Configuration rc.conf.
        **  We use DHCP.
        # vi /etc/rc.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# NETWORK
# + Main.
hostname="bsd"
defaultrouter="192.168.1.1"

# + WiFi.
wlans_iwn0="wlan0"
ifconfig_wlan0="WPA DHCP"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    3.  Configuration wpa_supplicant.conf.
        **  SSID in your WiFi adapter should be visible.
        # vi /etc/wpa_supplicant.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
network={
    ssid="<WIFI SSID NAME>"
    psk="<WIFI PASSWORD>"
}
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    4.  Restart network connect.
        # /etc/rc.d/netif restar && /etc/rc.d/routing restart

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.3.3. Setting up SSH access.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Setting up SSH access.
=============================================================================
-----------------------------------------------------------------------------
Enabling sshd.
-----------------------------------------------------------------------------
  I.In FreeBSD, sshd daemon must be enabled during installation.
    1.  Modified rc.conf.
        # vi /etc/rc.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# NETWORK
# + SSH.
sshd_enable="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  Run sshd.
        # /etc/rc.d/sshd start

        **  sshd configuration in /etc/ssh/sshd_config. After making changes:
            # /etc/rc.d/sshd reload
       
 II.In /etc/ssh/sshd_config uncomment and edit the following string.
    1.  Modified sshd_config.
        # vi /etc/ssh/sshd_config
    
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Port 22
Protocol 2
PasswordAuthentication yes
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  Reload options:
        # /etc/rc.d/sshd reload
        
-----------------------------------------------------------------------------
Open access to root user.
-----------------------------------------------------------------------------
    **  Attention! It is not safe! Use any other account to connect via SSH.
        Do not use the root account.

  I.In /etc/ssh/sshd_config uncomment and edit the following string.
    1.  Modified sshd_config.
        # vi /etc/ssh/sshd_config
    
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
PermitRootLogin yes
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  Reload options.
        # /etc/rc.d/sshd reload

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.4.1. Installing the Ports Collection.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Installing the Ports Collection.
=============================================================================
-----------------------------------------------------------------------------
Install the ports collection.
-----------------------------------------------------------------------------
  I.Installing the Ports Collection from the Internet.
    A.  The first method - use a portsnap utility.
        # /usr/sbin/portsnap fetch && /usr/sbin/portsnap extract

    B.  The second method - use a csup utility.
        1.  Create special file.
            # vi ~/ports-all

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
*default host=cvsup3.ua.FreeBSD.org
*default base=/var/db
*default prefix=/usr
*default release=cvs tag=.
*default delete use-rel-suffix
*default compress
ports-all
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
        
        2.  Run it:
            # csup ~/ports-all

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.4.2. Installing FreeBSD source code.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Installing the source code, documentation, etc.
=============================================================================
-----------------------------------------------------------------------------
Installing FreeBSD source code.
-----------------------------------------------------------------------------
  I.Update all source code.
    1.  Create special file.
        # vi ~/src-all
        
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
*default host=cvsup3.ua.FreeBSD.org
*default base=/var/db
*default prefix=/usr
*default release=cvs tag=RELENG_9_0
*default delete use-rel-suffix
*default compress
src-all
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  Run it.
        # csup ~/src-all
    
-----------------------------------------------------------------------------
Installing FreeBSD Ports Collection.
-----------------------------------------------------------------------------
  I.Update the ports collection.
    1.  Create special file.
        # vi ~/ports-all
        
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
*default host=cvsup3.ua.FreeBSD.org
*default base=/var/db
*default prefix=/usr
*default release=cvs tag=.
*default delete use-rel-suffix
*default compress
ports-all
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  Run it.
        # csup ~/ports-all

-----------------------------------------------------------------------------
Installing FreeBSD documentation
-----------------------------------------------------------------------------
  I.Update the documentation.
    1.  Create special file.
        # vi ~/doc-all

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
*default host=cvsup3.ua.FreeBSD.org
*default base=/var/db
*default prefix=/usr
*default release=cvs tag=RELENG_9_0
*default delete use-rel-suffix
*default compress
doc-all
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  Run it.
        # csup ~/doc-all

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.5.1. Build FreeBSD world.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Build FreeBSD world.
=============================================================================
-----------------------------------------------------------------------------
Download the source system tree.
-----------------------------------------------------------------------------
  I.Update all source code.
    1.  Create special file.
        **  If you want to download the latest source code, use: tag=RELENG_9
        # vi ~/src-all
        
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
*default host=cvsup3.ua.FreeBSD.org
*default base=/var/db
*default prefix=/usr
*default release=cvs tag=RELENG_9_0
*default delete use-rel-suffix
*default compress
src-all
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  Run it.
        # csup ~/src-all    

-----------------------------------------------------------------------------
Configure system files.
-----------------------------------------------------------------------------
  I.Configure /etc/make.conf, for example.
    # vi /etc/make.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# MAIN
# + Compiler options.
CPUTYPE?=nocona
CFLAGS=-O2 -fno-strict-aliasing -pipe

# + Ports.
PORTSDIR?=/usr/ports

# + Others.
MAKE_SHELL?=sh
NO_PROFILE=true

NO_CPU_CFLAGS=false
NO_CPU_COPTFLAGS=false

NO_SENDMAIL=true
NO_GAMES=true
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

-----------------------------------------------------------------------------
Starting single-user mode.
-----------------------------------------------------------------------------
  I.Modification of the configuration files.
    1.  Allow to show bootloader menu.
        # vi /boot/loader.conf
        
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# SYSTEM
# + Bootloader menu.
autoboot_delay="7"
beastie_disable="NO"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

 II.Starting single-user mode.
    1.  Reboot the system.
        # shutdown -r now
        
    2.  In bootloader menu select: "6. Boot [S]ingle User: NO".
    
III.In single-user mode.
    1.  Mount all partitions.
        # fsck -p
        # mount -u /
        # mount -a -t ufs
        # swapon -a
        
    2.  Remove /usr/obj.
        # cd /usr/obj
        # chflags -R noschg *
        # rm -rf *
        
-----------------------------------------------------------------------------
Build world.
-----------------------------------------------------------------------------
  I.Build world.
    1.  Build world.
        # cd /usr/src
        # make -j4 buildworld
        
    2.  Necessarily build and install kernel again.
        **  My kernel has name: ADAMO13KERNEL86
        **  Necessarily read HOWTO: "FreeBSD Kernel Configuration".

        A.  Hand mode:
            # cd /usr/src/
            # make buildkernel KERNCONF=ADAMO13KERNEL86
            # make installkernel KERNCONF=ADAMO13KERNEL86

        B   Automatic mode:
            # cd /usr/src/
            # foreach cmd (buildkernel installkernel)
            ?     make $cmd KERNCONF=ADAMO13KERNEL86
            ? end

    3.  Install world.
        # make installworld
        
    4.  Output of single-user mode.  
        # reboot now
    
        **  After the login in multi-user mode, do not forget to change
            the settings in /boot/loader.conf.

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.5.2. FreeBSD Kernel Configuration.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    FreeBSD Kernel Configuration.
=============================================================================
-----------------------------------------------------------------------------
Note.
-----------------------------------------------------------------------------
    Make sure that the kernel source installed.

-----------------------------------------------------------------------------
Backup original kernel.
-----------------------------------------------------------------------------
  I.Backup old kernel.
    # cp -R /boot/kernel /boot/kernel.generic
    
    **  If after rebuild your kernel your computer can not run:
        1. Start your FreeBSD Live USB.
        2. Mount root part:
            A.  If you used gpart for installation FreeBSD.
                # mkdir -p /mnt/hdd/a
                # mount /dev/gpt/root /mnt/hdd/a
              
            B.  If you used fdisk for installation FreeBSD.
                # mkdir -p /mnt/hdd/a
                # mount /dev/ufs/root /mnt/hdd/a

        3.  Remove bad kernel and install the old kernel.
            # chflags -R noschg /boot/kernel/
            # rm -R /boot/kernel
            # cp -R /boot/kernel.generic /boot/kernel
              
        4.  Reboot FreeBSD Live USB system.
            # shutdown -r now

-----------------------------------------------------------------------------
Rebuilding new kernel.
-----------------------------------------------------------------------------
    **  For example, add the kernel option "graphics mode in the console".
    
  I.Copy kernel file.
    **  Do not modify the standard kernel file. Copy original file and think
        sup new name for it, for example: ADAMO13KERNEL86.
        
    **  My laptop Dell Adamo 13, My FreeBSD system: i386.
        # mkdir -p /heap/freebsd/system/kernels
        # cd /usr/src/sys/i386/conf
        # cp GENERIC /heap/freebsd/system/kernels/ADAMO13KERNEL86
        # ln -s /heap/freebsd/system/kernels/ADAMO13KERNEL86

 II.Options.
    **  Add to your kernel next options:
        1. SC_PIXEL_MODE       - setting the graphics mode in the console.
        2. SC_NORM_ATTR        - text and background color.
        3. SC_KERNEL_CONS_ATTR - color kernel messages and background.

III.Modified kernel file.
    **  Rewrite conf file, add next strings to your kernel.
    # vi ADAMO13KERNEL86
    
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# Graphic mode
### options SC_PIXEL_MODE # [!] SC_PIXEL_MODE enabled by default in GENERIC.
options SC_NORM_ATTR=(FG_WHITE|BG_BLACK)
options SC_KERNEL_CONS_ATTR=(FG_RED|BG_BLACK)

# UTF8 support
options	VESA
options TEKEN_UTF8
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    **  Will be used white text on black background.
    **  Will be used red kernel message on a black background.

 IV.Rebuilding new kernel.
    A.  Hand mode:
        # cd /usr/src/
        # make buildkernel KERNCONF=ADAMO13KERNEL86
        # make installkernel KERNCONF=ADAMO13KERNEL86

    B.  Automatic mode:
        # cd /usr/src/
        # foreach cmd (buildkernel installkernel)
        ?     make $cmd KERNCONF=ADAMO13KERNEL86
        ? end
        
  V.Finish.
    Restart your computer.
    # shutdown -r now
        
    **  After reboot you should see something as follows:
        # uname -a
        FreeBSD adamo 9.0-RELEASE-p4 FreeBSD 9.0-RELEASE-p4 #0: Thu Aug 23
        05:46:28 UTC 2012 root@:/usr/obj/usr/src/sys/ADAMO13KERNEL86  i386
        
=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.5.3. Setting graphics mode in the console.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Setting graphics mode in the console.
=============================================================================
-----------------------------------------------------------------------------
Note.
-----------------------------------------------------------------------------
    Before you do this, make sure you add the options in your kernel:
    
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# Graphic mode
options SC_NORM_ATTR=(FG_WHITE|BG_BLACK)
options SC_KERNEL_CONS_ATTR=(FG_RED|BG_BLACK)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    **  Will be used white text on black background.
    **  Will be used red kernel message on a black background.

-----------------------------------------------------------------------------
Setting up configuration files.
-----------------------------------------------------------------------------
  I.Rewrite /boot/loader.conf and add this:
    # vi /boot/loader.conf
    
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# VIDEO
# + Graphic mode in console.
vesa_load="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

 II.Rewrite /etc/rc.conf.
    # vi /etc/rc.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# VIDEO
# + Graphic mode in console.
allscreens_flags="MODE_280"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    **  Need to boot the new kernel.
    **  You can't use vidcontrol via SSH.
    **  In order to know the available modes, use:
        # vidcontrol -i mode >> /tmp/gmode
        # less /tmp/gmode

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
     mode#     flags   type    size    font     window      linear   buffer
----------------------------------------------------------------------------
  0 (0x000) 0x00000001 T 40x25         8x8  0xb8000 32k 32k 0x00000000 32k
  1 (0x001) 0x00000001 T 40x25         8x8  0xb8000 32k 32k 0x00000000 32k
  2 (0x002) 0x00000001 T 80x25         8x8  0xb8000 32k 32k 0x00000000 32k
  3 (0x003) 0x00000001 T 80x25         8x8  0xb8000 32k 32k 0x00000000 32k
  4 (0x004) 0x00000003 G 320x200x2 C   8x8  0xb8000 32k 32k 0x00000000 32k
  5 (0x005) 0x00000003 G 320x200x2 C   8x8  0xb8000 32k 32k 0x00000000 32k
  6 (0x006) 0x00000003 G 640x200x1 C   8x8  0xb8000 32k 32k 0x00000000 32k
 13 (0x00d) 0x00000003 G 320x200x4 4   8x8  0xa0000 64k 64k 0x00000000 256k
 14 (0x00e) 0x00000003 G 640x200x4 4   8x8  0xa0000 64k 64k 0x00000000 256k
 16 (0x010) 0x00000003 G 640x350x2 2   8x14 0xa0000 64k 64k 0x00000000 128k
 18 (0x012) 0x00000003 G 640x350x4 4   8x14 0xa0000 64k 64k 0x00000000 256k
 19 (0x013) 0x00000001 T 40x25         8x14 0xb8000 32k 32k 0x00000000 32k
 20 (0x014) 0x00000001 T 40x25         8x14 0xb8000 32k 32k 0x00000000 32k
 21 (0x015) 0x00000001 T 80x25         8x14 0xb8000 32k 32k 0x00000000 32k
 22 (0x016) 0x00000001 T 80x25         8x14 0xb8000 32k 32k 0x00000000 32k
 23 (0x017) 0x00000001 T 40x25         8x16 0xb8000 32k 32k 0x00000000 32k
 24 (0x018) 0x00000001 T 80x25         8x16 0xb8000 32k 32k 0x00000000 32k
 26 (0x01a) 0x00000003 G 640x480x4 4   8x16 0xa0000 64k 64k 0x00000000 256k
 27 (0x01b) 0x00000003 G 640x480x4 4   8x16 0xa0000 64k 64k 0x00000000 256k
 28 (0x01c) 0x00000003 G 320x200x8 P   8x8  0xa0000 64k 64k 0x00000000 64k
 30 (0x01e) 0x00000001 T 80x50         8x8  0xb8000 32k 32k 0x00000000 32k
 32 (0x020) 0x00000001 T 80x30         8x16 0xb8000 32k 32k 0x00000000 32k
 34 (0x022) 0x00000001 T 80x60         8x8  0xb8000 32k 32k 0x00000000 32k
 37 (0x025) 0x00000003 G 320x240x8 V   8x8  0xa0000 64k 64k 0x00000000 256k
112 (0x070) 0x00000000 T 80x43         8x8  0xb8000 32k 32k 0x00000000 32k
113 (0x071) 0x00000001 T 80x43         8x8  0xb8000 32k 32k 0x00000000 32k
257 (0x101) 0x0000000f G 640x480x8 P   8x16 0xa0000 64k 64k 0xd0000000 300k
259 (0x103) 0x0000000f G 800x600x8 P   8x16 0xa0000 64k 64k 0xd0000000 487k
261 (0x105) 0x0000000f G 1024x768x8 P  8x16 0xa0000 64k 64k 0xd0000000 768k
273 (0x111) 0x0000000f G 640x480x16 D  8x16 0xa0000 64k 64k 0xd0000000 600k
274 (0x112) 0x0000000f G 640x480x32 D  8x16 0xa0000 64k 64k 0xd0000000 1200k
276 (0x114) 0x0000000f G 800x600x16 D  8x16 0xa0000 64k 64k 0xd0000000 937k
277 (0x115) 0x0000000f G 800x600x32 D  8x16 0xa0000 64k 64k 0xd0000000 1875k
279 (0x117) 0x0000000f G 1024x768x16 D 8x16 0xa0000 64k 64k 0xd0000000 1536k
280 (0x118) 0x0000000f G 1024x768x32 D 8x16 0xa0000 64k 64k 0xd0000000 3072k
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.5.4. Eliminating of demons cries.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Eliminating of demons cries.
=============================================================================
-----------------------------------------------------------------------------
Setting up configuration files.
-----------------------------------------------------------------------------
  I.Setting up file /boot/loader.conf
    # vi /boot/loader.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# SYSTEM
# + Demons scream in FreeBSD.
kern.hz="100"
hint.p4tcc.0.disabled="1"
hint.acpi_throttle.0.disabled="1"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

  II.Setting up file /etc/rc.conf.
    # vi /etc/rc.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# SYSTEM
# + Demons scream in FreeBSD.
powerd_enable="YES"
performance_cx_lowest="C2"
economy_cx_lowest="C2"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.5.5. Check after crash disk.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Check after crash disk.
=============================================================================
-----------------------------------------------------------------------------
Setting up configuration files.
-----------------------------------------------------------------------------
  I.Improving the start of the fsck tool.
    # vi /etc/rc.conf
        
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# SYSTEM
# + FSCK enhancements.
fsck_y_enable="YES"
background_fsck="NO" 
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.5.6. Locale UTF-8.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Locale UTF-8.
=============================================================================
-----------------------------------------------------------------------------
Setting.
-----------------------------------------------------------------------------
  I.Check  list of every available UTF-8 locale.
    # locale -a | grep UTF-8
    
    **  For me: ru_RU.UTF-8

 II.Edit the login database  to add a default character set and locale.
    # vi /etc/login.conf
        
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
...
    :ignoretime@:\
    :umask=022:\
    :charset=UTF-8:\
    :lang=ru_RU.UTF-8:

...
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
**  Add this after :ignoretime@:\ command line.

III.Rebuild the login database with cap_mkdb /etc/login.conf, then add the
    new locale to /etc/profile as well, so GDM and GNOME pick it up properly.
    # cap_mkdb /etc/login.conf
    # passwd

    # vi /etc/profile

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
LANG=ru_RU.UTF-8; export LANG
GDM_LANG=ru_RU.UTF-8; export GDM_LANG
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.5.7. Tuning and drivers.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Tuning and drivers.
=============================================================================
-----------------------------------------------------------------------------
Setting.
-----------------------------------------------------------------------------
  I.Change a few sysctl variables to enhance the experience of FreeBSD on the
    desktop, including expanding the amount of shared memory, tuning the 
    process scheduler for desktop use, and increasing the limit of 
    simultaneously-open files to something sensible.
    
    # vi /etc/sysctl.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# Enhance shared memory X11 interface.
kern.ipc.shmmax=67108864
kern.ipc.shmall=32768

# Enhance desktop responsiveness under high CPU use (200/224).
kern.sched.preempt_thresh=224

# Bump up maximum number of open files.
kern.maxfiles=200000

# Disable PC Speaker.
hw.syscons.bell=0
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

 II.Some knobs can only be set at boot by the loader by setting them in
    /boot/loader.conf. 
    # vi /boot/loader.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# SYSTEM
# + Boot-time kernel tuning.
kern.ipc.shmseg=1024
kern.ipc.shmmni=1024
kern.maxproc=10000

# + Access ATAPI devices through the CAM subsystem.
atapicam_load="YES"

# + Asynchronous I/O.
aio_load="YES"

# MOUNTING
# + Filesystem.
libiconv_load="YES"
libmchain_load="YES"
cd9660_iconv_load="YES"
msdosfs_iconv_load="YES"

# + Load MMC/SD card-reader support.
mmc_load="YES"
mmcsd_load="YES"
sdhci_load="YES"

# + Filesystems in userspace (SSHFS, etc).
fuse_load="YES"

# + In-memory filesystems.
tmpfs_load="YES"

# WEBCAM
# + Userland character device driver for webcams.
cuse4bsd_load="YES"

# THERMAL SENSORS
# + Intel Core thermal sensors.
coretemp_load="YES"

# + AMD K8, K10, K11 thermal sensors.
amdtemp_load="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

III.Finally, enable everything else.
    # vi /etc/rc.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# SYSTEM
# + Powerd: adaptive speed while on AC power, adaptive while on battery power.
powerd_enable="YES"
powerd_flags="-a hiadaptive -b adaptive"

# NETWORK
# + Enable BlueTooth.
hcsecd_enable="YES"
sdpd_enable="YES"

# GUI I/O
# + Mouse and Keyboard in GUI.
hald_enable="YES"
dbus_enable="YES"

# DE/WM
# + KDE
### kdm4_enable="YES"

# + Gnome2
gdm_enable="YES"
gdm_lang="ru_RU.UTF-8"

# WEBCAM
# + Webcam daemon.
webcamd_enable="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

 IV.Mounts.
    # vi /etc/fstab

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/dev/gpt/swap   none                swap        sw  0   0
/dev/gpt/root   /                   ufs         rw  1   1
/dev/gpt/var    /var                ufs         rw  0   2
/dev/gpt/tmp    /tmp                ufs         rw  0   2
/dev/gpt/usr    /usr                ufs         rw  0   2
/dev/gpt/home   /home               ufs         rw  0   2
/dev/gpt/heap   /heap               ufs         rw  0   2
proc            /proc               procfs      rw  0   0
fdesc           /dev/fd             fdescfs     rw  0   0
linproc         /compat/linux/proc  linprocfs   rw  0   0
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

  V.Device Permissions.
    # vi /etc/devfs.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# Allow all users to access optical media
perm    /dev/acd0       0666
perm    /dev/acd1       0666
perm    /dev/cd0        0666
perm    /dev/cd1        0666

# Allow all USB Devices to be mounted
perm    /dev/da0        0666
perm    /dev/da1        0666
perm    /dev/da2        0666
perm    /dev/da3        0666

# Misc other devices
perm    /dev/pass0      0666
perm    /dev/xpt0       0666
perm    /dev/uscanner0  0666
perm    /dev/video0     0666
perm    /dev/dvb/adapter0/demux0    0666
perm    /dev/dvb/adapter0/dvr       0666
perm    /dev/dvb/adapter0/frontend0 0666
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    # vi /etc/devfs.rules

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
[devfsrules_common=7]
add path 'ad[0-9]*'       mode 666
add path 'ada[0-9]*'  mode 666
add path 'da[0-9]*'       mode 666
add path 'acd[0-9]*'  mode 666
add path 'cd[0-9]*'       mode 666
add path 'mmcsd[0-9]*'    mode 666
add path 'pass[0-9]*' mode 666
add path 'xpt[0-9]*'  mode 666
add path 'ugen[0-9]*' mode 666
add path 'usbctl'     mode 666
add path 'usb/*'      mode 666
add path 'lpt[0-9]*'  mode 666
add path 'ulpt[0-9]*' mode 666
add path 'unlpt[0-9]*'    mode 666
add path 'fd[0-9]*'       mode 666
add path 'uscan[0-9]*'    mode 666
add path 'video[0-9]*'    mode 666
add path 'dvb/*'      mode 666
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    # vi /etc/rc.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# ENABLE DEVFS RULES
devfs_system_ruleset="devfsrules_common"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.6.1. Configuring Sound Card.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Configuring the sound card.
=============================================================================
-----------------------------------------------------------------------------
Analysis.
-----------------------------------------------------------------------------
  I.Available devices.
    # cat /dev/sndstat
    FreeBSD Audio Driver (newpcm: 32bit 2009061500/i386)
    Installed devices:
    pcm0: <HDA NVidia (Unknown) PCM #0 DisplayPort> (play) default
    pcm1: <HDA NVidia (Unknown) PCM #0 DisplayPort> (play)
    pcm2: <HDA NVidia (Unknown) PCM #0 DisplayPort> (play)
    pcm3: <HDA NVidia (Unknown) PCM #0 DisplayPort> (play)
    pcm4: <HDA IDT 92HD81B1X PCM #0 Analog> (play/rec)
    pcm5: <HDA IDT 92HD81B1X PCM #1 Analog> (rec)

    **  For me, the attention has: pcm4

-----------------------------------------------------------------------------
Setting up configuration files.
-----------------------------------------------------------------------------
  I.Setting up system files.
    1.  File loader.conf.
        # vi /boot/loader.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# SOUND
# + Sound settings.
snd_hda_load="YES"
sound_load="YES"
snd_uaudio_load="YES"
hw.snd.default_unit="4"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  File rc.conf.
        # vi /etc/rc.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# SOUND
# + Sound settings.
snddetect_enable="YES"
mixer_enable="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    3.  Set the of the device number a manually.
        **  In the example, the target device under the number - 4.
        # sysctl hw.snd.default_unit=4

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.6.2. Configuring Xorg.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Configuring Xorg.
=============================================================================
-----------------------------------------------------------------------------
Note.
-----------------------------------------------------------------------------
    You must have installed the ports collection.

-----------------------------------------------------------------------------
Install software.
-----------------------------------------------------------------------------
  I.Install drivers.
    A.  Install drivers from ports collection.
        # setenv BATCH yes

        # cd /usr/ports/x11/xorg
        # make && make install clean

        # cd /usr/ports/x11/linux-f10-xorg-libs
        # make && make install clean

    B.  Install drivers from packages.
        # pkg_add -r xorg
        # pkg_add -r linux-f10-xorg-libs

-----------------------------------------------------------------------------
Additional settings.
-----------------------------------------------------------------------------
  I.Keyboard and mouse support.
    1.  Configure rc.conf.
        # vi /etc/rc.conf
        
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# LINUX
# + Binary compatibility with Linux.
linux_load="YES"

# GUI I/O
# + Mouse and Keyboard.
hald_enable="YES"
dbus_enable="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

 II.Create xorg.conf.
    1.  Configure Xorg.
        # Xorg -configure
        # Xorg -config /root/xorg.conf.new
        
    2.  After go to next screen - Alt+F2, and.
        # cd /root/
        # cp xorg.conf.new /etc/X11/xorg.conf
        
        **  If you use nVidia video card, then see installing nVidia drivers 
            and configuration it.
            # nvidia-xconfig

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.6.3. Configuring nVidia Video Card.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Configuring nVidia Video Card.
=============================================================================
-----------------------------------------------------------------------------
Note.
-----------------------------------------------------------------------------
    You must have installed the ports collection.

-----------------------------------------------------------------------------
Install software.
-----------------------------------------------------------------------------
  I.Install drivers.
    1.  Install drivers from ports collection.
        # setenv BATCH yes
        # kldload linux

        # cd /usr/ports/x11/nvidia-driver
        # make && make install clean

        # cd /usr/ports/x11/nvidia-settings
        # make && make install clean
    
        # cd /usr/ports/x11/nvidia-xconfig
        # make && make install clean
        
    2.  Install drivers from packages.
        # kldload linux
   
        # pkg_add -r nvidia-driver
        # pkg_add -r nvidia-settings
        # pkg_add -r nvidia-xconfig

-----------------------------------------------------------------------------
Additional settings.
-----------------------------------------------------------------------------
  I.Create config files.
    1.  Modified /boot/loader.conf.
        # vi /boot/loader.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# LINUX
# + Binary compatibility with Linux.
linux_load="YES"

# VIDEO
# + nVidia drivers.
nvidia_load="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

 II.Run and config it.
    **  First - configure the Xorg.
    # rehash
    # nvidia-xconfig

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*3.6.4. Configuring Intel Video Card.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Configuring Intel Video Card.
=============================================================================
-----------------------------------------------------------------------------
Note.
-----------------------------------------------------------------------------
    You must have installed the ports collection.

-----------------------------------------------------------------------------
Install software.
-----------------------------------------------------------------------------
 I.Install drivers from ports collection.
    # setenv BATCH yes
    # cd /usr/ports/x11-drivers/xf86-video-intel
    # make && make install clean

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*4.1.1. Finding application.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Finding application.
=============================================================================
-----------------------------------------------------------------------------
Find in Ports Collections.
-----------------------------------------------------------------------------
  I.Use whereis tool.
    For example:
    # whereis opera
    opera: /usr/ports/www/opera

    # whereis nosoftware
    nosoftware:

 II.Default method.
    # cd /usr/ports
    # make search name=opera
    Port:   www/opera
    Moved:
    Date:   2011-10-04
    ...

III.Use psearch tool. Its is good tools for search ports.
    ** First you should be Installed it.
    # pseacrh opera
    ...
    www/opera  Blazingly fast, full-featured, standards-compliant browser.
    ...

-----------------------------------------------------------------------------
Install pseacrh.
-----------------------------------------------------------------------------
  I.Find psearch tool.
    # whereis psearch
    psearch: /usr/ports/ports-mgmt/psearch

 II.Installation.
    # setenv BATCH yes
    # cd /usr/ports/ports-mgmt/psearch
    # make && make install clean
    # rehash

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*4.1.2. Installation of the packages.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Installation of the packages.
=============================================================================
-----------------------------------------------------------------------------
Install software.
-----------------------------------------------------------------------------
  I.Use local repository.
    1.  Go to the directory on the local repository.
        **  For example: ~/localrepo/.
        # cd ~/localrepo/

    2. Find the right package.
        **  For example opera_11_4.tar.gz
        # ls | grep ^opera
        opera_11_4.tar.gz

    3. Installing the package.
        # pkg_add opera_11_4.tar.gz
        
    **  In the local repository should be all the necessary dependencies.

 II.Use global repository.
    1.  Choice of place of a global repository. Is responsible for this
        PACKAGESITE global variable.
        A.  For FreeBSD 8.2.
            # setenv PACKAGESITE "http://ftp.freebsd.org/pub/FreeBSD/
                                    ports/i386/packages-8.2-release/All/"
                                    
        B.  For FreeBSD 9.0.
            # setenv PACKAGESITE "ftp://ftp.freebsd.org/pub/FreeBSD/
                                    ports/i386/packages-9-stable/Latest/"

    2.  Install software.
        **  For example install opera and all dependencies.
        # pkg_add -r opera
        
-----------------------------------------------------------------------------
Create a local repository of installed programs.
-----------------------------------------------------------------------------
  I.Create a custom script.
    1.  Create script.
        # mkdir -p ~/localrepo
        # cd ~/localrepo
        # vi create.csh
    
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#!/bin/csh

set packages = `pkg_info | cut -d' ' -f1`
set localrepo = "$HOME/localrepo/"
mkdir -p $localrepo
cd $localrepo

foreach package ($packages)
    pkg_create -b $package
end

unset localrepo packages

exit(0)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  Run script.
        # csh create.csh

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*4.1.3. Installation of the ports collections.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Installation of the ports collections.
=============================================================================
-----------------------------------------------------------------------------
Install software.
-----------------------------------------------------------------------------
  I.Find the right port.
    **  For example psearch.
    # whereis psearch
    psearch: /usr/ports/ports-mgmt/psearch

  II.Installation.
    1.  Hands mode.
        **  Will have to answer some questions.
        # cd /usr/ports/ports-mgmt/psearch
        # make && make install clean

    2.  Automatic mode.
        **  All questions will be answered "Yes".
        # setenv BATCH yes
        # cd /usr/ports/ports-mgmt/psearch
        # make && make install clean

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*4.1.4. Uninstall programs and clean debris.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Uninstall programs and clean debris.
=============================================================================
-----------------------------------------------------------------------------
Uninstall programs.
-----------------------------------------------------------------------------
  I.Use ports collection.
    **  If you do not used when installing ports: make clean.
    # cd /usr/ports/<CATEGORY>/<PORT>
    # make deinstall

 II.Use pkg_delete.
    **  For example, remove wine software.
    # pkg_info | grep wine
    wine-1.3.32,1    Microsoft Windows  compatibility layer for UNIX sys.
    # pkg_delete wine-1.3.32,1

-----------------------------------------------------------------------------
Remove the dependency.
-----------------------------------------------------------------------------
  I.Use ports-mgmt/pkg-orphan
    **  pkg-orphan is a console utility for managing orphan i.e. unreferenced
        FreeBSD packages. It finds all or selected orphans and lets the user
        choose which ones to remove and which ones to keep. It maintains a 
        keep-list file, so previously kept packages will be skipped 
        automatically. In batch mode, all packages, not present in the keep-
        list are either deleted or kept in the list.

    # pkg-orphan
    Package 1 of 104:
    ImageMagick-6.7.3.4: Image processing tools
    ImageMagick-6.7.3.4: Delete/Kepp/Ignore [I]: 
    ...

 II.Use ports-mgmt/pkg_cutleaves.
    **  pkg_cutleaves finds installed 'leaf' packages, i.e. packages that are
        not referenced  by any other  installed  package, and lets you decide
        for each one if you want to keep or deinstall it (via pkg_deinstall).

    # pkg_cutleaves
    autoconf-2.13.000227_6 - [keep]/(d)elete/(f)lush marked pkgs/(a)bort?
    ...
    
=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*4.2.1. Script automatic software installation (only from port collections).*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Script automatic software installation using ports collections.
=============================================================================
-----------------------------------------------------------------------------
Theory.
-----------------------------------------------------------------------------
    The script is used when you want to install a lot of ports. You create a
    list of installed ports and run script. The script has a log file - in
    case of a break network, the script can be restarted and installed only
    software that has not yet been established.
    
-----------------------------------------------------------------------------
Source code.
-----------------------------------------------------------------------------

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#!/bin/csh

# Author: valsorym
# Date: 2013.01.20

# DEFINES
# ------------------------------------------------------------------------- #
set TYPE_AUTOMODE = 'automode'
set TYPE_HANDMODE = 'handmode'
set TYPE_STEPBYSTEP = 'step by step'

# OPTIONS
# ------------------------------------------------------------------------- #
# To test script set DEBUG = 1.
set DEBUG = 0

# ON (0)/OFF (1) mode type.
set automode_enable = 1
set handmode_enable = 0
set stepbystep_enable = 1

# Load additional kernel modules.
### kldload cuse4bsd
kldload linux

# AUTOMODE
# ------------------------------------------------------------------------- #
# List port collections (automatic mode and hand mode).
# ** For $automode and $handmode use the "endlist" marker to set the end of
#    the list.

set a_devel = (devel/valgrind devel/geany)
set a_graphics = (graphics/evince graphics/inkscape graphics/epdfview \
graphics/djview4 graphics/gimp)
set a_audio = (audio/gmixer audio/moc)
set a_editors = (editors/vim-lite)
set a_multimedia = (multimedia/xmms multimedia/mplayer)
set a_misc = (misc/mc)
set a_ports_mgmt = (ports-mgmt/psearch ports-mgmt/pkg-orphan)
set a_sysutils = (sysutils/tmux sysutils/dvd+rw-tools sysutils/tree \
sysutils/screen)
set a_security = (security/sudo)
set a_archivers = (archivers/unrar archivers/p7zip)
set a_x11 = (x11/xterm x11/rxvt-unicode x11-wm/xfce4 x11/xev \
x11/xxkb x11/xorg x11-fonts/webfonts \
x11-fonts/terminus-font) ### x11-wm/dwm x11/dmenu x11/gnome-terminal 
set a_www = (www/nginx www/fcgi www/firefox www/firefox-i18n)
set a_java = (java/openjdk7 java/netbeans)

# HANDMODE
# ------------------------------------------------------------------------- #
set h_x11 = (endlist)

# INSTALL LIST
# ------------------------------------------------------------------------- #
set automode = ( \
$a_devel $a_graphics $a_audio $a_editors \
$a_multimedia $a_misc $a_ports_mgmt $a_sysutils $a_security \
$a_archivers $a_x11 $a_java $a_www \
endlist)

set handmode = (\
$h_x11 \
endlist)

# STEP BY STEP
# ------------------------------------------------------------------------- #
# ** Add to the scenario of list-specific commands.

set arr = 1
set scmax = 100
set scenario = ( \
\
# LIBREOFFICE \
'setenv BATCH yes' \
'cd /usr/ports/editors/libreoffice' \
'make LOCALIZED_LANG=ru' \
'make LOCALIZED_LANG=ru install' \
'make clean' \
'cd /usr/ports/russian/libreoffice' \
'make && make install clean' \
\
# NEXT CMD \
'ls' \
endlist)

# ------------------------------------------------------------------------- #

# + Log files.
set logdir = "/tmp/software"
set logfile = "logfile"
set logready = "logready"

# PREPARATION
set logfile="$logdir/$logfile"
set logready = "$logdir/$logready"

# + Create log-construction.
mkdir -p $logdir

if ( $DEBUG == '1' ) then
# Clear logfiles.
    echo '' > $logfile
    echo '' > $logready
endif

if ( -e $logfile ) then
    echo "Logfile: $logfile ... ok."
else
    touch $logfile
    if ( $? == '0' ) then
        echo "Logfile: $logfile ... ok."
    else
        exit(1)
    endif
endif
    
if ( -e $logready ) then
    echo "Logready: $logready ... ok."
else
    touch $logready
    if ( $? == '0' ) then
        echo "Logready: $logready ... ok."
    else
        exit(1)
    endif
endif

# INSTALL
# ------------------------------------------------------------------------- #
# + Automatically.
setenv BATCH yes
set type = "$TYPE_AUTOMODE"
set i = 0

HANDMODE:
foreach port (`echo $automode`)
# ...
    if ( $type == $TYPE_AUTOMODE ) then
        if ( $automode_enable == '0' ) then
            break
        endif
    else if ( $type == $TYPE_HANDMODE ) then
        if ( $handmode_enable == '0' ) then
            break
        endif
    endif

# Check for the port.
    # + User's end of list.
    if ( "$port" == "endlist" ) then
    # End list.
        break
    endif
    
    # + Already installed.
    less $logready | grep ^${port}$
    if ( $? == '0' ) then
        continue
    endif 
    
    # + Port is exist.
    if ( -d "/usr/ports/$port" ) then
        cd "/usr/ports/$port"
    else
        continue
    endif
    
    # Install port and write report to logfile.
    @ i += 1
    set date = `date "+%H:%M:%S %Y.%m.%d"`
    printf "$i.\tPort:\t$port\n\tStart:\t$date\n" >> $logfile
    
    set result = '1'
    if ( $DEBUG == '1' ) then
    # Debug.
        echo "DEBUGGING"
        pwd && ls
        set result = $?
    else
    # Work.    
        ### make LOCALIZED_LANG=ru && make LOCALIZED_LANG=ru install
        make && make install
        set result = $?
    
        make clean
    endif

    echo "Result ($type): $result"

    set date = `date "+%H:%M:%S %Y.%m.%d"`
    printf "\tStop:\t$date\n\tStatus: " >> $logfile
    
    if ( $result == '0' ) then
        printf "INSTALLED" >> $logfile
        echo $port >> $logready
    else
        printf "ERROR" >> $logfile
    endif
        
    printf " ($type)\n\n" >> $logfile
    rehash
end

# + Hand mode.
if ( $type != $TYPE_HANDMODE ) then
    setenv BATCH no
    set type = "$TYPE_HANDMODE"
    set automode = `echo $handmode`
    goto HANDMODE
endif

# + Step by step.
if ( $stepbystep_enable == '1' ) then
# Step by step run.
    set type = "$TYPE_STEPBYSTEP"
 
    while ( $arr < $scmax )
    # Run all cmd.
        set cmd = "$scenario[$arr]"

        if ( "$cmd" == "endlist" ) then
        # End list.
            break
        endif 

    # Run current cmd.
        @ i += 1
        set date = `date "+%H:%M:%S %Y.%m.%d"`
        printf "$i.\tCmd:\t$cmd\n\tStart:\t$date\n" >> $logfile

        set result = '1'
        if ( $DEBUG == '1' ) then
        # Debug.
            echo "DEBUGGING"
            echo "$cmd"
            set result = $?
        else
        # Work.
            eval "$cmd"
            set result = $?
        endif
    
        echo "Result ($type): $result"
        set date = `date "+%H:%M:%S %Y.%m.%d"`
        printf "\tStop:\t$date\n\tStatus: " >> $logfile
    
        if ( $result == '0' ) then
            printf "GOOD" >> $logfile
            echo $port >> $logready
        else
            printf "ERROR" >> $logfile
        endif
        
        printf " ($type)\n\n" >> $logfile

    # Next cmd.
        @ arr = $arr + 1
        unset cmd result date
    end

endif # end if ($stepbystep_enable)

# END
# ------------------------------------------------------------------------- #

less $logfile
if ( $DEBUG == '1' ) then
# Clear logfiles.
    echo '' > $logfile
    echo '' > $logready
endif

printf "\nDone!\n"

exit(0)

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

-----------------------------------------------------------------------------
View results.
-----------------------------------------------------------------------------
  I.Installed Software.
    # less /tmp/software/logfile
    1.      Port:   audio/moc
            Start:  14:15:40 2012.09.20
            Stop:   14:32:53 2012.09.20
            Status: INSTALLED (automatically)
    
    2.      Port:   misc/mc
            Start:  14:32:53 2012.09.20
            Stop:   14:54:35 2012.09.20
            Status: INSTALLED (automatically)
    
    3.      Port:   ports-mgmt/psearch
            Start:  14:54:35 2012.09.20
            Stop:   14:54:39 2012.09.20
            Status: INSTALLED (automatically)
    
    ...

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*4.3.1. Databases MySQL55.*

To view the complete contents of the HOWTO/FAQ: Back to content.
See also the short FAQ on MySQL here.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Database MySQL 55.
=============================================================================
-----------------------------------------------------------------------------
Settings.
-----------------------------------------------------------------------------
  I.Configure system files.
    1.  Configure /etc/make.conf.
        # vi /etc/make.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# MAIN
# + Ports.
PORTSDIR?=/usr/ports

# MySQL
DEFAULT_MYSQL_VER=55

# + Server.
.if ${.CURDIR} == ${PORTSDIR}/databases/mysql55-server
# BUILD_OPTIMIZED=yes
# BUILD_STATIC=yes
# WITHOUT_INNODB=yes

WITH_ARCHIVE=yes
WITH_CHARSET=utf8
WITH_COLLATION=utf8_unicode_ci
WITH_LINUXTHREADS=yes
.endif

# + Client.
.if ${.CURDIR} == ${PORTSDIR}/databases/mysql55-client
# BUILD_STATIC=yes

BUILD_OPTIMIZED=yes
WITH_CHARSET=utf8
WITH_COLLATION=utf8_unicode_ci
.endif
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  Configure /etc/rc.conf.
        # vi /etc/rc.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# LINUX
# + Binary compatibility with Linux.
linux_enable="YES"
 
# DATABASES
# + MySQL settings.
mysql_enable="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

-----------------------------------------------------------------------------
Installation.
-----------------------------------------------------------------------------
  I.Installation MySQL 55.
    A.  From ports collections.
        # cd /usr/ports/databases/mysql55-server
        # make && make install clean

    B.  From packages.
        # pkg_add -r mysql55-server
        
 II.Creating a configuration file.
    **  MySQL has four simple configuration files that located in the
        /usr/local/share/mysql/ directory:
        1) my-small.cnf  - for systems with up to 64 Mb of RAM.
        2) my-medium.cnf - for systems with up to 128 Mb of RAM.
        3) my-large.cnf  - for systems with 512 Mb of RAM.
        4) my-huge.cnf   - for systems with 1/2 Gb of RAM.

    # mkdir -p /var/db/mysql/
    # cp /usr/local/share/mysql/my-small.cnf /var/db/mysql/my.cnf

    **  Add UTF-8 support:
        Modify the blocks [client], [mysqld] and [mysql], see the comments 
        in the text.
        # vi /etc/my.cnf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# ** Add to the end of the [client] block.
[client]
# ... 
default-character-set = utf8

# ** Add to the end of the [mysqld] block.
[mysqld]
# ...
init-connect="SET NAMES utf8"
collation-server = utf8_unicode_ci
character-set-server = utf8
skip-character-set-client-handshake

# ** Add to the end of the [mysql] block.
[mysql]
# ...
default-character-set = utf8
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

**  In the file my.cnf, in case the assembly is installed without using
    innodb and launch is accompanied by message "[ERROR] Default storage
    engine (InnoDB) is not available", comment out [> skip-innodb <] and
    instead specify [> default-storage-engine = MyISAM5 <].

III.Installing database.
    # cd /usr/local; mysql_install_db
    # chown -R mysql:mysql /var/db/mysql
    # /usr/local/etc/rc.d/mysql-server start

 IV.Create MySQL root password.
    # mysqladmin -u root password 'mysqlpass'
    # mysql -uroot -pmysqlpass mysql

  V.Remove others localhost users.
    > delete from user where not (user='root' and host='localhost');
    > select user, host from user;

    +------+-----------+
    | user | host      |
    +------+-----------+
    | root | localhost |
    +------+-----------+

    **  Ok, everything is ready, you can use the MySQL.
-----------------------------------------------------------------------------
Short HOWTO on MySQL 
-----------------------------------------------------------------------------
*****************************************************************************
    Create first root password for MySQL.
*****************************************************************************
    A.  Syntax:
        # mysqladmin -u [USER] password '[PASSWORD]'

    B.  For example:
        - User: root
        - Password: mysqlpass
        # mysqladmin -u root password 'mysqlpass'

*****************************************************************************
    MySQL database management.
*****************************************************************************
    A.  Syntax:
        **  Without separators between -u and -p flags.
        # mysql -u[USER] -p[PASSWORD] mysql
    
        or:
        # mysql -u [USER] -p
        Enter password: [PASSWORD]

    B.  For example:
        - User: root
        - Password: mysqlpass
        # mysql -uroot -pmysqlpass mysql

*****************************************************************************
    Change the root password.
*****************************************************************************
    A.  Login into mysql use old root password:
        # mysql -u root -p

    B.  Create a MySQL query:
        > set password for 'root'@'localhost' = password('[NEWPASSWORD]');

*****************************************************************************
    Create new database.
*****************************************************************************
    A.  Syntax:
        > create database [DATABASE] charset=utf8;

    B.  For example:
        - Database:  mysite_db
        - Coding:    utf-8

        > create database mysite_db charset=utf8;

*****************************************************************************
    Create new user and setting permissions.
*****************************************************************************
    A.  Syntax:
        > grant all privileges on [DATABASE].* to '[USER]'@'[HOSTNAME]'
        -> identified by '[PASSWORD]' with grant option;

    B.  For example:
        - Database: mysql_db
        - New user: mysite_db_user
        - Password: mysite_db_password
        - Hostname: localhost
 
        > grant all privileges on mysite_db.* to 'mysite_db_user'@'localhost' 
        -> identified by 'mysite_db_password' with grant option;

        **  Access to the database for a given user is only possible with
            the localhost. If you want to give him access to the database
            from any host, use [ % ] instead of [ localhost ]:
            - Database: mysql_db
            - New user: mysite_db_user
            - Password: mysite_db_password
            - Hostname: localhost
 
            > grant all privileges on mysite_db.* to 'mysite_db_user'@'%' 
            -> identified by 'mysite_db_password' with grant option;

*****************************************************************************
    Checking the text encoding.
*****************************************************************************
    A.  Checking the text encoding (should be utf-8).
        > show variables like 'coll%';
        +----------------------+-------------------+
        | Variable_name        | Value             |
        +----------------------+-------------------+
        | collation_connection | utf8_general_ci   |
        | collation_database   | latin1_swedish_ci |
        | collation_server     | latin1_swedish_ci |
        +----------------------+-------------------+
                
        > show variables like 'char%';
        +--------------------------+----------------------------------+
        | Variable_name            | Value                            |
        +--------------------------+----------------------------------+
        | character_set_client     | utf8                             |
        | character_set_connection | utf8                             |
        | character_set_database   | latin1                           |
        | character_set_filesystem | binary                           |
        | character_set_results    | utf8                             |
        | character_set_server     | latin1                           |
        | character_set_system     | utf8                             |
        | character_sets_dir       | /usr/local/share/mysql/charsets/ |
        +--------------------------+----------------------------------+

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*4.3.2. Devel Ruby-Gems.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Devel Ruby-Gems.
=============================================================================
-----------------------------------------------------------------------------
Settings.
-----------------------------------------------------------------------------
  I.Configure config files.
    In /etc/make.conf add:
    # vi /etc/make.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
RUBY_VERSION=1.9.3
RUBY_DEFAULT_VER=1.9
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

-----------------------------------------------------------------------------
Installation.
-----------------------------------------------------------------------------
  I.Installation Ruby 1.9.3.
    A.  From ports collections.
        # /usr/ports/devel/ruby-gems
        # make && make install clean

    B.  From packages.
        # pkg_add -r ruby-gems

 II.To work correctly, install additional ports.
    **  In most cases, devel/libehetsinfo already installed.
    # setenv BATCH yes 
    # cd /usr/ports/devel/libexecinfo
    # make && make install clean

    # cd cd /usr/ports/www/node
    # make && make install clean
        
-----------------------------------------------------------------------------
Installing Ruby packages.
-----------------------------------------------------------------------------
**  Use the gem utility.
  I.For example, installation rails framework.
    # gem install rails

    **  Verify the installation:
        # rehash
        # rails -v
          Rails 3.2.11

    **  Gem short help:
        # gem list - Show list installed gem-packages.
        # gem update - Updtae all gem-packages.
        # gem update --system - Update gem-system.
        # gem update <GEM_PKG_NAME> - Update gem-package, for exmaple:
            > gem update rails - Update rails framework.
        # gem uninstall <GEM_PKG_NAME> - Uninstall gem-package.
        # gem enviroment - Show config RubyGems.

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*4.3.3. Dynamic DNS.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Dynamic DNS.
=============================================================================
-----------------------------------------------------------------------------
Register a domain name.
-----------------------------------------------------------------------------
  I.Register here.
    URL: http://www.no-ip.com/services/managed_dns/free_dynamic_dns.html
    **  To activate your account please click on the activation URL in your
        e-mail.
    
 II.Add new domain name.
    1.  Login in no-ip system.
        URL: http://www.no-ip.com/login/
        
    2.  Go to admin menu.
        URL:https://www.no-ip.com/members/
        
        Clik to "Add a Host" menu.
        URL: https://www.no-ip.com/members/dns/host.php
        
    3.  Add new domain.
        For WWW:
            - Host Type: DNS Host (A).
        
-----------------------------------------------------------------------------
FreeBSD settings.
-----------------------------------------------------------------------------
  I.Install special software.
    # cd /usr/ports/dns/noip
    # make && make install clean
    
 II.Create config file.
    **  Choosing the right interface.
    **  Enter the authorization data (E-mail/Password) with NO-IP service.
    # /usr/local/bin/noip2 -C
    
    ...
    New configuration file '/usr/local/etc/no-ip2.conf' created.

III.Set the owner to the configuration file:
    # chown noip:noip /usr/local/etc/no-ip2.conf
    
 IV.Modified /etc/rc.conf, add:
    # vi /etc/rc.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# NETWORK
# + NO-IP.
noip_enable="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
    
  V.Run service.
    # /usr/local/etc/rc.d/noip start

    **  To check, go to the domain name that you created.
	
-----------------------------------------------------------------------------
Global SSH access.
-----------------------------------------------------------------------------
	** If your computer has a dynamic IP address, and you need access to it
       through SSH: configure SHH demon (HOWTO: "Setting up SSH access");
       registration in NO-IP service (HOWTO: "Dynamic DNS").

  I.Modified your no-ip domain.
    Host Type: DNS Host (A).

 II.Configure NAT (Network Address Translation) on your router.
    +--------------+------------+--------------+------------+----------+
    | Service Name | Port Range |    Local IP  | Local port | Protocol |
    +--------------+------------+--------------+------------+----------+
    | SSH Server   |       2222 | 192.168.x.xx |         22 |    TCP   |
    +--------------+------------+--------------+------------+----------+

    **  IP 192.168.x.xx - IP your local web server.
    **  If your router use DHCP - assign the IP address use MAC address.
    **  Check your SSH access, use 2222 port to access.
    
=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*4.3.4. Editor Vim.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Vim editor.
=============================================================================
-----------------------------------------------------------------------------
Installation.
-----------------------------------------------------------------------------
  I.Installation Apache22.
    A.  From ports collections.
        # cd /usr/ports/editors/vim-lite
        # make && make install clean
        
    B.  From packages.
        # pkg_add -r vim-lite

-----------------------------------------------------------------------------
Settings.
-----------------------------------------------------------------------------
  I.Configure .vimrc
    **  Please go to the website www.vim.org and install these plugins:
        - NERD_tree

    # cd ~/
    # vi .vimrc

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
" VIM CONFIGURATIONS
" Author: valsorym
" Date: 2012-12-12

" OPTIONS
" ****************************************************************************
 
""" Including support for Russian language.
set keymap=russian-jcukenwin
set iminsert=0
set imsearch=0
highlight lCursor guifg=NONE guibg=Cyan

set tabpagemax=40     " Maximum open tabs using: vim -p f1 f2 .. f40
set showtabline=2     " Show tab panel.

""" Options.
set bs=2              " Full use of the backspace.
set tw=78             " String length.
""" set ai                " To include auto-indent for new lines.
""" set cin               " Include C-style indentation.
""" set autoindent        " Set auto-indent.
set tabstop=4         " Magnitude of the indentation for Tab.
set softtabstop=4     " Magnitude of the indentation for Space.
set shiftwidth=4      " The number of spaces used in the indentation
                      " ... commands, such as >> or <<;
set smarttab
set expandtab         " Insert spaces instead of Tab.
                      " To insert a tab character if  expandtab is enabled:
                      " ... 1. In edit mode: Ctrl+v, Ctrl+i
                      " ... 2. Off expandtab: set noexpandtab
set nocompatible      " Turn arrows in the mode of INSERT.
colorscheme slate     " Change the color scheme
                      " ... /usr/local/share/vim/vim73/colors/
syntax on             " Include syntax highlighting.
set background=dark   " Into thinking that the VIM background is black.
set ignorecase        " Ignore upper/lower case when searching.
set smartcase
""" set backup            " Create .bak files (default <oldname> ~).
set showmatch         " Check the brackets.
set sidescroll=5      " Scrolling (Left/Right in nowrap).
set listchars+=precedes:<,extends:> " display ">" or "<" scrolling nowrap.
set sidescrolloff=5
set guifont=terminus

set nowrap            " Do not break the line.
""" set warp              " Transfer of long lines.
""" set linebreak         " Transfer word to rather 
""" set dy=lastline       " ... than symbols.

set nu                " Line number.
set showcmd           " Show cmd in statusbar.
set wildmenu          " List menu.

set backup            " Backup.
set backupdir=/tmp    " Backup dir.

""" UTF8 and type ending of line.
set termencoding=utf-8
set fileencodings=usc-bom,utf-8mdefault,cp1251
set ffs=unix,dos,mac

""" Information about open file.
set wildmenu          " Commands autocomplete.
set laststatus=2      " Value 2 - always show the status of the status bar.
set statusline=%<%f\%{(&modified)?'\*\ ':''}%*%=C:%c%V,R:%l\ %P

" MAPPING
" ***************************************************************************

" FILES
" Open file.
imap <C-o> <Esc>:e<Space>
nmap <C-o> :e<Space>

" Save current tab.
imap <F2> <Esc>:w!<CR>
nmap <F2> :w!<CR>

" TABS
" Tab list.
imap <C-t> <Esc>:tabs<CR>
nmap <C-t> :tabs<CR>

" Move tab in N position.
imap <F3> <Esc>:tabm<Space>
nmap <F3> :tabm<Space>

" Go to N tab.
imap <F4> <Esc>:tabn<Space>
nmap <F4> :tabn<Space>

" Prev tab.
imap <F5> <Esc>:tabprev<CR>
nmap <F5> :tabprev<CR>

""" imap <C-h> <Esc>:tabprev<CR>
""" nmap <C-h> :tabprev<CR>

" Next tab.
imap <F6> <Esc>:tabnext<CR>
nmap <F6> :tabnext<CR>

""" imap <C-l> <Esc>:tabnext<CR>
""" nmap <C-l> :tabnext<CR>

" Create tab.
imap <F7> <Esc>:tabnew<CR>
nmap <F7> :tabnew<CR>

imap <C-n> <Esc>:tabnew<CR>
nmap <C-n> :tabnew<CR>

" Close current tab without save.
imap <F10> <Esc>:q!<CR>
nmap <F10> :q!<CR>

" Save and close current tab.
imap <F11> <Esc>:wq!<CR>
nmap <F11> :wq!<CR>

" EDITOR
" On / Off display of line numbers.
imap <F12> <Esc>:set<Space>nu!<CR>a
nmap <F12> :set<Space>nu!<CR>

" Encoding menu.
set wildmenu
set wcm=<Tab>
menu Encoding.koi8-r :e ++enc=koi8-r ++ff=unix<CR>
menu Encoding.windows-1251 :e ++enc=cp1251 ++ff=dos<CR>
menu Encoding.cp866 :e ++enc=cp866 ++ff=dos<CR>
menu Encoding.utf-8 :e ++enc=utf8 <CR>
menu Encoding.koi8-u :e ++enc=koi8-u ++ff=unix<CR>
map <F8> :emenu Encoding.<TAB>


" PLUGINS
" ***************************************************************************

" NERDTree.
" * HELP:
" * Use F9 for open NERDTree.
" *
" * Download NERDTree:
" * http://www.vim.org/scripts/script.php?script_id=1658
" * 
" * Unzip NERDTree archive to ~/.vim/.
" * 
" * To work with windows, use:
" * Ctrl+w, arrows - move the window to the left/right/up/down.
" * Ctrl+w, o - expand the window.
" * Ctrl+w, c - close the window.
" * Ctrl+w, s - window horizontally split.
" * Ctrl+w, v - window vertically split.
nmap <silent> <F9> :NERDTreeToggle<CR>

" FINE-TUNING
" ****************************************************************************

""" TAB'S NAMES {BEGIN}
function TabLabel(n)
    let label = ''
    let buflist = tabpagebuflist(a:n)
    let label = substitute(bufname(buflist[tabpagewinnr(a:n) - 1]), '.*/', '', '')

    if label == ''
        let label = '[No Name]'
    endif

    let label = ' ' . a:n . '. ' . label

    for i in range(len(buflist))
        if getbufvar(buflist[i], "&modified")
            let label = label . '*'
             break
        endif
    endfor

    return label
endfunction " end TabLabel().

function TabName()
    let str = ''

    for i in range(tabpagenr('$'))
        if i + 1 == tabpagenr()
            let str .= '%#TabLineSel#'
        else
            let str .= '%#TabLine#'
        endif

        let str .= '%' . (i + 1) . 'T'
        let str .= ' %{TabLabel(' . (i + 1) . ')} |'
    endfor

    let str .= '%#TabLineFill#%T'

    if tabpagenr('$') > 1
        let str .= '%=%#TabLine#%999XX'
    endif

    return str
endfunction " end TabName().

set tabline=%!TabName()

""" TAB'S NAMES {END}

""" TAB MOVE {BEGIN}
function MoveTabLeft()
    let current_tab = tabpagenr()
    if current_tab > 1
        let current_tab = current_tab - 2
        execute 'tabmove' current_tab
    endif
endfunction " end MoveTabLeft().

function MoveTabRight()
    let current_tab = tabpagenr()
    execute 'tabmove' current_tab
endfunction " end MoveTabRight().

imap <C-j> <Esc>:call MoveTabLeft()<CR>
nmap <C-j> :call MoveTabLeft()<CR>

imap <C-k> <Esc>:call MoveTabRight()<CR>
nmap <C-k> :call MoveTabRight()<CR>

""" TAB MOVE {END}

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*4.3.5. Lang Python27 and Django.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Lang Python27 and Django14.
=============================================================================
-----------------------------------------------------------------------------
Python installation.
-----------------------------------------------------------------------------
  I.Installation Python 2.7.
    A.  From ports collections.
        # /usr/ports/lang/python27
        # make && make install clean

    B.  From packages.
        # pkg_add -r python27

-----------------------------------------------------------------------------
Django installation.
-----------------------------------------------------------------------------

  I.Installation Django 1.4.5.
    A.  Hand mode.
        1.  Create a special dir for the temporary deployment of Django.
            # mkdir -p /tmp/Django/
            # cd /tmp/Django/

        2.  Download Django.
            # fetch https://www.djangoproject.com/download/1.4.5/tarball/

        3.  Install Django.
            # mv fetch.out Django-1.4.5.tar.gz
            # tar xzvf Django-1.4.5.tar.gz
            # cd Django-1.4.5
            # python setup.py install

    B.  From ports collections.
        # cd /usr/ports/www/py-django14
        # make && make install

 II.Django installation verification.
    # python
      Python 2.7.3 (default, Jan 16 2013, 01:29:45)
      [GCC 4.2.1 20070831 patched [FreeBSD]] on freebsd9
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import django
      >>> django.VERSION
      (1, 4, 5, 'final', 0)

    **  If you see this - then all ok.
    **  Use Ctrl+Z to exit the Python interactive interpreter.

III.Installation MySQL for Django.
    **  Also, you can install: databases/py-psycopg2, databases/py-postgresql
    A.  From ports collections.
        # cd /usr/ports/databases/py-MySQLdb55
        # make && make install clean

    B.  Hand mode.
        **  This method is not very good.
        1.  Download MySQL library.
            # fetch -o MySQL-python-1.2.4b4.tar.gz \
            http://sourceforge.net/projects/mysql-python/files/latest/download
    
        2.  Unpack MySQL-python-1.2.4b4.tar.gz and install it.
            # cd MySQL-python-1.2.4b4
            # python setup.py install

-----------------------------------------------------------------------------
Running a simple example.
-----------------------------------------------------------------------------
  I.Create Django project directory.
    **  I have a special section (/heap) and its structure of directories.
        You can use any other directory to hold Django projects.
    **  Do not use the directory /var/www to store Django projects - it's
        a bad idea.
    # mkdir -p /heap/warehouse/valsorym/development/projects/webworld/
    # cd /heap/warehouse/valsorym/development/projects/webworld
    # django-admin.py startproject example

    # tree example/
    example/
    |__ example/
    |   |__ __init__.py
    |   |__ settings.py
    |   |__ urls.py
    |   |__ wsgi.py
    |__ manage.py

    # cd example/
    # python manage.py runserver
    
    **  Open your browser: http://127.0.0.1:8000/
        You will see:
        
        It worked!
        Congratulations on your first Django-powered page.
    
        ...

    **  If you want to start the server using a different port or address:
        # python manage.py runserver 8000
        or
        # python manage.py runserver 0.0.0.0:8000

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*4.3.6. Sysutils Tmux.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Terminal multiplexer.
=============================================================================
-----------------------------------------------------------------------------
Note.
-----------------------------------------------------------------------------
    Tmux is a terminal multiplexer: it enables a number of terminals, each
    running a separate program, to be created, accessed, and controlled from
    a single screen. Tmux may be detached from a screen and continue running
    in the background, then later reattached.

-----------------------------------------------------------------------------
Configurate.
-----------------------------------------------------------------------------
  I.Change ~/.tmux.conf
    1.  Rewrite .tmux.conf
        # vi ~/.tmux.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# Move around panes with hjkl, as one would in vim after pressing ctrl-w.
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# Resize panes like vim.
# Feel free to change the "1" to however many lines you want to resize by,
# only one at a time can be slow.
bind < resize-pane -L 10
bind > resize-pane -R 10
bind - resize-pane -D 10
bind + resize-pane -U 10

bind-key R respawn-window
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*4.3.7. Web Server Apache22.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Web Server Apache22.
=============================================================================
-----------------------------------------------------------------------------
Installation.
-----------------------------------------------------------------------------
  I.Installation Apache22.
    A.  From ports collections.
        # cd /usr/ports/www/apache22
        # make && make install clean
        
    B.  From packages.
        # pkg_add -r apache22
        
-----------------------------------------------------------------------------
Settings.
-----------------------------------------------------------------------------
  I.Configure config files.
    1.  Add to /etc/rc.conf.
        # vi /etc/rc.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# WEB-SERVER
# + Apache22.
apache22_enable="YES"
apache22_http_accept_enable="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  Open the /usr/local/etc/apache22/httpd.conf and comment
        unique_id_modules.so.
        # vi /usr/local/etc/apache22/httpd.conf
        
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
...
LoadModule usertrack_module libexec/apache22/usertrack_module.so
# LoadModule unique_id_module libexec/apache22/unique_id_module.so
LoadModule setenvif_module libexec/apache22/setenvif_module.so
...
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

-----------------------------------------------------------------------------
Start.
-----------------------------------------------------------------------------
  I.Start Apache22.
    1.  Run Web Server.
        # /usr/local/etc/rc.d/apache22 start
        
    2.  Check result.
        # lynx 127.0.0.1

        **  You can see: It works!
        **  Local project here: /usr/local/www/nginx/
=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*4.3.8. Web Server Nginx.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Web Server Nginx.
=============================================================================
-----------------------------------------------------------------------------
Installation.
-----------------------------------------------------------------------------
  I.Installation Nginx.
    A.  From ports collections.
        # /usr/ports/www/nginx
        # make && make install clean
        
    B.  From packages.
        # pkg_add -r nginx
        
-----------------------------------------------------------------------------
Settings.
-----------------------------------------------------------------------------
  I.Configure config files.
    In /etc/rc.conf add:
    # vi /etc/rc.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# WEB_SERVER
# + Ngnix.
nginx_enable="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

-----------------------------------------------------------------------------
Start.
-----------------------------------------------------------------------------
  I.Start Ngnix.
    1.  Run Web Server.
        # /usr/local/etc/rc.d/nginx start
        
    2.  Check result.
        # lynx 127.0.0.1

        **  You can see: Welcome to ngnix.

-----------------------------------------------------------------------------
FastCGI interface and FCGI Program on C language.
-----------------------------------------------------------------------------
  I.Install FastCGI Devel Kit.
    A.  From ports collections.
        # cd /usr/ports/www/fcgi
        # make && make install clean
        
    B.  From packages.
        # pkg_add -r fcgi
        
 II.Install spawn-fcgi tool.
    A.  From ports collections.
        # cd /usr/ports/www/spawn-fcgi
        # make && make install clean
        
    B.  From packages.
        # pkg_add -r spawn-fcgi
        
III.Create virtual host.
    1.  For example, host name: site-a.vals - add to /etc/hosts
        # vi /etc/hosts
        
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
...
127.0.0.1       site-a.vals
...
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
   
    2.  Configure nginx.
        # cd /usr/local/etc/nginx/
        # vi nginx.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
    server {
        listen          80;
        server_name     site-a.vals;
        access_log      /var/log/nginx/site-a.vals.access.log;

        location / {
            root            /usr/local/www/site-a.vals/www;
            index           index.htm index.html;
            include         fastcgi_params;
            fastcgi_pass    127.0.0.1:9000;
        }
    }
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    3.  Reload configuration.
        # mkdir -p /var/log/nginx/
        # mkdir -p /usr/local/www/site-a.vals/www
        # /usr/local/etc/rc.d/nginx restart
        
    4.  Create FCGI program.
        # cd /usr/local/www/site-a.vals/www
        # vi index.c
        
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/* cc -O2 -o index.fcgi index.c -L/usr/local/lib -lfcgi */
#include </usr/local/include/fcgi_stdio.h>
#include <stdlib.h>

int
main(int argc, char **argv)
{
/* Initialization. */
    int count = 0;

/* Response loop. */
    while (FCGI_Accept() >= 0) {
        printf("Content-type: text/html\r\n"
                "\r\n"
                "<title>FastCGI A! (C, fcgi_stdio library)</title>"
                "<h1>FastCGI Hello! (C, fcgi_stdio library)</h1>"
                "Request number %d running on host <i>%s</i>\n",
                ++count, getenv("DOCUMENT_URI"));
    }

    return 0;
}
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
    
    5.  Run FCGI program.
        # cc -O2 -o index.fcgi index.c -L/usr/local/lib -lfcgi
        # spawn-fcgi -a 127.0.0.1 -p 9000 ./index.fcgi
        spawn-fcgi: child spawned successfully: PID: 4477
        
        Check result.
        # lynx site-a.vals

-----------------------------------------------------------------------------
Local Server in Global World.
-----------------------------------------------------------------------------
    **  In here we use NO-IP service.
    **  See "Dynamic DNS" HOWTO.

  I.Create no-ip domain name.
    Host Type: DNS Host (A).
    
 II.Modified nginx config file.
    We will be listen 777 port.
    # vi  vim /usr/local/etc/nginx/nginx.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
    server {
        listen          777;
        server_name     site-a.vals;
        access_log      /var/log/nginx/site-a.vals.access.log;
        
        ...
    }
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

III.Configure NAT (Network Address Translation) on your router.
    +--------------+------------+--------------+------------+----------+
    | Service Name | Port Range |    Local IP  | Local port | Protocol |
    +--------------+------------+--------------+------------+----------+
    | HTTP Server  |         80 | 192.168.x.xx |        777 |    TCP   |
    +--------------+------------+--------------+------------+----------+

    **  IP 192.168.x.xx - IP your local web server.
    **  If your router use DHCP - assign the IP address use MAC address.

  V.Restart nginx.
    # /usr/local/etc/rc.d/nginx restart
    
    **  Check your website.

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*4.3.9. X11 Dwm (Ptr 1).*

To view the complete contents of the HOWTO/FAQ: Back to content.
Go to 4.3.9. X11 Dwm (Ptr 2).

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    DWM Window manager.
=============================================================================
-----------------------------------------------------------------------------
Note.
-----------------------------------------------------------------------------
    Dwm is a dynamic window manager. It manages windows in tiled, monocle and
    floating layouts. All of the layouts can be applied dynamically,
    optimising the environment for the application in use and the task
    performed.

-----------------------------------------------------------------------------
Installing from ports collections.
-----------------------------------------------------------------------------
  I.Installing DWM.
    # cd /usr/ports/x11-wm/dwm
    # make && make install 

    **  Do not use goal "clean" in make, etc - make clean. After installing
        we need ./work/dwm-x.n/ directory.

 II.Installation of additional software.
    1.  Program to identify the key code.
        # cd /usr/ports/x11/xev
        # make && make install clean
        
-----------------------------------------------------------------------------
Configure and recompile DWM.
-----------------------------------------------------------------------------
  I.Go to the working directory.
    # cd /usr/ports/x11-wm/dwm/work/dwm-6.0/

    **  In my case, I use DWM-6.0.
    **  We are interested in the files: config.h and dwm.c.
    
 II.Rewrite DWM configurations.
    # vi config.h

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/* DWM DWM Window manager.
 * Author: valsorym
 * Date: 2012.08.12
 */

/***************************************************************************/
/*******                          MAIN                               *******/
/***************************************************************************/
/* Font scheme. 
 * Support Latin (Russian, Ukrainian, Belarusian).
 */
static const char font[] = "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-koi8-r";

/* Color scheme. */
static const char normbordercolor[] = "#444444";
static const char normbgcolor[] = "#222222";
static const char normfgcolor[] = "#bbbbbb";
static const char selbordercolor[] = "#222222";
static const char selbgcolor[] = "#222222";
static const char selfgcolor[] = "#eeeeee";

/* View scheme. */
static const unsigned int borderpx = 1;   /* Border pixel of windows. */
static const unsigned int snap = 32;      /* Snap pixel. */
static const Bool showbar = True;         /* False means no bar. */
static const Bool topbar = True;          /* False means bottom bar. */

/***************************************************************************/
/*******                          TAGGING                            *******/
/***************************************************************************/
/* Tabs caption. */
static const char *tags[] = {"[cmd]", "[www]", "[free]", "[free]", "[free]"};

/* Parameters of the run programs. */
/* Tags mask:
 *     ~0      -   free and run everywhere.
 *     1 << 4  -   run only in the 5 tab.
 *     1 << 1  -   run only in the 2 tab.
 */
static const Rule rules[] = {
  /*  CLASS      INSTANCE  TITLE     TAGS MASK   ISFLOATING  MONITOR */
  /*{ "Gimp",    NULL,     NULL,     ~0,         True,       -1 },
    { "MPlayer", NULL,     NULL,     ~0,         True,       -1 },
    { "Conky",   NULL,     NULL,     1 << 4,     False,      -1 }, 
    { "XTerm",   NULL,     NULL,     1 << 4,     False,      -1 }, */
    
    { "gnome-terminal",   
                 NULL,     NULL,     1 << 4,     False,      -1 },
    { "Opera",   NULL,     NULL,     1 << 1,     False,      -1 },
};

/***************************************************************************/
/*******                         LAYOUT(S)                           *******/
/***************************************************************************/
/* Factor of master area size [0.05..0.95]. */
static const float mfact = 0.75; 

/* Number of clients in master area. */
static const int nmaster = 1;    

/* True means respect size hints in tiled resizals. */
static const Bool resizehints = True; 

static const Layout layouts[] = {
    /* SYMBOL  |  ARRANGE
     *            FUNCTION */
    { "[t]",      tile },  /* First entry is default. */
    { "[f]",      NULL },  /* No layout function means floating behavior. */
    { "[m]",      monocle },
};

#define MODKEY Mod1Mask
#define TAGKEYS(KEY,TAG) \
    { MODKEY,                       KEY,  view,       {.ui = 1 << TAG} }, \
    { MODKEY|ControlMask,           KEY,  toggleview, {.ui = 1 << TAG} }, \
    { MODKEY|ShiftMask,             KEY,  tag,        {.ui = 1 << TAG} }, \
    { MODKEY|ControlMask|ShiftMask, KEY,  toggletag,  {.ui = 1 << TAG} },

/* Helper for spawning shell commands in the pre dwm-5.0 fashion. */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }

/* Commands. */
static const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb",
    normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf",
    selfgcolor, NULL };
static const char *termcmd[]  = { "urxvt", NULL };

/***************************************************************************/
/*******                      KEY DEFINITIONS                        *******/
/***************************************************************************/
static Key keys[] = {
    /* MODIFIER          KEY        FUNCTION        ARGUMENT */
    { MODKEY,            XK_p,      spawn,          {.v = dmenucmd } },
    { MODKEY|ShiftMask,  XK_Return, spawn,          {.v = termcmd } },
    { MODKEY,            XK_b,      togglebar,      {0} },
    { MODKEY,            XK_j,      focusstack,     {.i = +1 } },
    { MODKEY,            XK_k,      focusstack,     {.i = -1 } },
    { MODKEY,            XK_i,      incnmaster,     {.i = +1 } },
    { MODKEY,            XK_d,      incnmaster,     {.i = -1 } },
    { MODKEY,            XK_h,      setmfact,       {.f = -0.05} },
    { MODKEY,            XK_l,      setmfact,       {.f = +0.05} },
    { MODKEY,            XK_Return, zoom,           {0} },
    { MODKEY,            XK_Tab,    view,           {0} },
    { MODKEY|ShiftMask,  XK_c,      killclient,     {0} },
    { MODKEY,            XK_t,      setlayout,      {.v = &layouts[0]} },
    { MODKEY,            XK_f,      setlayout,      {.v = &layouts[1]} },
    { MODKEY,            XK_m,      setlayout,      {.v = &layouts[2]} },
    { MODKEY,            XK_space,  setlayout,      {0} },
    { MODKEY|ShiftMask,  XK_space,  togglefloating, {0} },
    { MODKEY,            XK_0,      view,           {.ui = ~0 } },
    { MODKEY|ShiftMask,  XK_0,      tag,            {.ui = ~0 } },
    { MODKEY,            XK_comma,  focusmon,       {.i = -1 } },
    { MODKEY,            XK_period, focusmon,       {.i = +1 } },
    { MODKEY|ShiftMask,  XK_comma,  tagmon,         {.i = -1 } },
    { MODKEY|ShiftMask,  XK_period, tagmon,         {.i = +1 } },
    
    /* [!] Add this function in dwm.c file.
     * Function resets the position of windows to the standard.
     */
    { MODKEY,            XK_q,      zeronmaster,    {.i = 0 } },
    
    /* Learn the key code with the utility "xev". */
    TAGKEYS(0xffbe,  0) /* F1 */
    TAGKEYS(0xffbf,  1) /* F2 */
    TAGKEYS(0xffc0,  2) /* .. */
    TAGKEYS(0xffc1,  3)
    TAGKEYS(0xffc2,  4)
    TAGKEYS(0xffc3,  5)
    TAGKEYS(0xffc4,  6)
    TAGKEYS(0xffc5,  7)
    TAGKEYS(0xffc6,  8) /* F9 */
    
    { MODKEY|ShiftMask,  XK_q,   quit, {0} },
};

/***************************************************************************/
/*******                     BUTTON DEFINITIONS                      *******/
/***************************************************************************/
/* Click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin,
 * or ClkRootWin
 */
static Button buttons[] = {
    /* CLICK         EVENT MASK  BUTTON    FUNCTION     ARGUMENT */
    { ClkLtSymbol,   0,          Button1,  setlayout,   {0} },
    { ClkLtSymbol,   0,          Button3,  setlayout,   {.v = &layouts[2]} },
    { ClkWinTitle,   0,          Button2,  zoom,        {0} },
    { ClkStatusText, 0,          Button2,  spawn,       {.v = termcmd } },
    { ClkClientWin,  MODKEY,     Button1,  movemouse,   {0} },
    { ClkClientWin,  MODKEY,     Button2,  togglefloating, {0} },
    { ClkClientWin,  MODKEY,     Button3,  resizemouse,    {0} },
    { ClkTagBar,     0,          Button1,  view,           {0} },
    { ClkTagBar,     0,          Button3,  toggleview,     {0} },
    { ClkTagBar,     MODKEY,     Button1,  tag,            {0} },
    { ClkTagBar,     MODKEY,     Button3,  toggletag,      {0} },
};
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
```


----------



## valsorym (Mar 26, 2013)

*4.3.9. X11 Dwm (Ptr 2).*

To view the complete contents of the HOWTO/FAQ: Back to content.
Go to 4.3.9. X11 Dwm (Ptr 1).

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
III.Add our zeronmaster function in DWM.
    # vi dwm.c

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
...
static void incnmaster(const Arg *arg);
static void zeronmaster(const Arg *arg);    /* [!] Add it. Line: ~196 */
static void initfont(const char *fontstr);
...

...
/* [!] Add it. Line: ~1035 */
void									
zeronmaster(const Arg *arg) {
	selmon->nmaster = 1;
	arrange(selmon);
}
...
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

 IV.Reinstall DWM.
    # cd /usr/ports/x11-wm/dwm/
    # make deinstall
    # make && make install

-----------------------------------------------------------------------------
Additional software.
-----------------------------------------------------------------------------
    Program that displays the time, keyboard layoutand and battery status.
    # cd /usr/ports/x11-wm/dwm/work/dwm-6.0/
    # vi dwmbar.c

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
*****************************************************************************

SEE URL: http://pastebin.com/tuRfDzGc

*****************************************************************************
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .    


    Compile it:
    # cc -Wall -ansi -o dwmbar dwmbar.c -I/usr/local/include \
		-L/usr/local/lib -lX11
    
    Copy bin file:
    # cp ./dwmbar /usr/bin/

-----------------------------------------------------------------------------
Setup utility.
-----------------------------------------------------------------------------
  I.Switching the keyboard layout.
    # vi ~/.xxkbrc

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
XXkb.button.enable: no

XXkb.controls.two_state: no
XXkb.controls.focusout: yes
XXkb.controls.add_when_start: yes
XXkb.controls.add_when_create: yes
XXkb.controls.add_when_change: yes

XXkb*label.text.1: En
XXkb*label.text.2: Ru
XXkb*label.text.3: Ua

XXkb.mainwindow.type: tray
XXkb.mainwindow.enable: no
XXkb.mainwindow.appicon: no
XXkb.mainwindow.geometry: 20x20

XXkb.mainwindow.label.enable: no
XXkb.mainwindow.label.background: transperent
XXkb.mainwindow.label.foreground: #ffffff
XXkb.mainwindow.label.font: -misc-*-r-*-13-*

XXkb.mainwindow.border.color: white
XXkb.mainwindow.border.width: 2
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    Copy config file others users.
    # cp .xxkbrc /usr/home/<USERNAME>/
    
-----------------------------------------------------------------------------
Setting Xorg.
-----------------------------------------------------------------------------
  I.Install Xorg.
    A.  From ports collections.
        # cd /usr/ports/x11/xorg
        # make && make install clean
        
    B.  From packages.
        # pkg_add -r xorg
    
 II.Configure.
    **  Add next options.
    # vi /etc/rc.conf
    
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# GUI
# + Mouse and Keyboard in GUI.
hald_enable="YES"
dbus_enable="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

III.Create xorg.conf.
    1.  Configure.
        # Xorg -configure
        # Xorg -config /root/xorg.conf.new

    2.  After go to next screen (Alt+F3).
        # cd /root/
        # cp xorg.conf.new /etc/X11/xorg.conf

-----------------------------------------------------------------------------
Launch DWM.
-----------------------------------------------------------------------------
  I.Configure X.
    **  DWM will only run under the user.
    # vi /usr/home/<USERNAME>/.xinitrc
  
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
export LANG="ru_RU.UTF-8"
export LC_ALL="ru_RU.UTF-8"

setxkbmap -layout us,ru,ua -variant \
-option grp:lwin_toggle,grp_led:scroll,terminate:ctrl_alt_bksp &

xxkb &
mixer 95:95 &
gnome-terminal &
dwmbar &

exec dwm
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

 II.Launch DWM.
    # startx

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*4.3.10. X11 Kde4.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Kde4 Desktop Environment.
=============================================================================
-----------------------------------------------------------------------------
Note.
-----------------------------------------------------------------------------
    KDE is an international free software community producing an integrated 
    set of cross-platform applications designed to run on GNU/Linux, FreeBSD,
    Solaris, Microsoft Windows, and OS X systems.

-----------------------------------------------------------------------------
Installing from packages.
-----------------------------------------------------------------------------
  I.Installing KDE4.
    **  KDE4 installation time can be problems with the packages:
        qt4-doc-4.7.4.tbz, kdeartwork-4.7.3.tbz - we need to download the
        packages and install them manually and restart the cycle KDE4
        installation.
	**	For FreeBSD 9.1 packages do not exist - to change the value of a
	    global variable PACKAGESITE for installation packages version 9.0.

    # pkg_add -r kde4
    
 II.Russification.
    # pkg_add -r ru-kde-l10n
    
    **  After starting KDE: settings - language - russian.

-----------------------------------------------------------------------------
Change of system files.
-----------------------------------------------------------------------------
  I.Automatic start.
    # vi /etc/rc.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# GUI I/O
# + Mouse and Keyboard in GUI.
hald_enable="YES"
dbus_enable="YES"

# DE/WM
# + KDE
kdm4_enable="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

 II.Start use xstart.
    # vi /etc/rc.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# GUI I/O
# + Mouse and Keyboard in GUI.
hald_enable="YES"
dbus_enable="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    # vi ~/.xinitrc
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
export LANG="ru_RU.UTF-8"
export LC_ALL="ru_RU.UTF-8"

# KDE4
exec /usr/local/kde4/bin/startkde
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .	


=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*4.3.11. X11 Xcompmgr.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Xcompmgr composite manager.
=============================================================================
-----------------------------------------------------------------------------
Note.
-----------------------------------------------------------------------------
    Xcompmgr is a simple composite manager capable of rendering drop shadows
    and, with the use of the transset utility, primitive window transparency.

-----------------------------------------------------------------------------
Installing.
-----------------------------------------------------------------------------
  I.Installing Xcompmgr.
    A.  From packages.
        # pkg_add -r xcompmgr

-----------------------------------------------------------------------------
Run.
-----------------------------------------------------------------------------
  I.Simple run.
    % xcompmgr -c

-----------------------------------------------------------------------------
Gnome2 + Gcompmgr.
-----------------------------------------------------------------------------
**  gcompmgr, is a Gnome GUI interface to xcompmgr, it is an anjuta managed
    project in C++ with a GTKmm/Gnome2 backend. Through xcompmgr it allows 
    you to use your graphics card to create effects in your Gnome window 
    manager.

  I.Install.
    **
    # pkg_add -r gcompmgr
    # rehash

 II.And run.
    # gcompmgr

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*4.3.12. X11 Xfce4.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Xfce4 Desktop Environment.
=============================================================================
-----------------------------------------------------------------------------
Note.
-----------------------------------------------------------------------------
    Xfce is a lightweight desktop environment for UNIX operating systems.
    It aims to be fast and low on system resources, while still being
    visually appealing and user friendly.

-----------------------------------------------------------------------------
Installing from ports collections.
-----------------------------------------------------------------------------
  I.Installing Xfce4.
    # cd /usr/ports/x11/xorg
    # make && make install clean

    # cd /usr/ports/x11-fonts/webfonts
    # make && make install clean
    
    # cd /usr/ports/x11-wm/xfce4
    # make && make install clean

 II.Installation of additional software.
    1.  Program to identify the key code.
        # cd /usr/ports/x11/xev
        # make && make install clean

    2.  Program to displays the current layout in the panel Xfce.
        # cd /usr/ports/deskutils/xfce4-xkb-plugin
        # make && make install clean

    3.  Program to display the battery status on the panel Xfce.
        # cd /usr/ports/sysutils/xfce4-battery-plugin
        # make && make install clean

-----------------------------------------------------------------------------
Change of system files.
-----------------------------------------------------------------------------
  I.Change /boot/loader.con file.
    # vi /boot/loader.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# ACPI
# + Control (on/off) video outputs.
acpi_video_load="YES"

# + Adds additional controls in the system tree MIB (for example, you can 
#   on/off wifi module or card reader, etc.).
acpi_asus_load="YES"

# MOUNTING
# + Filesystem.
libiconv_load="YES"
libmchain_load="YES"
cd9660_iconv_load="YES"
msdosfs_iconv_load="YES"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

 II.Change /usr/local/etc/PolicyKit/PolicyKit.conf file.
    **  Give users the right to restart and shutdown.
    # vi /usr/local/etc/PolicyKit/PolicyKit.conf

    **  Between <config> </config> tags add:
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
<match action="org.freedesktop.hal.power-management.shutdown">
    <return result="yes"/>
</match>
 
<match action="org.freedesktop.hal.power-management.reboot">
    <return result="yes"/>
</match>
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

III.Change /etc/fstab file.
    **  Software could to get information on access rights.
    1.  Add to file.
        # vi /etc/fstab

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
proc    /proc    procfs    rw    0    0
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  Mount poc filesystem.
        # mount /proc

 IV.Change org.freedesktop.consolekit.pkla file.
    **  Activate button shutdown and reboot.
    # cd /usr/local/etc/polkit-1/localauthority/50-local.d/
    # vi org.freedesktop.consolekit.pkla

    **  Notice the line:
        Identity=unix-group:ENTER_HERE_YOUR_GROUP
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
[Restart]
Identity=unix-group:ENTER_HERE_YOUR_GROUP
Action=org.freedesktop.consolekit.system.restart
ResultAny=yes
ResultInactive=yes
ResultActive=yes
 
[Shutdown]
Identity=unix-group:ENTER_HERE_YOUR_GROUP
Action=org.freedesktop.consolekit.system.stop
ResultAny=yes
ResultInactive=yes
ResultActive=yes
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

-----------------------------------------------------------------------------
Start Xfce4 (console method).
-----------------------------------------------------------------------------
  I.Run the command.
    **  Under simple user.
    # gconftool-2 --type list --list-type=string \
    --set /system/storage/default_options/vfat/mount_options \
    "[longnames,-u=,-L=ru_RU.UTF-8,-D=cp866]"

 II.Configure start Xfce4.
    **  Under simple user.
    # vi ~/.xinitrc

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
export LANG="ru_RU.UTF-8"
export LC_ALL="ru_RU.UTF-8"

mixer 95:95 &
exec /usr/local/bin/startxfce4
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    **  To start, use the command:
        # xstart
 
-----------------------------------------------------------------------------
Start Xfce4 (custom method).
-----------------------------------------------------------------------------
  I.Run the command.
    **  Under simple user.
    # gconftool-2 --type list --list-type=string \
    --set /system/storage/default_options/vfat/mount_options \
    "[longnames,-u=,-L=ru_RU.UTF-8,-D=cp866]"
    
 II.Install and configure xdm.
    1.  Install xdm.
        # cd /usr/ports/x11/xdm
        # make && make install clean
        
    2.  Configure xdm.
    **  Modified /etc/ttys.
        # vi /etc/ttys

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ttyv8   "/usr/local/bin/xdm -nodaemon"  xterm   on  secure
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    3.  Change ~/.xsession
    **  Under simple user.
        # vi ~/.xsession
        
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
export LANG="ru_RU.UTF-8"
export LC_ALL="ru_RU.UTF-8"

exec /usr/local/bin/startxfce4
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    **  The end. Reboot system.

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*5.1.1. Dump and Restore.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Dump and Restore.
=============================================================================
-----------------------------------------------------------------------------
Create snapshot your systemi (dump & restore).
-----------------------------------------------------------------------------
    ** For example, use an external drive /dev/da0a to store the backup.
    
  I. Without compression.
    A.  Create.
        # mount /dev/da0a /mnt
        # dump -C16 -0uanL -h0 -f /mnt/root.dump /
        # dump -C16 -0uanL -h0 -f /mnt/var.dump /var
        # dump -C16 -0uanL -h0 -f /mnt/usr.dump /usr
        # umount /mnt

    B.  Restore.
        # mount /dev/da0a /mnt
        # cd / && restore -ruf /mnt/root.dump
        # cd /var && restore -ruf /mnt/var.dump
        # cd /usr && restore -ruf /mnt/usr.dump
        # umount /mnt
        
 II.Use compression.
    A.  Create.
        # mount /dev/da0a /mnt
        # dump -C16 -0uanL -h0 -f - /    | gzip -2 > /mnt/root.dump.gz
        # dump -C16 -0uanL -h0 -f - /var | gzip -2 > /mnt/var.dump.gz
        # dump -C16 -0uanL -h0 -f - /usr | gzip -2 > /mnt/usr.dump.gz
        # umount /mnt

    B.  Restore.
        # mount /dev/da0a /mnt
        # gzcat /mnt/root.dump.gz | (cd / && restore -ruf -)
        # gzcat /mnt/var.dump.gz  | (cd /var && restore -ruf -)
        # gzcat /mnt/usr.dump.gz  | (cd /usr && restore -ruf -)
        # umount /mnt
        
-----------------------------------------------------------------------------
Backup via SSH.
-----------------------------------------------------------------------------
  I.Create and restore.
    A.  Create.
        # dump -C16 -0uanL -h0 -f - /    | gzip -2 | 
            ssh -c blowfish user@host dd of=root.dump.gz
        # dump -C16 -0uanL -h0 -f - /var | gzip -2 | 
            ssh -c blowfish user@host dd of=var.dump.gz
        # dump -C16 -0uanL -h0 -f - /usr | gzip -2 | 
            ssh -c blowfish user@host dd of=usr.dump.gz

    B.  Restore.
        # mkdifr /tmp/root /tmp/var /tmp/usr
        # ssh -c blowfish usr@host gzcat root.dump.gz | 
            (cd /tmp/root && restore -ruf -)
        # ssh -c blowfish usr@host gzcat var.dump.gz  | 
            (cd /tmp/var && restore -ruf -)
        # ssh -c blowfish usr@host gzcat usr.dump.gz  | 
            (cd /tmp/usr && restore -ruf -)

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*5.2.1. Create local repository.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                            HOWTO FOR FREEBSD 9.x.
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Create local repository.
=============================================================================
-----------------------------------------------------------------------------
Create a local repository of installed programs.
-----------------------------------------------------------------------------
  I.Create a custom script.
    1.  Create script.
        # mkdir -p ~/localrepo
        # cd ~/localrepo
        # vi create.csh
    
[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
#!/bin/csh

# Author: valsorym
# Date: 2013.01.20

# OPTIONS
set packages = `pkg_info | cut -d' ' -f1`
set localrepo = "$HOME/localrepo/"

# WORK
mkdir -p $localrepo
cd $localrepo

foreach package ($packages)
    pkg_create -b $package
end

unset localrepo packages

echo "Done!"
echo ""

exit(0)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  Run script.
        # csh create.csh

    **  Local repository will be created in ~/localrepo/
    **  See "Installation of the packages" HOWTO for installed software from
        local repository.

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*1.1.1. Short MySQL FAQ (Part 1).*

To view the complete contents of the HOWTO/FAQ: Back to content.
See also the short HOWTO for MySQL here.
Go to 1.1.1. Short MySQL FAQ (Part 2).

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                                   FAQ MySQL 55
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Database MySQL 55.
=============================================================================
-----------------------------------------------------------------------------
Attention.
-----------------------------------------------------------------------------
    **  Installation instructions, see in the MySql55 HOWTO.
    **  We use syntax of the form: [USERNAME] or [PASSWORD] - you need 
        instead to specify a username or password.

-----------------------------------------------------------------------------
Useful links.
-----------------------------------------------------------------------------
  I.http://www.mysql.ru/docs/pautov/sql.htm

*****************************************************************************
                                MAIN OPTIONS
*****************************************************************************
-----------------------------------------------------------------------------
First run MysqlAdmin.
-----------------------------------------------------------------------------
  I.Installing database.
    # cd /usr/local; mysql_install_db
    # chown -R mysql:mysql /var/db/mysql
    # /usr/local/etc/rc.d/mysql-server start

 II.For the first time set a root password.
    A.  Install only the password.
        # mysqladmin -u root password '[PASSWORD]'

    B.  Set a password and host name.
        # mysqladmin -u root -h '[HOSTNAME]' password '[PASSWORD]'

III.Starting the server console.
    A.  Quick start.
        ** No spaces between the parameters and data.
        # mysql -u[USERNAME] -p[PASSWORD] mysql

    B.  Standard launch.
        # mysql -u [USERNAME] -p
        Enter password:

 IV.Remove others localhost users.
    > delete from user where not (user='root' and host='localhost');
    > select user, host from user;

    +------+-----------+
    | user | host      |
    +------+-----------+
    | root | localhost |
    +------+-----------+
    1 row in set (0.00 sec)

  V.Exit from the server console.
    A.  Use 'quit' sql query.
        > quit

    B.  Use 'exit' sql query.
        > exit

-----------------------------------------------------------------------------
Change the root password.
-----------------------------------------------------------------------------
  A.Change the root password.
    **  If you know the root password.
    1.  Start the MySQL console.
        # mysql -u root -p
        Password:

    2.  Create a MySQL query:
        > set password for 'root'@'localhost' = password('[NEWPASSWORD]');

  B.Reset the administrator password.
    **  If you forget the root password.
    **  If mysql-server has been turned off/on several times:
        Using the top or htop - kill processes: mysql, mysqd_safe etc., and
        # /usr/local/etc/rc.d/mysql-server stop
        # /usr/local/etc/rc.d/mysql-server start

    1.  Edit /usr/local/etc/rc.d/mysql-server file.
        **  Add to the beginning of the file.
        # vi /usr/local/etc/rc.d/mysql-server

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
mysql_args="--init-file=/root/mysql-pass-reset"
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    2.  Create a script change the password.
        **  Password must be replaced twice in the [NEWPASSWORD].
        # vi /root/mysql-pass-reset

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
update mysql.user set password = password('[NEWPASSWORD]') where user='root';
grant all privileges on *.* to root@localhost identified by password
password('[NEWPASSWORD]') with grant option;
flush privileges;
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    3.  Restart mysql-server.
        # /usr/local/etc/rc.d/mysql-server restart
  
    4.  Connect to mysql use new password.
        # mysql -u root -p
        Password: [NEWPASSWORD]

    **  If the connection fails - restart mysql server and try again.
    **  Comment out mysql_args="--init-file=/root/mysql-pass-reset" in the 
        file: /usr/local/etc/rc.d/mysql-server
    **  Remove /root/mysql-pass-reset.

-----------------------------------------------------------------------------
Removing the anonymous account.
-----------------------------------------------------------------------------
  I.Start the MySQL console as root and run the query.
    > use mysql;
    > delete from user where User = '';
    > delete from db where User = '';
    > flush privileges;

*****************************************************************************
                             DATABASE OPERATIONS
*****************************************************************************
-----------------------------------------------------------------------------
View databases.
-----------------------------------------------------------------------------
  I.Start the MySQL console as root and run the query.
    > show databases;

    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | test               |
    +--------------------+
    4 rows in set (0.00 sec)

-----------------------------------------------------------------------------
Create a new database.
-----------------------------------------------------------------------------
  I.Start the MySQL console as root and run the query.
    A.  Rough method.
        > create database [DATABASE];
        or
        > create database [DATABASE] charset=[CODING];

    B.  Mild method.
        > create database if not exists [DATABASE];
        or
        > create database if not exists [DATABASE] charset=[CODING];

 II.Example.
    **  Creating a database with encoding utf-8.
    **  Attention! The server mysql must be configured properly. 
    > create database if not exists my_site_database charset=utf8;

-----------------------------------------------------------------------------
Remove database.
-----------------------------------------------------------------------------
  I.Start the MySQL console as root and run the query.
    A.  Rough method.
        > drop database [DATABASE];

    B.  Mild method.
        > drop database if exists [DATABASE];

-----------------------------------------------------------------------------
Select database.
-----------------------------------------------------------------------------
  I.Start the MySQL console as root and run the query.
    > use [DATABASE];
```


----------



## valsorym (Mar 26, 2013)

*1.1.1. Short MySQL FAQ (Part 2).*

To view the complete contents of the HOWTO/FAQ: Back to content.
Go to 1.1.1. Short MySQL FAQ (Part 1).

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
*****************************************************************************
                              TABLES OPERATIONS
*****************************************************************************
-----------------------------------------------------------------------------
View tables.
-----------------------------------------------------------------------------
  I.Start the MySQL console.
    1.  Select database.
        > use [DATABASE];

    2.  View tables.
        > show tables;

    3.  View table status.
        > show table status;

-----------------------------------------------------------------------------
Create tables.
-----------------------------------------------------------------------------
  I.Start the MySQL console.
    1.  Select database.
        > use [DATABASE];

    2.  Create query.
        > create table [TABLENAME] (
        -> id int not null auto_increment primary key,
        -> [ARGNAME] [ARGTYPE],
        ...
        -> [ARGNAME] [ARGTYPE]
        ) type = [TABLETYPE];

    Example:
        > drop database if exists helloworld;
        > create database helloworld;
        > use helloworld;

        > create table messages (
        -> id int not null auto_increment primary key,
        -> message varchar(77));

        > show tables;

        +----------------------+
        | Tables_in_helloworld |
        +----------------------+
        | messages             |
        +----------------------+
        1 row in set (0.00 sec)

-----------------------------------------------------------------------------
Delete tables.
-----------------------------------------------------------------------------
  I.Start the MySQL console.
    1.  Select database.
        > use [DATABASE];

    2.  Create query.
        > drop table if exists [TABLENAME];

-----------------------------------------------------------------------------
Show table data.
-----------------------------------------------------------------------------
  I.Start the MySQL console.
    1.  Select database.
        > use [DATABASE];

    2. Create query.
        > select [FIELD_1],[FIELD_ ...],[FIELD_N] from [TABLENAME];

    Example:
        > use mysql;
        > select user,password,host from user;

*****************************************************************************
                             ACCOUNTS OPERATIONS
*****************************************************************************
-----------------------------------------------------------------------------
View users.
-----------------------------------------------------------------------------
  I.Start the MySQL console as root and run the query.
    > use mysql;
    > select user,password,host from user;

    +-------------+-------------------------------------------+-----------+
    | user        | password                                  | host      |
    +-------------+-------------------------------------------+-----------+
    | root        | *CDC006E5FCB22B379747AF6E75DF97FB503F11B3 | localhost |
    +-------------+-------------------------------------------+-----------+
    1 rows in set (0.01 sec)

-----------------------------------------------------------------------------
Create an new account.
-----------------------------------------------------------------------------
  I.Start the MySQL console as root and run the query.
    **  Database [DATABASE] must already be created.
    > grant all privileges on [DATABASE].* to '[USERNAME]'@'[HOSTNAME]'
    -> identified by '[PASSWORD]' with grant option;
    > flush privileges;

-----------------------------------------------------------------------------
Remove users.
-----------------------------------------------------------------------------
  I.Start the MySQL console as root and run the query.
    A.  Use drop query.
        > drop user '[USERNAME]'@'[HOSTNAME]';

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*2.1.1.1 Devel Ruby-Gems.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                             FAQ DEVEL RUBY-GEMS
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Install Ruby-Gems.
=============================================================================
-----------------------------------------------------------------------------
Settings.
-----------------------------------------------------------------------------
  I.Configure config files.
    **  We use ruby 1.9.
    In /etc/make.conf add:
    # vi /etc/make.conf

[ F I L E ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
RUBY_VERSION=1.9.3
RUBY_DEFAULT_VER=1.9
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

-----------------------------------------------------------------------------
Installation.
-----------------------------------------------------------------------------
  I.Installation Ruby 1.9.3.
    A.  From ports collections.
        # /usr/ports/devel/ruby-gems
        # make && make install clean
  
=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*2.1.1.1. Install Rails Framework.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                                  FAQ RoR
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Install Rails Framework.
=============================================================================
-----------------------------------------------------------------------------
Installing.
-----------------------------------------------------------------------------
  I.Installation rails framework.
    **  Use the gem utility.
    # gem install rails

    **  Verify the installation:
        # rehash
        # rails -v
          Rails 3.2.11

    **  Gem short help:
        # gem list - Show list installed gem-packages.
        # gem update - Updtae all gem-packages.
        # gem update --system - Update gem-system.
        # gem update <GEM_PKG_NAME> - Update gem-package, for exmaple:
            > gem update rails - Update rails framework.
        # gem uninstall <GEM_PKG_NAME> - Uninstall gem-package.
        # gem enviroment - Show config RubyGems.

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*2.1.1.2. Create first RoR app.*

To view the complete contents of the HOWTO/FAQ: Back to content.

P.S. Sorry for my bad English.
P.P.S. If you find something of interest, tell me: "thank you man" - I will be pleased. If you think that this is useless, do not scold me - I will be unpleasant. If you know a better solution - I'll be glad to see your adjustments.


```
=============================================================================
                                   FAQ RoR
=============================================================================
CREATED:
    Author: valsorym
    E-mail: valsorym.e@gmail.com
    
DATE:
    2013.03.23

DESCRIPTION:
    Create First RoR App.
=============================================================================
-----------------------------------------------------------------------------
Create first RoR app.
-----------------------------------------------------------------------------
  I.Create work directory.
    **  For example, our work directory - /heap/RoR/.
    # mkdir -p /heap/RoR

 II.Create RoR app.
    **  To create a project, you should have enough rights.
    **  Our first project  have a name - hello-ror.
    # cd /heap/RoR/
    # rails new hello-ror

III.Run RoR Server.
    # cd /heap/RoR/hello-ror
    # rails server

    **  If the server does not start and displays an error like:
[ E R R O R ] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/usr/local/lib/ruby/gems/1.9/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in
`autodetect': Could not find a JavaScript runtime. See https://github.com/sst
ephenson/execjs for a list of available runtimes.
(ExecJS::RuntimeUnavailable)
    from /usr/local/lib/ruby/gems/1.9/gems/execjs-1.4.0/lib/execjs.rb:5:in `<m
odule:ExecJS>'
    from /usr/local/lib/ruby/gems/1.9/gems/execjs-1.4.0/lib/execjs.rb:4:in `<t
op (required)>'
    from /usr/local/lib/ruby/gems/1.9/gems/coffee-script-2.2.0/lib/coffee_scri
pt.rb:1:in `require'
    from /usr/local/lib/ruby/gems/1.9/gems/coffee-script-2.2.0/lib/coffee_scri
pt.rb:1:in `<top (required)>'
   ... 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        
        A.  Add in Gemfile next line:
            # echo "gem 'therubyracer'" >> Gemfile
            # rails server

        B.  Panacea.
            **  In order for such an error does not happen again - you need to
                install Node.js.
            **  In most cases, devel/libehetsinfo already installed.
            # setenv BATCH yes
            # cd /usr/ports/devel/libexecinfo
            # make && make install clean

            # cd cd /usr/ports/www/node
            # make && make install clean

        **  Then start the server again: 
            # rails server

 IV.Open RoR App.
    **  If the server is successfully launched - open in your browser:
        http://localhost:3000/

=============================================================================
                                                             Author: valsorym
```


----------



## valsorym (Mar 26, 2013)

*The End!*

I finished
We can start the discussion. :beergrin


----------



## cpm@ (Mar 26, 2013)

@valsorym

First, you did a great work! :beergrin

Second, you should correct the link to 4.3.12. X11 Xfce4 because is linked to 4.3.11. X11 Xcompmgr. Anyway, I'll take a more exhaustive read.

Third, you can add to Section 4.3.9. X11 Dwm an standardized example of .xinitrc (modifies mine if you want).







```
# Set keyboard layout to English
setxkbmap -layout en

# Loop
while true
do
        xsetroot -name "vol/pcm: $( (/usr/sbin/mixer -s vol 2> /dev/null || echo - ) | cut -d ':' -f 2)/$( (/usr/sbin/mixer -s pcm 2> /dev/null || echo - ) | cut -d ':' -f 2) | bat: $(/usr/sbin/acpiconf -i0 | grep "Remaining capacity" | awk '{print $3}') temp: $(sysctl -n dev.cpu.0.temperature)/$(sysctl -n dev.cpu.1.temperature) | $(/bin/date "+%e %a %H:%M")"
        # Update every 1s
        sleep 1
done &

# Set wallpaper
feh --bg-scale ~/wallpaper/named-wallpaper.png

# Run dwm
exec dwm
```

As clarification, in the above example to set wallpaper should install graphics/feh


----------



## valsorym (Mar 26, 2013)

cpu82 said:
			
		

> @valsorym
> 
> First, you did a great work! :beergrin
> 
> Second, you should correct the link to 4.3.12. X11 Xfce4 because is linked to 4.3.11. X11 Xcompmgr. Anyway, I'll take a more exhaustive read.



Thanks,
And, I corrected this misunderstanding.




			
				cpu82 said:
			
		

> @valsorym
> 
> Third, you can add to Section 4.3.9. X11 Dwm an standardized example of .xinitrc (modifies mine if you want).
> 
> ...



Hi again,
I have not forgotten about xinitrc. This fasting is very big and it is divided into two parts.
At the top of the post is a link to the second part: 


> *4.3.9. X11 Dwm (Ptr 1).*
> To view the complete contents of the HOWTO/FAQ: Back to content.
> Go to 4.3.9. X11 Dwm (Ptr 2).



As for graphics/feh - I think it is not appropriate for x11-wm/dwm - this is a tile window manager and desktop is virtually no time to be seen (it's closed window), but it is well suited for x11-wm/openbox. :stud


----------



## cpm@ (Mar 27, 2013)

Sorry for the noise. Anyway, can help to complete yours :e

PS. So you can add various suggested applications for the Dynamic Window Manager (DWM). I use it on my ASUS Eee PC 1018P and works great.


----------

