Friday, July 22, 2016

archlinux - fonts (chinese)

Fonts and font collections in the enabled repositories can be installed using pacman. Available fonts may be found by using:

# pacman -Ss font


The font or font collection wqy-zenhei solved the problem of displaying chinese characters on Chromium and Firefox browsers:

# pacman -S wqy-zenhei


List of ordinary fonts:

adobe-source-code-pro-fonts (Adobe)
adobe-source-sans-pro-fonts (Adobe)
adobe-source-serif-pro-fonts (Adobe)
ttf-dejavu
ttf-liberation
ttf-ubuntu-font-family


References:
https://wiki.archlinux.org/index.php/fonts

Wednesday, July 20, 2016

archlinux - graphical user interface

The below configuration has a great performance; it's been running on an old laptop Intel Centrino 1.7Ghz with 1Gb RAM and 100Gb HDD


Display server: Xorg

# pacman -S xorg-server xorg-server-utils xorg-apps


Display drivers: intel

# pacman -S xf86-video-intel


Desktop environments: Xfce

# pacman -S xfce4 xfce4-goodies xfce4-whiskermenu-plugin


xinitrc: The ~/.xinitrc file is a shell script read by xinit and by its front-end startx. It is mainly used to execute desktop environments, window managers and other programs when starting the X server (e.g., starting daemons and setting environment variables). The xinit program starts the X Window System server and works as first client program on systems that are not using a display manager.

- first create a copy of the default xinitrc in home directory:

# cp /etc/X11/xinit/xinitrc ~/.xinitrc

- Append desired commands and remove/comment the conflicting lines.

~/.xinitrc
...

if [ -d /etc/X11/xinit/xinitrc.d ] ; then
    for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
        [ -x "$f" ] && . "$f"
    done
    unset f
fi

# twm &
# xclock -geometry 50x50-1+1 &
# xterm -geometry 80x50+494+51 &
# xterm -geometry 80x20+494-0 &
# exec xterm -geometry 80x66+0+0 -name login

## some applications that should be run in the background
xscreensaver &
xsetroot -cursor_name left_ptr &

exec startxfce4

- when executing # startx the graphical user interface will be displayed, in this case Xfce


Desktop environments: GNOME

#  pacman -S gnome gnome-extra

- same as Xfce, first create a copy of the default xinitrc in home directory and append desired commands and remove/comment the conflicting lines.

exec gnome-session


Display manager: GDM

# pacman -S gdm
# systemctl enable gdm.service


Enable Network to be managed using GUI:

# pacman -S networkmanager network-manager-applet dhclient
# systemctl enable NetworkManager.service


References:
https://wiki.archlinux.org/index.php/General_recommendations#Graphical_user_interface
https://wiki.archlinux.org/index.php/Xorg#Installation
https://wiki.archlinux.org/index.php/GNOME
https://wiki.archlinux.org/index.php/GDM
https://wiki.archlinux.org/index.php/NetworkManager#Enable_NetworkManager

Sunday, July 10, 2016

archlinux - openssh server

Piece of cake!

Installation:
# pacman -S openssh

Configuration:
- The SSH daemon configuration file can be found and edited in /etc/ssh/sshd_config.

Enable the sshd service (start on every boot):
# systemctl enable sshd.service


References:
https://wiki.archlinux.org/index.php/Secure_Shell#Server_usage

archlinux - VMWare tools

Straightforward guide from arch wiki.

Summarized:
- Install the dependencies using pacman: base-devel (for building), net-tools (for ifconfig, used by the installer) and linux-headers (for kernel headers).
e.g. 
# pacman -S net-tools

- Create bogus init directories for the installer:
# for x in {0..6}; do mkdir -p /etc/init.d/rc${x}.d; done

- The installer can then be mounted:
# mount /dev/cdrom /mnt

- Extracted (e.g. to /tmp):
# tar xf /mnt/VMwareTools*.tar.gz -C /tmp

- And started:
# perl /tmp/vmware-tools-distrib/vmware-install.pl

- Reboot the Virtual Machine:
# systemctl reboot

- Log in and start the VMware Tools:
# /etc/init.d/rc6.d/K99vmware-tools start


Additionally, autostart of VMWare tools on every boot.

- Create the following text file:
# nano /etc/systemd/system/vmwaretools.service

Add the following text:
[Unit]
Description=VMWare Tools daemon

[Service]
ExecStart=/etc/init.d/vmware-tools start
ExecStop=/etc/init.d/vmware-tools stop
PIDFile=/var/lock/subsys/vmware
TimeoutSec=0
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

- To have it start at boot write the following in the terminal:
# systemctl enable vmwaretools.service


References:
https://wiki.archlinux.org/index.php/VMware/Installing_Arch_as_a_guest#Official_VMware_Tools
http://www.unax.dk/2014/01/running-vmware-tools-on-boot-in-arch-linux/

