Skip to content

Instantly share code, notes, and snippets.

@namndev
Last active June 22, 2023 12:29
Show Gist options
  • Save namndev/ca5d8afae80454d291b76ab0a204918a to your computer and use it in GitHub Desktop.
Save namndev/ca5d8afae80454d291b76ab0a204918a to your computer and use it in GitHub Desktop.
Things to do After Installing Ubuntu

Things to do After Installing Ubuntu

Some package for dev

sudo add-apt-repository ppa:bamboo-engine/ibus-bamboo
sudo apt update
sudo apt install vim git zsh build-essential heif-gdk-pixbuf ibus ibus-bamboo gdebi
im-config -n ibus

Install media codecs

$ sudo apt install ubuntu-restricted-extras

Install GNOME Tweak

$ sudo apt install gnome-tweaks

ZSH for terminal

$ sudo usermod -s /usr/bin/zsh $(whoami)
$ sudo reboot

To install Oh-My-ZSH

$ sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

OR Install Prezto

Install font & Syntax Highlighting extension

$ sudo apt-get install powerline fonts-powerline
$ git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
$ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

Append zsh-autosuggestions & zsh-syntax-highlighting to plugins() like this

plugins=(git zsh-autosuggestions zsh-syntax-highlighting)

Install Theme Powerlevel10k

$ git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k

Then edit your ~/.zshrc and set ZSH_THEME="powerlevel10k/powerlevel10k". Also add the following: POWERLEVEL9K_MODE="awesome-patched"

Display only the last directory segment

  • Open ~/.p10k.zsh, search for POWERLEVEL9K_SHORTEN_STRATEGY and change the value of this parameter to truncate_to_last

  • Alternatively, you can try changing the value of POWERLEVEL9K_DIR_MAX_LENGTH to 1.

  • If you frequently work outside of your home directory, you might want to utilize named directories. For example, WSL users often add this to their ~/.zshrc:

Install a patched font

Enabling Oh-My-ZSH Plugins:

Oh-My-ZSH has many plugins. You can find a list of pre-installed plugins at https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins

Let’s install the colored-man-pages plugin. It adds color to the Linux man pages.

Visual Studio Code config

Installing a patched font will mess up the integrated terminal in VS Code unless you use the proper settings. You'll need to go to settings (Ctrl + ,) and add or edit the following values:

  • For Source Code Pro + Font Awesome: "terminal.integrated.fontFamily": "'SourceCodePro+Powerline+Awesome Regular'". The single quotes are important! Restart VS Code after the config change.
  • For Source Code Pro: "terminal.integrated.fontFamily": "Source Code Pro for Powerline"
  • For Meslo: "terminal.integrated.fontFamily": "Meslo LG M for Powerline"

You can also set the fontsize e.g.: "terminal.integrated.fontSize": 14

Manual install JavaSDK

Download file jdk-8u241-linux-x64.tar.gz at this storage

$ sudo mkdir /opt/java-jdk
$ sudo tar -C /opt/java-jdk -zxf ~/jdk-8u241-linux-x64.tar.gz

Set Default

$ sudo update-alternatives --install /usr/bin/java java /opt/java-jdk/jdk1.8.0_241/bin/java 1
$ sudo update-alternatives --install /usr/bin/javac javac /opt/java-jdk/jdk1.8.0_241/bin/javac 1
$ sudo update-alternatives --install /usr/bin/javaws javaws /opt/java-jdk/jdk1.8.0_241/bin/javaws 1

Check

$ sudo update-alternatives --config java

Install Maven

$ sudo apt install maven

GEN SSH KEY

ssh-keygen -t ed25519 -C "email"

Config for many sshkey

vi ~/.ssh/config

with content

Host *.domain.*
IdentityFile ~/.ssh/domain_rsa

Host *.domain2.*, 10.x.x.*
IdentityFile ~/.ssh/domain2_rsa

example:

eval "$(ssh-agent -s)"

Host *
  AddKeysToAgent yes
  IdentityFile ~/.ssh/id_ed25519
Host *.teko.vn
  AddKeysToAgent yes
  IdentityFile ~/.ssh/nam_teko

Eclipse Shortcut for Ubuntu

cd ~/.local/share/applications
wget https://gist.github.com/raw/2922285/eclipse.desktop
chmod u+x eclipse.desktop
vi eclipse.desktop

Install MySQL Server

$ sudo apt install mysql-server
$ sudo mysql_secure_installation
$ sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf

And then change the bind-address line to 0.0.0.0 instead of 127.0.0.1.

$ sudo systemctl restart mysql
$ sudo systemctl enable mysql

By default, MySQL listens for connections on port 3306. You can confirm that your MySQL service is listening for incoming connections on all interfaces 0.0.0.0 with this command:

$ ss -ltn

Finally, the only thing left to do is make sure that your server's firewall isn't blocking incoming connections on port 3306 (default MySQL listening port). You can issue the following ufw command to add an exception in Ubuntu's default firewall:

$ sudo ufw allow from any to any port 3306 proto tcp

Set password for Root

$ sudo mysql

Next, check which authentication method each of your MySQL user accounts use with the following command:

mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
Output
+------------------+-------------------------------------------+-----------------------+-----------+
| user             | authentication_string                     | plugin                | host      |
+------------------+-------------------------------------------+-----------------------+-----------+
| root             |                                           | auth_socket           | localhost |
| mysql.session    | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys        | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *CC744277A401A7D25BE1CA89AFF17BF607F876FF | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
4 rows in set (0.00 sec)
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

If failed:

msyql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name                        | Value |
+--------------------------------------+-------+
| validate_password.check_user_name    | ON    |
| validate_password.dictionary_file    |       |
| validate_password.length             | 8     |
| validate_password.mixed_case_count   | 1     |
| validate_password.number_count       | 1     |
| validate_password.policy             | MEDIUM|
| validate_password.special_char_count | 1     |
+--------------------------------------+-------+
mysql> SET GLOBAL validate_password.length = 6;
mysql> SET GLOBAL validate_password.policy = LOW;
mysql> SET GLOBAL validate_password.number_count = 0;

Finally

mysql> FLUSH PRIVILEGES;

POSTGRESQL

sudo apt install postgresql postgresql-contrib

Check port

ss -nlt

To bind address 0.0.0.0

sudo systemctl disable postgresql
sudo vi /etc/postgresql/12/main/postgresql.conf

Find and edit:

listen_addresses = '*' // before is local

and

sudo systemctl restart postgresql
sudo bash -c "echo host    all          all            0.0.0.0/0  md5 >> /etc/postgresql/12/main/pg_hba.conf"
sudo ufw allow from any to any port 5432 proto tcp
sudo -u postgres psql
\password

Auto start postgresql when boot

sudo update-rc.d postgresql enable

Android Devices With ADB

Check device vendor id and product id:

$ lsusb
Bus 001 Device 002: ID 8087:8000 Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 078: ID 138a:0011 Validity Sensors, Inc. VFS5011 Fingerprint Reader
Bus 002 Device 003: ID 8087:07dc Intel Corp. 
Bus 002 Device 002: ID 5986:0652 Acer, Inc 
Bus 002 Device 081: ID 22b8:2e81 Motorola PCS 
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Here my android device is Motorola PCS. So my vid=22b8 and pid=2e81.

Now create a udev rule:

sudo vi /etc/udev/rules.d/51-android.rules
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="2e81", MODE="0666", GROUP="plugdev"

Now the device is good to be detected once udev rule is reloaded. So, let's do it:

$ sudo udevadm control --reload-rules

Fix Pulse Secure in Ubuntu 20.04

https://community.pulsesecure.net/t5/Pulse-Desktop-Clients/pulseUi-doesn-t-work-in-ubuntu-20-04/m-p/42733#M1572

GO

Download from Go for Linux

sudo tar -C /usr/local -xzf go1.15.3.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin

Python

In ubuntu 20.04 using python 3.8 To set default:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1

install pip3

 sudo apt install python3-pip
 pip3 --version

MS Fonts

sudo apt install ttf-mscorefonts-installer
sudo fc-cache -f -v

Ibus bamboo FEDORA https://software.opensuse.org//download.html?project=home%3Alamlng&package=ibus-bamboo

@namndev
Copy link
Author

namndev commented Nov 12, 2020

