Thursday, August 1, 2019

Reinstall ubuntu 19.04 dual boot on T470p - Setting (2)

1. Right click on the desktop, in the menu select "Display Settings"
   "Display Settings" --> "Resolution" --> "2048 x 1152 (16:9)"
                                  --> "Refresh Rate" --> "119.96Hz"
                                  --> "Scale" --> "100%"

2. Open "Terminal" --> "Preferences" --> "Unnamed" -->
               "Initial terminal size" --> "152 x 36"
               "Custom font" --> "12"

3.  Open "Settings"
(1) "Dock" --> scale dock to a proper size
(2) "Privacy" --> configure privacy setting
(3) "Power" -->
                   "Blank screen" --> select "Never"
                   "Automatic suspend" --> "off"
                   "When the Power Button is pressed" --> "Suspend"
(4) "Details" --> "About" --> modify "Device name" to make it short in terminal
                     --> "Date & Time" --> set proper date & time format
                     --> "User" --> select an image for login
                     --> "Default Application" --> select proper default application

4. Install "tweaks"
`sudo add-apt-repository universe`
`sudo apt install gnome-tweak-tool`
Open "tweaks":
(1) "General" --> turn off "Suspend when laptop lid is closed"
(2) "Top Bar" --> Select proper 'clock' and 'calendar' format
(3) "Windows" --> turn on "Center New Windows"

5. Install "VLC media player" from "Ubuntu Software"
(1) click 'loop one sign'
(2) "Tools" --> "Preferences" --> "Interface" -->
           "Show media change popup" --> select "Never"
           "Continue playback?" --> select "Never"
           "Save recently played items" --> "off"
           "Allow metedata network access"  --> "off"
     Open ubuntu system "Settings" -->
           "Notifications" --> "VLC media player" --> "off"
       
6.  Playing videos in firefox
If those streaming services use DRM, you must enable DRM in Firefox's settings: "Preferences -> General -> Play DRM-controlled content"
You might also have to install package libavcodec-extra to get the codecs:
`sudo apt install libavcodec-extra`

@reference_1_askubuntu.com

Reinstall ubuntu 19.04 dual boot on T470p - Setting (1)

1.  Fix Windows and Linux Showing Different Times When Dual Booting
 To make linux use Local Time (not UTC time):
 `timedatectl set-local-rtc 1 --adjust-system-clock`

 To check your current settings, run:
`timedatectl`



 To undo this change:
 `timedatectl set-local-rtc 0 --adjust-system-clock`
 
@reference_1_ howtogeek.com


2. Add a (command) directory to the '$PATH' in Ubuntu
Edit `.bashrc` in your home directory and add the following line: 
`export PATH="/path/to/dir:$PATH"`

You will need to source your '.bashrc' or logout/login (or restart the terminal) for the changes to take effect. To source your '.bashrc', simply type 
`source ~/.bashrc`

@reference_2_askubuntu.com

3.  Install "proxychains"
 `apt-get install proxychains`
Edit:   `/etc/proxychains.conf`               (`chmod...` etc.)
Add:  `socks5 127.0.0.1 1080`

Note that: there is a DNS issue in "tsocks"

Use the following script to switch ports:
`re='^[0-9]{4}$'
if [ "$#" -eq  "0" ]
  then
    echo "Error: No arguments supplied"
else
    if ! [[ $1 =~ $re ]] ; then
       echo "Error: argument '$1' is illegal!"
    else sudo sed -i -r 's/(127.0.0.1 )([0-9]{4})/\1'"$1"'/g' /etc/proxychains.conf
    fi
fi
`

@reference_3_yuzhangbit.github.io

4.  Add “New Document” back to the right-click menu
`touch ~/Templates/"Untitled Document"`

@reference_1_vitux.com

5. How to auto-mount windows 10 ntfs partition in dual-boot ubuntu system ?
    "Activities" --> search "Disks" --> select the partition to auto-mount -->
                click [gears icon] (Additional partition options) --> 
                click "Edit Mount Options..." --> 
                turn off "User Session Defaults" -->
                set "Mount Point" to `/media/xxxxx/D Volume` (or other pathes) -->
                click "OK" --> reboot system to check



Reinstall ubuntu 19.04 dual boot on T470p - system installation

1. Using "Rufus" to create a bootable USB flash drive (keep default configuration). Disable Secure Boot and Fast Boot options from UEFI settings (if supported).

2. Delete ubuntu partitions in winfdows 10 or delete it during the installation process. (or shrink windows 10 disk to create "free partition" for ubuntu installation if ubuntu dual boot hasn't been installed before)

3. Select "Something else"

4. create "root partition", "home partition" and "swap partition"
 root partition

 home partition

swap partition
 (Note that the size of swap partition being too small may slow down 'vmware' unless you select "Fit all virtual machine memory into reserved host RAM")

 5. From the Device for boot loader installation select the Windows Boot Manager.


@reference_1_linuxbsdos.com



Wednesday, July 31, 2019

Reinstall ubuntu 19.04 dual boot - install vmware workstation 15 pro

1. Uninstall Workstation Pro from a Linux Host
`su` root
`vmware-installer -u vmware-workstation`

(To inistall, 'sh' the bundle file)

@reference_1_docs.vmware.com

2. Prompt "No 3d support is available from the host" and "hardware graphics acceleration is not available" when booting up the virtual machine.

edit `.vmware/preferences`
`mks.gl.allowBlacklistedDrivers = "TRUE"`

@reference_2_askubuntu.com

3. “Install VMware Tools” greyed out

shutdown the machine and change both the "floppy drive" and "cd drive" to "Auto detect" and then power on the machine.

@reference_3_askubuntu.com

4.  Install VMware Tools 10.3.10 in windows10 vm on ubuntu host machine
(1) Download the 10.3.10 tools from VMware. https://my.vmware.com/web/vmware/details?downloadGroup=VMTOOLS10310&productId=491
(could be downloaded without proxy)
      Get the zip file with Windows and Linux tools.
(2) Unpack the zip file, and execute `chmod 777 -R VMware-Tools-core-10.3.10-12406962` .
(3) Set "floppy drive" to "pvscsi-Windows8.flp" and "cd drive" to "windows.iso" respectively.
(4) Restart the virtual machine, then click into the "cd drive" to install the "VMware Tools"

@reference_4_vm.knutsson.it
@reference_5_communities.vmware.com
@reference_6_my.vmware.com

5. Note that
There is NO "clean up disks" availability for Linux host VMware workstation.
In windows host there is an option to "reclaim disk space" but running with linux as host, that doesn't exist.

@reference_7_communities.vmware.com

6. System "Swap" memory problem
If the size of "Swap Partition" memory allocation is too low when you install the ubuntu dual boot system, your virtual window10 on the ubuntu host could be extremely slow.
To solve the problem:
(1) Run VMware under root (Terminal: `su` --> `vmware`)
(2) Click "Edit" --> "Preferences" --> "Memory" --> "Additional Memory"
      --> select "Fit all virtual machine memory into reserved host RAM"


Sunday, July 7, 2019

Build a 'trojan' server

Step 1: 
(a). install nginx
(b). install letsencrypt as previously posted

Step 2:
(a). obtaining a Let's Encrypt SSL certificate
(b). set  'live' and 'archive' folder in 'letsencrypt' to 755 recursively

@ref_github_1

Step 3:
change nginx configuration as follws:
`
server {
    listen 127.0.0.1:80 default_server;

    server_name example.com;

    location / {
        proxy_redirect off; 
        proxy_pass https://www.xxxx.net;
    }

}

server {
    listen 127.0.0.1:80;

    server_name 100.100.100.100; # server IP address

    return 301 https://example.com;
}

server {
    listen 0.0.0.0:80;
    listen [::]:80;

    server_name _;

    return 301 https://example.com;
}
`
@ref_blog.siaimes.me_2

Step 4:
Option 1: Install 'trojan' from github:
@ref_trojan-gfw.github.io_3
(a).
run
 `sudo apt -y install build-essential cmake libboost-system-dev libboost-program-options-dev libssl-dev default-libmysqlclient-dev`
to install all the necessary dependencies.

(b).
`git clone https://github.com/trojan-gfw/trojan.git`
` cd trojan/`

(c).
`mkdir build`
`cd build/`
`cmake ..`
`make`
`ctest`
`make install`

(d).
edit '/usr/local/etc/trojan/config.json'
set "password"
set "cert": "/etc/letsencrypt/live/example.com/fullchain.pem"
set "key": "/etc/letsencrypt/live/example.com/privkey.pem"
set "alpn": [ "http/2.0" ]

(e).
`systemctl restart trojan nginx`
`systemctl status trojan nginx`
`systemctl enable trojan nginx`

Option 2: Install 'trojan' from 'apt repository'
(a).
`
apt install software-properties-common
add-apt-repository ppa:greaterfire/trojan
apt update

apt install trojan
trojan version
vi /etc/trojan/config.json
`
@ref_blog.siaimes.me_4

Step 5:
Firewall:
'
apt install ufw
ufw allow ssh     # Or port number
ufw allow https
ufw allow http
ufw enable
ufw status
ufw status verbose
'
@ref_blog.siaimes.me_5


Sunday, December 16, 2018

Setup Let's Encrypt With Nginx on Ubuntu 16.04

Install Certbot

To obtain a Let's Encrypt SSL certificate, you have to install the Certbot client on your server.
Add the repository. Press the ENTER key when prompted to accept.
add-apt-repository ppa:certbot/certbot
Update the package list.
apt-get update
Proceed by installing Certbot and Certbot's Nginx package.
apt-get -y install python-certbot-nginx

Configuring Nginx

Certbot automatically configures SSL for Nginx, but to do so it needs to find the server block in your Nginx configuration file. It does this by matching the server_name directive in the configuration file with the domain name for which you're requesting a certificate.
If you're using the default configuration file /etc/nginx/sites-available/default open it with a text editor such as nano and find the server_name directive. Replace the underscore, _, with your own domain name(s):
nano /etc/nginx/sites-available/default
After editing the configuration file, the server_name directive should look as follows. In this example, I assume that your domain is example.com and that you're requesting a certificate for example.com and www.example.com.
server_name example.com www.example.com;
Proceed by verifying the syntax of your edits.
nginx -t
If the syntax is correct, restart Nginx to use the new configuration. If you get any error messages, reopen the configuration file and check for any typos, then try again.
systemctl restart nginx

Obtaining a Let's Encrypt SSL certificate

The following command will obtain a certificate for you. Edit your Nginx configuration to use it, and reload Nginx.
certbot --nginx -d example.com -d www.example.com
You can also request an SSL certificate for additional domains. Just add the "-d" option as many times as you like.
certbot --nginx -d example.com -d www.example.com -d example.net -d example.net
In case you only want to obtain the certificate from Let's Encrypt without installing it automatically you can use the following command. This makes temporary changes to your Nginx configuration to obtain the certificate and reverts them once the certificate has been downloaded.
certbot --nginx certonly -d example.com -d www.example.com
 
@reference_1_vultr.com 

Saturday, October 20, 2018

chrome headless cli

`chrome --headless --user-data-dir=D:\TEMP\output\tmp --no-sandbox --enable-logging --dump-dom https://www.baidu.com/ > D:\TEMP\output\file.html`

`chrome --headless --user-data-dir=D:\TEMP\output\tmp --no-sandbox --print-to-pdf=D:\TEMP\output\whatever.pdf https://www.baidu.com/`

`chrome --headless --user-data-dir=D:\TEMP\output\tmp --no-sandbox --disable-gpu --screenshot=D:\TEMP\output\screenshot.png https://www.baidu.com/`