Why ubuntu installation is so slow

Symptoms

While installing ubuntu ,it’s very slow ,usally it took long like 3-4 even 5+ hours to finish the installation.The progress was showing “Retrieving file” with several hours remaining

Cause

The reason is the installation was updating ubuntu to the latest for you , and because you are located where the network latency is high while connecting to the main ubuntu repository. Or normally after you finished the installation you usally changed sources.list to use local ubuntu repository mirror which is faster

Resolution/Workaround

The workaround is to disconnect your laptop or desktop pc or vmware from network , then install ubuntu ,after the installation is been done, change your repository to one mirror which is faster

If you are installing ubuntu via vmware player , you can disconnect the network before installation refering below screenshot , untick the Connect at power on option

Conclusion

If you are suffering slow ubuntu installation , you can try to disconnect the network of the installing ubuntu , then the installation will not update ubuntu during the installation for you and you can do it post-installation.

Set up teamviewer without installation in Ubuntu 20.04

In Ubuntu we can install teamviewer by downloading the deb package then use apt install to install it , also we can download the teamviewer tar file then extract it to run it directly.

1.Download teamviewer tar file using Firefox or command wget

wget https://download.teamviewer.com/download/linux/teamviewer_amd64.tar.xz

2. Extract it using command tar or your gui file browser

tar xf teamviewer_amd64.tar.xz

3. Run teamviewer from command line or double clicking “teamviewer” in file browser

4. Probably you need to check if requried libaries been installed or not

./tv-setup checklibs

Install and setup nfs server for Ubuntu 20.04

This small guide will show you how to install and configure nfs server in Ubuntu 20.04.Since nfs v4 depends on KDC ,we use nfs v3 here.

1.Install nfs server package

sudo apt update
sudo apt install nfs-kernel-server

2.Create a directory which we will export

sudo mkdir -p /share/dir01

3.Edit /etc/exports ,add below line

 /share/dir01       *(rw,sync,no_subtree_check)

4.Restart nfs server or run command “exportfs -ra”

sudo systemctl restart nfs-server

OR

sudo exportfs -ra

run command exportfs to verify

j@ubuntu:~$ sudo exportfs
/share/dir01  	<world>
j@ubuntu:~$

5.Test nfs server from client

sudo mkdir /mountp1
sudo mount nfs-servernameorip:/share/dir01 /mountp1

For more inforation regarding /etc/exports , just “man exports”

3 ways to list installed packages in ubuntu 20.04

Method 1 : list installed packages using command apt

apt list --installed
root@ubuntu:/home/j# apt list --installed | wc -l
 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
 1615
 root@ubuntu:/home/j#

We can see this host has 1615 packages installed

   list        list is somewhat similar to dpkg-query --list in that it can display a list of packages        satisfying certain criteria. It supports glob(7) patterns for matching package names as well as        options to list installed (--installed), upgradeable (--upgradeable) or all available        (--all-versions) versions.

Method 2: list installed packages using dpkg command

dpkg --get-selections

OR

dpkg -l

OR

dpkg-query  --list

Note: For dpkg-query –list and dpkg -l there are 5 lines additional information.

Method 3: list manually installed packages using command apt-mark

root@ubuntu:/home/j# apt-mark 
apt 2.0.2ubuntu0.2 (amd64)
Usage: apt-mark [options] {auto|manual} pkg1 [pkg2 ...]

apt-mark is a simple command line interface for marking packages
as manually or automatically installed. It can also be used to
manipulate the dpkg(1) selection states of packages, and to list
all packages with or without a certain marking.

Most used commands:
  auto - Mark the given packages as automatically installed
  manual - Mark the given packages as manually installed
  minimize-manual - Mark all dependencies of meta packages as automatically installed.
  hold - Mark a package as held back
  unhold - Unset a package set as held back
  showauto - Print the list of automatically installed packages
  showmanual - Print the list of manually installed packages
  showhold - Print the list of packages on hold
root@ubuntu:/home/j# apt-mark showmanual | wc -l
56
root@ubuntu:/home/j# apt-mark showauto | wc -l
1558

Share files between win 10 and ubuntu 20.04

This guide will show you how to share files using samba in ubuntu, in Windows 10 you can map the ubuntu share as a map drive

1.In ubuntu , open your file browser(Nautilus),right-click the folder you wanto share then select Local Network Share

2.If you don’t have samba installed , click Install service and follow the instruction to get samba installed

3.Create Share , here we enable guest access

4.In case you don’t have dns setup , you can use command “ip addr” to get your ip address of you ubuntu

5.In Windows 10 , open Run by pressing WIN+r , then type in \\ip_addr_ofubuntu , then press Enter, you should be able to access the ubuntu shared folder now

6.(Optional) Also you can map the share as a drive

Fix wordpress SyntaxHighlighter ampersand to “&” issue

The workaround is to add below code into syntaxhighlighter.php

/**
 * Filter to fix issue with & in SyntaxHighlighter Evolved plugin.
 *
 * @param string $code Code to format.
 * @param array $atts Attributes.
 * @param string $tag Tag.
 *
 * @return string
 */
function kagg_syntaxhighlighter_precode( $code, $atts, $tag ) {
    if ( 'code' === $tag ) {
        $code = wp_specialchars_decode( $code );
    }
    return $code;
}
add_filter( 'syntaxhighlighter_precode', 'kagg_syntaxhighlighter_precode', 10, 3 );

1.Go to your wp-admin page

2.On left pane click “Plugins” then “Plugin Editor”

3.select plugin edit to “SyntaxHighlighter Evolved” then click “Select”

4.Add above code to the end of syntaxhighlighter.php

Disable lock screen for ubuntu 20.04

I’m using ubuntu 20.04 virtual machine for test purpose, the default idle time is 300 seconds and lock screen is enabled , it’s a little bit annoy to unlock the screen frequently . We can use command gsettings to disable lock screen or we can change the idle time longer

Disable Lock screen for Gnome

j@ubuntu:~$ gsettings get org.gnome.desktop.lockdown disable-lock-screen
false
j@ubuntu:~$ gsettings set org.gnome.desktop.lockdown disable-lock-screen true

we can see by default “disable-lock-screen” is “false” , so we can just change it to true to disable lock screen

Change gnome session idle delay time

j@ubuntu:~$ gsettings get org.gnome.desktop.session idle-delay
uint32 300
j@ubuntu:~$ gsettings set org.gnome.desktop.session idle-delay 3600
j@ubuntu:~$

Above command changed gnome session idle delay time from 5 minutes to 1 hour.

Install php moduel imagick in ubuntu

I just did a health check for my wordpress site , I was told to enable optional php module imagick , below is the steps

1.Install php 7 imagick module using below command

sudo apt-get update;sudo apt-get install php-imagick

2.Enable the installed module using phpenmod command

sudo  phpenmod imagick

3.Reload your http service to get it took affect to your wordpress site,I’m using apache2

sudo systemctl reload apache2.service

4.(optional) Redo healthcheck for your wordpress site , this time should be no such performance recommendation anymore

twenty tweny one theme change width of content

I’m using the latest them twenty twenty for one of my blog , I realy like this theme, but one thing is the content width is a little small.Below is the steps how I enlarge the width of content . I ‘m not an expert of css ,if you have better ways to do this please comment.

1.Open your wordpress admin page , then go to Appearance —Theme Editor –click style.css , copy below lines

@media only screen and (min-width: 822px) {

	:root {
		--responsive--aligndefault-width: min(calc(100vw - 8 * var(--global--spacing-horizontal)), 610px);
		--responsive--alignwide-width: min(calc(100vw - 8 * var(--global--spacing-horizontal)), 1240px);
	}
}

2.Go to Appearance –Customize — additional css ,and paste the copied lines there.

3.Now you can change to value of –responsive–aligndefault-width to enlarge the width of content .Below is the screenshot of changing from 610px to 1240px.

Can not connect to Tiger vnc server

So many versions of vnc , I was supposed to install tightvncserver ,but somehow I installed tigervnc , and I can’t connect to vnc server from windows ,I got error “Timed out waiting for a response from the computer” like below

After some time’s checking , I found for tiger vnc , if we need to connect to vnc server from remote machine we need to add opiont “-localhost no” like:

vncserver -localhost no

As you can see from the usage of command vncserver

[-localhost yes|no]    Only accept VNC connections from localhost

As you can see from below example , without option “-localhost no” , vncserver will be listening on 127.0.0.1:590X but not 0.0.0.0:590X

So if you want to connet to your tiger vnc servver from remote host ,please remember to add option “-localhost no”