Change Firefox icon in Linux Mint

  1. As root, open the text file /usr/share/applications/firefox.desktop

  2. Find the line that says "Icon=firefox" and change it to

Icon=/usr/share/pixmaps/firefox.png
  1. Save and close the firefox.desktop file

@namndev
Copy link
Author

namndev commented Nov 13, 2020

Install Telepresence

Run the following to install Telepresence:

curl -s https://packagecloud.io/install/repositories/datawireio/telepresence/script.deb.sh | sudo bash

If you are running another Debian-based distribution that has Python 3.8 installable as python3, you may be able to use the Ubuntu 20.04 (Focal) packages. The following works on Linux Mint 20 (Ulyana) and Debian 9 (Stretch) by forcing the PackageCloud installer to access Focal packages.

curl -sO https://packagecloud.io/install/repositories/datawireio/telepresence/script.deb.sh | sudo bash
sudo env os=ubuntu dist=focal bash script.deb.sh

Continue:

sudo apt install --no-install-recommends telepresence
rm script.deb.sh

@namndev
Copy link
Author

namndev commented Nov 13, 2020

Install Kubectl

curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
kubectl version

Detail

@namndev
Copy link
Author

namndev commented Feb 8, 2023

Tricks

  1. Change icon of mouse when hove jetbrains IDE
    Change to Yaru
/usr/share/icons/default/index.theme
  1. Disable touchscreen
    In file /usr/share/X11/xorg.conf.d/40-libinput.conf change:
MatchIsTouchscreen = "off"

and add new file:

sudo vi /usr/share/X11/xorg.conf.d/99-disabletouch.conf

content

Section "InputClass"
    Identifier "Touchscreen catchall"
    MatchIsTouchscreen "off"
EndSection
  1. Fix warning when run apt update
cd /etc/apt
sudo cp trusted.gpg trusted.gpg.d
  1. Check resolution:
xdpyinfo | grep -B2 resolution

To set dpi, fb

xrandr --help
  1. Support HEIC in linux
sudo apt install heif-gdk-pixbuf

@namndev
Copy link
Author

namndev commented Feb 9, 2023

$ apt list --upgradable
$ sudo apt --only-upgrade install package_name

@namndev
Copy link
Author

namndev commented Feb 9, 2023

Fix slack gpgkey

sudo apt-key list

How do you do that? Read the message carefully.

W: https://packagecloud.io/slacktechnologies/slack/debian/dists/jessie/InRelease: Key is stored in legacy

Run

sudo apt-key export 038651BD | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/slack.gpg

check

ls -l /etc/apt/trusted.gpg.d/slack.gp

Fix missing key issue for Slack APT repo in Debian/Ubuntu

If you are using Debian/Ubuntu, having Slack installed, you will see this warning when doing apt update:

W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://packagecloud.io/slacktechnologies/slack/debian jessie InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY C6ABDCF64DB9A0B2
W: Failed to fetch https://packagecloud.io/slacktechnologies/slack/debian/dists/jessie/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY C6ABDCF64DB9A0B2
W: Some index files failed to download. They have been ignored, or old ones used instead.

Here is how to fix:

Use GPG to retrieve Slack public key:
$ gpg --keyserver pgpkeys.mit.edu --recv-key C6ABDCF64DB9A0B2              
gpg: key D938EC0D038651BD: public key "https://packagecloud.io/slacktechnologies/slack (https://packagecloud.io/docs#gpg_signing) <support@packagecloud.io>" imported
gpg: Total number processed: 1
gpg:               imported: 1
Export that key to a file, storing it to a place where APT can use
gpg --export C6ABDCF64DB9A0B2 | sudo tee /etc/apt/keyrings/slack.gpg
Open `/etc/apt/sources.list.d/slack.list` file, which was added automatically when you installed Slack from deb file, modify the line to be like this:
deb [signed-by=/etc/apt/keyrings/slack.gpg] https://packagecloud.io/slacktechnologies/slack/debian/ jessie main

(we add [signed-by=...])

Now, run sudo apt update again, you won't see that warning message.

@namndev
Copy link
Author

namndev commented May 6, 2023

Change the default terminal
sudo update-alternatives --config x-terminal-emulator

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