Wednesday, 24 August 2016

Simple-ish Arch setup for VirtualBox

This is a work in progress. There's probably a simple command for making Arch remember that I only ever want to use a UK keyboard, but I've been tinkering with this for too long now.

If you want to use SSH to access the guest from the host, add a Host-Only Ethernet Adapter in your VirtualBox settings.

loadkeys uk
parted /dev/sda
# When in parted
mklabel  msdos
mkpart  primary  ext4  0%  100%
set 1 boot on
quit
# Then
mkfs.ext4 /dev/sda1
mount  /dev/sda1  /mnt
# Edit /etc/pacman.d/mirrorlist to select mirror.
pacstrap /mnt base
genfstab -p /mnt >> /mnt/etc/fstab
arch-chroot /mnt
passwd
ln -s /usr/share/zoneinfo/Europe/Dublin/ /etc/localtime

printf “arch1\n” > /etc/hostname

pacman -S grub

grub-install --target=i386-pc /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

exit
reboot
# Then enable networking
systemctl enable dhcpcd.service
systemctl start dhcpcd.service

# Install stuff

pacman -S --noconfirm linux-headers xorg xorg-server mate mate-extra lxdm pkgfile base-devel virtualbox-guest-iso wget openssh

# Enable display manager and ssh daemon
systemctl enable lxdm.service
systemctl enable sshd.socket
reboot

# I know there must be a way of reducing the number of reboots
mkdir -p /media/iso
mount -o loop /usr/lib/virtualbox/additions/VBoxGuestAdditions.iso /media/iso
/media/iso/autorun.sh 
# Now add a user and log in as them...
useradd -m -G wheel -s /bin/bash mikey
passwd mikey

# ... so we can install yaourt (not allowed do this as su) ...
mkdir yaourt
cd yaourt
wget https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=package-query
mv PKGBUILD?h=package-query PKGBUILD
makepkg -s
sudo pacman -U package-query-1.8-2-x86_64.pkg.tar.xz 
ls
rm -rf *
ls
wget https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=yaourt
mv PKGBUILD\?h\=yaourt PKGBUILD
ls
makepkg
sudo pacman -U yaourt-1.8.1-1-any.pkg.tar.xz 
cd ..
rm -rf yaourt/
# ... so we can install Google Chrome
echo 1|yaourt --noconfirm google-chrome

Tuesday, 23 August 2016

Install Chrome on CentOS 7

Put this in a .sh file and run it

cat <<EOF >/etc/yum.repos.d/google-chrome.repo
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl.google.com/linux/linux_signing_key.pub
EOF
yum install -y google-chrome-stable

Install MATE on CentOS 7

These commands will install MATE and make it launch on boot.

yum -y install epel-release
yum -y groupinstall "X Window system"
yum -y groupinstall "MATE Desktop"
systemctl set-default graphical.target

This command will start it up now

systemctl isolate graphical.target

Simple CentOS 7 VM configuration

This setup allows you to ssh into your VM easily (without port forwarding)

  1. Create a new VirtualBox VM with name vm-name of type Linux, Version Linux 2.6 / 3.xd /4.x (64-bit)
  2. Start the VM, select the install iso, follow dialog boxes to complete installation then shutdown the vm
  3. run these commands on the host
    VBoxManage modifyvm "vm-name" --nictype1 82543GC
    VBoxManage modifyvm "vm-name" --nic2 hostonly
    VBoxManage modifyvm "vm-name" --nictype2 82543GC
    VBoxManage modifyvm "vm-name" --hostonlyadapter2 "VirtualBox Host-Only Ethernet Adapter"
    
  4. run these command on the guest
    sed -ie "s/ONBOOT=no/ONBOOT=yes/" /etc/sysconfig/network-scripts/ifcfg-enp0s3
    sed -ie "s/ONBOOT=no/ONBOOT=yes/" /etc/sysconfig/network-scripts/ifcfg-enp0s8
    systemctl stop NetworkManager.service
    systemctl start NetworkManager.service
    

Monday, 22 August 2016

Install Latest Stable git from source on CentOS

Put these commands in a shell script and run it.
yum install -y wget curl-devel expat-devel gettext-devel \
      openssl-devel zlib-devel gcc perl-ExtUtils perl-devel
cd /usr/local/src
wget https://www.kernel.org/pub/software/scm/git/git-2.9.3.tar.gz
tar xzf git-2.9.3.tar.gz
cd git-2.9.3
./configure
make
make install

Install Latest Stable Emacs from source on CentOS

Put these commands in a shell script and run it.

yum install -y gtk3-devel libXpm-devel gcc giflib-devel libX11-devel libXft-devel \
       libjpeg-turbo-devel libtiff-devel make ncurses-devel -y
cd /usr/local/src
wget http://ftp.gnu.org/pub/gnu/emacs/emacs-24.5.tar.gz
tar xzvf emacs-24.5.tar.gz
cd emacs-24.5
./configure
make && make install

Wednesday, 10 August 2016

How to create a service on Linux

It took me a while to figure this out so I post it here in case I need to refer to it in the future.
These instructions apply to linux distros which have systemd. To find out if this applies to your distro run this command:
ps -q 1 -o comm=
If the output is systemd then your distro is one with systemd, so you can continue with these instructions.
  1. Create a shell file called test-service or whatever in /etc/init.d/. The shell file has to follow a pattern. Have a look at /etc/init.d/mountall-bootclean.sh for a concise example which conforms to this pattern.
  2. Enter this command to have your service start every time the host starts.
    sudo systemctl enable test-service
    
  3. Enter this command to have your service start now.
    sudo systemctl start test-service