Skip to content

Instantly share code, notes, and snippets.

@huan
Last active December 26, 2020 05:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huan/8514691b83a878c0cd2fc2d60cb55dde to your computer and use it in GitHub Desktop.
Save huan/8514691b83a878c0cd2fc2d60cb55dde to your computer and use it in GitHub Desktop.
linux setup toolbox

Setup Script for Ubuntu 18.10

Install

Harddisk

  1. mount exfat options: uid=zixia,gid=zixia
  2. list UUID: sudo blkid

Pinyin

Reboot after install (required to refresh ime)

Fonts

Install Fira Code iScript Font

git clone git@github.com:kencrocken/FiraCodeiScript.git
mkdir /usr/share/fonts/truetype/fira-code-iscript
cp FiraCodeiScript/*.ttf /usr/share/fonts/truetype/fira-code-iscript
fc-list | grep FiraCodeiScript

Desktop

  1. apt install gnome-tweak-tool
  2. Enable Static Workspace (disable Dynamic Workspace)
  3. Install Workspace Matrix (work for Ubuntu 19.04)
    See: Can I have 2x2 workspaces in GNOME 3?

Shadowsocks

Desktop Client

https://github.com/shadowsocks/shadowsocks-qt5/wiki/Installation

sudo add-apt-repository ppa:hzwhuang/ss-qt5
sudo apt-get update
sudo apt-get install shadowsocks-qt5

VirtualBox

sudo apt install virtualbox
sudo apt install virtualbox-ext-pack

# USB Devices
sudo adduser $USER vboxusers

# restart

WinXP

lftp pget -n 10 https://az412801.vo.msecnd.net/vhd/VMBuild_20141027/VirtualBox/IE6/Windows/IE6.XP.For.Windows.VirtualBox.zip
lftp pget -n 10 https://az412801.vo.msecnd.net/vhd/VMBuild_20141027/VirtualBox/IE11/Windows/IE11.Win7.For.Windows.VirtualBox.zip

Win7

BBR @ DigitalOcean

#!/usr/bin/env bash
set -e

# work with debian 8 and ubuntu 16
wget -P /tmp http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.9/linux-image-4.9.0-040900-generic_4.9.0-040900.201612111631_amd64.deb
dpkg -i /tmp/linux-image-4.9.0*.deb
rm -f /tmp/linux-image-4.9.0*.deb
update-grub

echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p

# http://askubuntu.com/a/811882/375372
# rm -fr /var/lib/docker/aufs/

# reboot

Docker @ Ubuntu 19.04

CUDA 10 @ Ubuntu 18.04

Install CUDA 10 on Ubuntu 18.04

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.0.130-1_amd64.deb \
    && sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub \
    && sudo apt-get update \
    && sudo dpkg -i cuda-repo-ubuntu1804_10.0.130-1_amd64.deb \
    && sudo apt-get update \
    && sudo apt-get install -y cuda

Android SDK

#!/usr/bin/env bash
set -e

apt-get install android-sdk
export ANDROID_HOME=/usr/lib/android-sdk/
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
apt-get install default-jdk

cd /usr/lib/android-sdk/
unzip ~/Downloads/tools_r25.2.3-linux.zip

/usr/lib/android-sdk/tools/android sdk
# $ANDROID_HOME/tools/bin/sdkmanager "build-tools;24.0.3"
# http://stackoverflow.com/a/41078173/1123955
android update sdk --no-ui --all --filter platform-tools,android-25,extra-android-m2repository

https://bugs.launchpad.net/ubuntu/+source/libnative-platform-java/+bug/1683761

Tune

# avoid ENOSPC
# http://stackoverflow.com/a/32600959/1123955
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

# Disable IPv6
echo net.ipv6.conf.all.disable_ipv6=1 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Lightworks

Others

  • Transmission BitTorrent Client
  • Double Commander: sudo apt-get install doublecmd-gtk
  • apt install indicator-multiload

OpenCV

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_GTK=ON -D WITH_QT=OFF -D WITH_OPENGL=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.2.0/modules -D ENABLE_PRECOMPILED_HEADERS=OFF -D WITH_CUBLAS=ON  ..

Wine

Wechat http://www.cnblogs.com/makefile/p/wine-life.html

$ LANG=zh_CN.UTF-8 wine WeChat.exe 

Printer/Scaner

https://askubuntu.com/a/323692/375372

  1. Install Xsane
  2. Add following entry in /etc/sane.d/xerox_mfp.conf the scanner was found:
# Samsung CLX-3186W
tcp 10.0.0.11

HP Printer/Scaner

  1. Install driver from https://sourceforge.net/projects/hplip/files/hplip/
  2. Then follow https://bugs.launchpad.net/hplip/+bug/1813768/comments/8 to fix the plugin problem.

And refer to https://askubuntu.com/a/1236966/375372

sudo apt install hplip-gui

Restore eth0

netplan generate
sudo reboot

https://askubuntu.com/a/801310/375372

OR

ETH0=$(ip ro li | grep default | awk '{print $5}') && echo $ETH0 https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/

Docker Registry

To get an initial config.yml:

docker run -it --rm --entrypoint cat registry:2 /etc/docker/registry/config.yml > `pwd`/config.yml

Add following to config.yml:

proxy:
      remoteurl: https://registry-1.docker.io

Then start docker registry with config.yml:

docker run -d --restart=always -p 5000:5000 --name docker-registry-proxy -v `pwd`/config.yml:/etc/docker/registry/config.yml registry:2

run docker daemon with --registry-mirror=http://<proxy_ip>:5000

curl https://<proxy_ip>:5000/v2/_catalog

Credit: https://stackoverflow.com/a/39717783/1123955

Docker Registry Mirror

/etc/docker/daemon.json

{
  "registry-mirrors": [
          "https://registry.docker-cn.com"
        , "http://hub-mirror.c.163.com"
        , "https://docker.mirrors.ustc.edu.cn"
  ]
}

Timezone

sudo ln -sf /usr/share/zoneinfo/Etc/GMT+8 /etc/localtime

Tunnel - IPIP

TUNNEL_NAME=bupt
TUNNEL_MODE=ipip
TUNNEL_LOCAL=128.199.33.239
TUNNEL_LOCAL_PRI=10.199.33.239
TUNNEL_REMOTE=111.207.243.66
TUNNEL_REMOTE_PRI=10.207.243.66
ip tu ad name "$TUNNEL_NAME" mode "$TUNNEL_MODE" local "$TUNNEL_LOCAL" remote "$TUNNEL_REMOTE"
ifconfig "$TUNNEL_NAME" "$TUNNEL_LOCAL_PRI" pointopoint "$TUNNEL_REMOTE_PRI" up
iptables -t nat -A POSTROUTING -s 10.0.0.0/8 -j MASQUERADE

# enable bbr
# echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
# echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -w net.core.default_qdisc=fq
sysctl -w net.ipv4.tcp_congestion_control=bbr

###############

TUNNEL_NAME=ams
TUNNEL_MODE=ipip
TUNNEL_LOCAL=111.207.243.66
TUNNEL_LOCAL_PRI=10.207.243.66
TUNNEL_REMOTE=128.199.33.239
TUNNEL_REMOTE_PRI=10.199.33.239

ip tu ad "$TUNNEL_NAME" mode "$TUNNEL_MODE" remote "$TUNNEL_REMOTE" local "$TUNNEL_LOCAL"
ifconfig "$TUNNEL_NAME" "$TUNNEL_LOCAL_PRI" pointopoint "$TUNNEL_REMOTE_PRI" up
iptables -t nat -A POSTROUTING -o "$TUNNEL_NAME" -j MASQUERADE

iptables -t nat -I PREROUTING -p tcp --dport 10001:20000 -j DNAT --to-destination "$TUNNEL_REMOTE_PRI"

Socat

socat TCP-LISTEN:18388,fork,reuseaddr "TCP:${HOLE_IP}:18388" &

Google Drive

Downloader (https://www.matthuisman.nz/2019/01/download-google-drive-files-wget-curl.html)

sudo wget -O /usr/local/bin/gdrivedl 'https://f.mjh.nz/gdrivedl'
sudo chmod +x /usr/local/bin/gdrivedl

OpenVPN

1 Server

openvpn \
    --port 1234 \
    --proto udp \
    \
    --dev openvpn \
    --dev-type tun \
    \
    --keepalive 10 60 \
    --ifconfig 192.168.0.1 192.168.0.2 \
    &

2 Client

openvpn \
    --remote ${IP} 1234 udp \
    \
    --dev openvpn \
    --dev-type tun \
    \
    --ifconfig 192.168.0.2 192.168.0.1 \
    &

Realtek RTL8811CU/RTL8821CU USB Wi-Fi adapter driver for Linux

git clone https://github.com/brektrou/rtl8821CU
cd rtl8821CU
sudo ./dkms-install.sh
sudo modprobe 8821cu

MySQL

create database DATABASE;
create user USER identified by 'PASS';
grant all privileges on DATABASE.* to 'USER'@'%';

alter user USER identified by 'PASS';

flush privileges;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment