Ubuntu install golang

As usual, before installing anything in Ubuntu, run

sudo apt update
sudo apt upgrade

Once done, you can start installing golang. The easiest method to install using the below command.

sudo apt install golang-go

Next is to test if you had successfully install golang. Create a hello.go file, paste the contents below into the hello.go file and save it.

package main

import "fmt"

func main() {
    fmt.Println("hello world")
}

To execute the file, run the command below.

go run hello.go

Ubuntu install sysstat

Ubuntu install sysstat

sudo apt install sysstat

Once installation completed, enable sysstat by setting the value to true.

sudo vim /etc/default/sysstat

ubuntu-install-sysstat-01

After that restart the sysstat service

sudo service sysstat restart

By default sysstat sample the CPU usage every 10 minutes at 5, 15, 25, 35, 45 and 55 minutes of the hour. To modify it,

sudo vim /etc/cron.d/sysstat

ubuntu-install-sysstat-02

Viewing the stats

To view latest stats

sar

To view yesterday’s stats

sar -f /var/log/sysstat/sa$(date +%d -d 'yesterday')

To view specific date stats

sar -f /var/log/sysstat/sa$(date +%d -d '2019-04-27')

 

Ubuntu install Plex media server

Ubuntu install Plex media server

Go to Plex website to get the download URL

ubuntu-install-plex-media-server

cd /tmp
wget https://downloads.plex.tv/plex-media-server/1.14.1.5488-cc260c476/plexmediaserver_1.14.1.5488-cc260c476_amd64.deb
sudo dpkg -i plexmediaserver_1.14.1.5488-cc260c476_amd64.deb
systemctl status plexmediaserver

ubuntu-install-plex-media-server

Go to http://127.0.0.1:32400/web and start configuring your Plex

Assuming that the videos are in your external hard disk connected to your Ubuntu desktop. You’ll need to run these commands to give user plex to access your drive.

MYGROUP="$USER"
sudo usermod -a -G $MYGROUP plex
sudo chown $USER:$MYGROUP /media/$USER
sudo chmod 750 /media/$USER
sudo setfacl -m g:$MYGROUP:rwx /media/$USER
sudo service plexmediaserver restart

to check your group or the group user plex is in

groups
groups plex

 

Ubuntu disable sleep on lid close

Ubuntu disable sleep on lid close

I prefer to install Ubuntu Desktop version instead of Ubuntu Server version because it takes care of all the drivers for my laptop. After the installation I’ll disable the GUI.

The screen will stay on at the login prompt and since it is a laptop, there isn’t a power off for the monitor only. Closing the lid will cause the laptop to sleep.

To prevent it from going to sleep. Do these.

ubuntu-disable-sleep-on-lid-close

Uncomment the 2 lines below and set it to ignore.

ubuntu-disable-sleep-on-lid-close

Lastly restart the service.

sudo service systemd-logind restart

 

Ubuntu 18.04 install MySQL Server

Ubuntu 18.04 install MySQL Server

Installation for MySQL is slightly different in 18.04 as compared to 16.04.

sudo apt update
sudo apt install mysql-server -y
sudo mysql -uroot

Now in MySQL console, type the following to check the users.

select user,host,plugin from mysql.user;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'NEWPASSWORD';
update mysql.user set host='%' where user='root';
exit;

Comment the line bind-address if you like to listen on all addresses.

sudo service mysql restart

 

Ubuntu install Selenium

Ubuntu install Selenium

Most sites can be crawled with simple wget in Bash but some are loaded at runtime using Javascripts. These sites cannot be crawled using simple wget in Bash. You’ll need something like Selenium.

To install Selenium, Firefox and xvfb. Run these commands.

sudo apt update
sudo apt install python-pip firefox xvfb -y
echo export DISPLAY=:99|sudo tee -a /etc/environment
pip install selenium

Download geckodriver. Extract it and move to /usr/bin/

wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz
tar -xzvf geckodriver-v0.24.0-linux64.tar.gz
sudo mv geckodriver /usr/bin/

Login as root, and set to run xvfb at reboot.

sudo su
crontab -e
@reboot Xvfb :99 -ac
reboot now

Create a simple python script to test if your installation is successful.

vim test.py
from selenium import webdriver
driver = webdriver.Firefox()
try:
  driver.get('https://www.bing.com')
  print driver.title
finally:
  driver.quit()
python test.py

Ubuntu install Nokogiri

Ubuntu install Nokogiri

First check if you have Ruby installed in your Ubuntu. Type the following command to check.

ruby -v

If you do not have Ruby installed. Read my Ruby on Rails setup post, and read the install rbenv and then later install Ruby.

If it is showing you your Ruby version then Ruby is already installed in your environment. Next to install Nokogiri, type the command below.

gem install nokogiri

Clean Ubuntu 18.04 quick install Nokogiri

Assuming you are installing Nokogiri using a brand new clean Ubuntu 18.04. To quickly install Nokogiri. Use these following commands.

sudo apt update
sudo apt upgrade -y
sudo apt install ruby ruby-dev libz-dev build-essential -y
sudo gem install nokogiri

 

Ubuntu install Deluge

Ubuntu install Deluge

The following commands installs Deluge

sudo apt update
sudo apt install deluged deluge-web -y

Add user

The following commands add user deluge or any other username of your choice. You can use user ubuntu or ec2-user to run deluge but it is best to create a new user to run deluge.

sudo su
adduser deluge

Type in the password for user deluge when prompted. You can leave the rest of the fields empty.

Running Deluge

I prefer to run a separate screen session and I named it deluge. Within the screen session I switch to user deluge created earlier. Then run deluge. To detach from the screen session, press Ctrl+A, Ctrl+D.

screen -S deluge
sudo su - deluge
deluged
deluge-web &

Login Deluge web UI

Assuming your Ubuntu IP is 10.0.0.123. Then go to http://10.0.0.123:8112 to login to Deluge web UI. The default password is “deluge“. You will be prompted to change the password once logged in.

ubuntu-install-deluge

 

Ubuntu change timezone

Ubuntu Desktop in Singapore

I had chosen Singapore timezone during the installation of Ubuntu 18.04 but it still turns out to be Indonesia timezone with Bahasa Indonesia as default language.

To avoid that, I’ve been installing Ubuntu Desktop 18.04 with the default New York timezone. That way I am sure that I’ll be getting English as default language and later just reconfigure my timezone.

Ubuntu change timezone

To change the timezone, use the command below.

sudo dpkg-reconfigure tzdata

ubuntu-change-timezone

ubuntu-change-timezone

ubuntu-change-timezone

ubuntu-change-timezone