Friday, July 8, 2016

archlinux - installation

Just another learner's howto install the archlinux on top of VMWare VM.

1. Download from http://arch-mirror.wtako.net/iso/2016.07.01/archlinux-2016.07.01-dual.iso the latest version as of july/2016 (from HK mirror) or choose from the available hosts from https://www.archlinux.org/download/

Then boot from ISO to begin proper installation. It will automatically login with root user.

- check whether the internet connection is working:

# ping -c 3 google.com

The DHCP daemon is supposed to start automatically when running the live system from ISO. If it does not work, check network configuration page (reference below).


2. Preparing storage (partitioning and formatting)
- Identify the devices where the new system will be installed:

# lsblk

Usually, and I believe for most of cases, the device name is SDA.

- Partitioning: the plan is to make simple partition using GPT format:
/dev/sda1 - BIOS boot partition
/dev/sda1 - boot (512mb) with bootable flag
/dev/sda2 - swap (2gb)
/dev/sda3 - root (remainder)

To achieve this, I am going to use # parted as per below:

# parted /dev/sda

parted prompt:
# mklabel gpt
# mkpart ESP fat32 1MiB 513MiB
# set 1 boot on
# mkpart primary linux-swap 513MiB 2.5GiB
# mkpart primary ext3 2.5GiB 100%
# quit

- Formatting: execute # lsblk to see whether the partitions were created correctly.
# mkfs.fat -F32 /dev/sda1 #first partition - boot
# mkswap /dev/sda2        #second partition - swap
# swapon /dev/sda2        #activate swap
# mkfs.ext4 /dev/sda3     #third partition - root


3. Mounting the partitions:
# mount /dev/sda3 /mnt       #Mount the root partition
# mkdir -p /mnt/boot         
# mount /dev/sda1 /mnt/boot  #Mount the boot partition


4. Installing the base package:
# pacstrap -i /mnt base base-devel grub sudo vim net-tools linux-headers abs 


5. Configuring the system:
- Generate FSTAB
# genfstab -U /mnt >> /mnt/etc/fstab

- Chroot to new mount system root
# arch-chroot /mnt /bin/bash

- Setup Locale and Time:
edit /etc/locale.gen and uncomment the needed localisations e.g. en_US.UTF-8 UTF-8. Save the file, and generate the new locales:
# nano /etc/locale.gen
# locale-gen

create file /etc/locale.conf with the uncommented lines e.g. en_US.UTF-8
# echo LANG=en_US.UTF-8 >> /etc/locale.conf

select a time zone and create the symbolic link /etc/localtime, where Zone/Subzone is the TZ value from tzselect:
# tzselect
# ln -s /usr/share/zoneinfo/Asia/Hong_Kong /etc/localtime


6. Installing a boot loader: there are few choices for boot loaders; the one that is going to be installed is GRUB:
# grub-install /dev/sda
- since this system is being installed in a virtual machine, the above command will result in a error; as a result, the option --force must be added as below:
# grub-install --force /dev/sda
- at last:
# grub-mkconfig -o /boot/grub/grub.cfg


7. Re-generate the initramfs image:
# mkinitcpio -p linux


8. Adjust network configuration for the next boot:
# cp /etc/netctl/examples/ethernet-dhcp /etc/netctl/ethernet-dhcp
- edit the new profile /etc/netctl/ethernet-dhcp - line interface with the correct network adapter (may be obtained by command ip link);
- start the netctl:
# netctl start ethernet-dhcp
- make the netctl auto start at boot:
# netctl enable ethernet-dhcp


9. Set the root password:
# passwd


10. Set the hostname:
# echo any_hostname >> /etc/hostname

update 2016-09-11 - The hostname can be set after initial reboot by using the following command:
# hostnamectl set-hostname <any_hostname>


11. Add new users:
# useradd -m -g users -G wheel -s /bin/bash user_name
# passwd user_name


12. Allow new users to sudo:
# visudo
and uncomment the lines below:
## Uncomment to allow members of group wheel to execute any command
# %wheel ALL=(ALL) ALL


13. Exit from the chroot environment, umount the partitions and reboot the system:

# exit
# umount -R /mnt
# reboot


14. Syncronize and update the system:
# pacman -Syu


References:
https://wiki.archlinux.org/index.php/Beginners%27_guide
https://wiki.archlinux.org/index.php/Network_configuration
https://wiki.archlinux.org/index.php/Partitioning
https://wiki.archlinux.org/index.php/Category:Boot_loaders
https://wiki.archlinux.org/index.php/GRUB
https://www.youtube.com/watch?v=VwvHeFixpZY
http://www.gnu.org/software/grub/manual/html_node/BIOS-installation.html