Skip to content

Instantly share code, notes, and snippets.

@arsho
Last active February 15, 2023 20:02
Show Gist options
  • Save arsho/83e00f2696a8f7c8da0c517a6f5261ed to your computer and use it in GitHub Desktop.
Save arsho/83e00f2696a8f7c8da0c517a6f5261ed to your computer and use it in GitHub Desktop.
Install basic tools in Ubuntu 22.04 LTS. It includes: oh-my-zsh, idle, venv, git, tree, MySQL, PHP, phpMyAdmin.
  • Generate the SSH key:
cd ~/.ssh
ssh-keygen -t ed25519 -C "[email protected]"
cat id_ed25519.pub
  • Add the public key in Github website settings.

References

Install CUDA in Ubuntu 22.10

  • Download and install network installer:
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb
sudo dpkg -i cuda-keyring_1.0-1_all.deb
sudo apt-get update
sudo apt-get -y install cuda
  • Export CUDA path to current path:
export PATH=/usr/local/cuda-12.0/bin${PATH:+:${PATH}}
  • Close and open terminal.
  • Check the versions:
nvcc --version                                       
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Fri_Jan__6_16:45:21_PST_2023
Cuda compilation tools, release 12.0, V12.0.140
Build cuda_12.0.r12.0/compiler.32267302_0
➜  ~ nvidia-smi
Wed Feb  8 15:55:17 2023       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.85.12    Driver Version: 525.85.12    CUDA Version: 12.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  On   | 00000000:01:00.0 Off |                  N/A |
| N/A   43C    P8     8W /  55W |      6MiB /  6144MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      2117      G   /usr/lib/xorg/Xorg                  4MiB |
+-----------------------------------------------------------------------------+
  • Add the path to .zshrc file:
# add cuda
export PATH=/usr/local/cuda-12.0/bin${PATH:+:${PATH}}

Install NCCL

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb
sudo dpkg -i cuda-keyring_1.0-1_all.deb
sudo apt-get update\n
sudo apt install libnccl2=2.16.5-1+cuda12.0 libnccl-dev=2.16.5-1+cuda12.0
  • To run NCCL program:
nvcc -o nccl_example nccl_example.cu -lnccl
./nccl_example

Install Oh My Zsh in Ubuntu 18.04 LTS

  • Install Zsh:
    sudo apt install zsh
    
  • Install git:
    sudo apt install git
    
  • Install oh-my-zsh:
    sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
    
  • If it asks to make it default, accept.
  • Logout and login to the machine.
  • Make zsh as default shell:
    chsh -s `which zsh`
    
  • Re-login to desktop to reflect changes.

Install PHP, MySQL, phpMyAdmin in Ubuntu 18.04 LTS

Install Mysql Server and MySQL Client

What is the difference between MySQL Server and MySQL Client?

MySql Client: The mysql-client package allows you to connect to a MySQL server. It will give you the mysql command-line program.

MySql Server: The mysql-server package allows to run a MySQL server which can host multiple databases and process queries on those databases.

  • Update Ubuntu

    sudo apt update
    
  • Upgrade Ubuntu

    sudo apt upgrade
    
  • Install MySQL Server

    sudo apt install mysql-server
    

    Enter root user password if asked.

  • Install MySQL Client

    sudo apt install mysql-client
    
  • Configure MySQL

    sudo mysql_secure_installation
    [sudo] password for USER_NAME_OF_MACHINE: 
    Would you like to setup VALIDATE PASSWORD plugin?
    Press y|Y for Yes, any other key for No: 
    
    Please set the password for root here.
    New password: 
    Re-enter new password: 
    
    Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
    Success.
    
    Disallow root login remotely? (Press y|Y for Yes, any other key for No) : 
    ... skipping.
    
    Remove test database and access to it? (Press y|Y for Yes, any other key for No) :   
    ... skipping.
    
    Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
    Success.
    
    All done!  
    
  • Test MySQL service

    systemctl status mysql.service
    
  • Test connecting to database

    sudo mysqladmin -p -u root version
    
  • Open Mysql Console

    sudo mysql -p -u root
    
  • In case the MySQL is not running, start it with

    sudo systemctl start mysql
    
  • In case you need to restart MySQL, restart it with

    sudo systemctl restart mysql
    
  • Create database in MySQL console

    create database cp_intrafish;
    
  • Install mysql-config

    sudo apt-get install libmysqlclient-dev
    
  • Load Database dump to the newly created database. Here cp_intrafish is the database name and myifm_dump.sql is the SQL dump file.

    mysql -p -u root cp_intrafish<myifm_dump.sql
    
  • Pretty output in MySQL console. Add \G at the end of your command. This will change the output just for that command, without changing the default output.

    SELECT * FROM product_price\G;
    

Install Apache2

sudo apt-get -y install apache2

Install PHP

sudo apt-get -y install php libapache2-mod-php
sudo apt-get -y install php-mbstring php-mbstring php-gettext
systemctl restart apache2
php --version

Install phpMyAdmin

sudo apt-get -y install phpmyadmin
sudo systemctl restart mysql.service

Edit Apache webserver config file

sudo nano /etc/apache2/apache2.conf
  • Add the following line at the end:
    Include /etc/phpmyadmin/apache.conf
    
  • Restart Apache server
    sudo systemctl restart apache2
    
  • To access phpMyAdmin go to http://localhost/phpmyadmin/

Handling Error in accessing database using phpMyAdmin

MySQL 5.7 changed the secure model: now MySQL root login requires a sudo.

I.e., phpMyAdmin will be not able to use root credentials.

The simplest, safest and permanent solution will be create a new user and grant required privileges.

  • Connect to MySQL
    sudo mysql --user=root mysql
    
  • Create an user for phpMyAdmin Replace some_pass by the desired password:
    CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY 'some_pass';
    
    If you get ERROR 1396 (HY000): Operation CREATE USER failed for 'phpmyadmin'@'localhost', check if you have already an user called phpmyadmin using:
    select user,host from user;
    
    Then give all privileges to the user:
    GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;
    FLUSH PRIVILEGES;
    

If your phpMyAdmin is connecting to localhost, this should be enough.

  • Add File read/write permission for current user in /var/www directory:
    ➜  ~ whoami
    arsho
    ➜  ~ sudo adduser arsho www-data
    [sudo] password for arsho: 
    Adding user `arsho' to group `www-data' ...
    Adding user arsho to group www-data
    Done.
    ➜  ~ sudo chown -R www-data:www-data /var/www
    ➜  ~ sudo chmod -R g+rwX /var/www
    
  • Logout and Login again.

Reference:

Install Tools for Python

  • Ubuntu 18.04 comes with Python 3.6.7:
    python3 --version                
    Python 3.6.7
    
  • It does not have idle or venv in it.
  • Install idle:
    sudo apt install idle
    
  • Install venv:
    sudo apt-get install python3-venv
    

(Optional) Create Flask application inside virtual environment and run locally:

  • Create new virtual environment and activate it
    python3 -m venv venv             
    source venv/bin/activate
    
  • Install flask:
    pip install flask
    
  • Application app.py:
    from flask import Flask
    
    app = Flask(__name__)
    
    @app.route('/')
    def index():
        return "Hello from Flask"
    
    
  • Environment file .flaskenv:
    FLASK_APP=app.py
    FLASK_ENV=development
    
  • Run the application:
    flask run
    

Install tree package in Ubuntu 18.04

  • Install the package:
    sudo apt install tree
    
  • Show current directory in tree view:
    tree
    
  • Ignore a specific directory in tree view:
    tree -I venv
    
  • Ignore multiple directories or pattern in tree view:
    tree -I 'venv|__pycache__'
    

Steps to install Ubuntu 18.04 alongside pre installed Windows 10 as dual boot in NVMe SSD.

Hardware Information:

  • Dell G5 5587
  • Core i7 8750H
  • RAM 16 GB
  • NVMe SSD (Toshiba) 256 GB
  • HDD 1 TB
  • NVIDIA® GeForce® GTX 1060 6GB GDDR5 with Max-Q Design

Download Files

Check Target Machine (optional)

  • Press Win + R.
  • Type msinfo32 and press Enter.
  • Look for the BIOS Mode entry.
  • If the value listed is Legacy, then the Boot Environment is BIOS, otherwise the respective Boot Environment will be listed.

Burn the ISO to a Pendrive

  • Insert a USB pendrive.
  • Backup the pendrive data if necessary.
  • Open Rufus.
  • Select Partition Scheme MBR.
  • Keep the other settings to default. E.g.: FAT.
  • Select the ISO and burn it to the connected pendrive.

Create Unallocated Space for Ubuntu

  • Open disk management in Windows.
  • Shrink the volume where Windows is installed(NVMe SSD). The size depends on yourself. I have created 100 GB of unallocated space.

Turn off Fast startup from Windows 10

  • Dual boot does not work when Fast startup option is enabled in Windows 10.
  • Right-click the Start button.
  • Click Search.
  • Type Control Panel and hit Enter on your keyboard.
  • Click Power Options.
  • Click Choose what the power buttons do.
  • Click Change settings that are currently unavailable.
  • Uncheck Turn on fast startup (recommended).
  • Click Save changes.

Turn off secure boot from BIOS

  • Tap F2 key at the Dell logo screen to enter System Setup or BIOS.
  • On the left pane, click Boot Sequence.
  • Check that Secure Boot is set to Disabled. Within the BIOS go to Secure Boot > Secure Boot Enable, and set the checkbox to Disabled.
  • Change the Secure Boot Mode to audit mode.
  • Save settings and the machine will be restarted.

Enable AHCI for dual boot

  • With a preinstalled Windows SATA mode set to IDE or RAID in BIOS.
  • To install dual boot we need to change SATA mode to AHCI from BIOS.
  • Create the Windows 10 local account:
    • Go to Settings > Accounts.
    • Select Family & other users.
    • Tap Add someone else to this PC.
    • Select I don't have this person's sign-in information.
    • Select Add a user without a Microsoft account.
    • Enter a username, type the account's password twice, enter a clue and select Next.
    • Change the Account type of this newly created account to Administrator.
    • Login using this new user account.
  • Right-click the Windows Start Menu. Choose Command Prompt (Admin).
  • Type this command and press ENTER: bcdedit /set {current} safeboot minimal
  • Restart the computer and enter BIOS Setup. On Dell Inspiron it is F2.
  • Change the SATA Operation mode to AHCI from either IDE or RAID.
  • Save changes and exit Setup and Windows will automatically boot to Safe Mode.
  • Right-click the Windows Start Menu once more. Choose Command Prompt (Admin).
  • Type this command and press ENTER: bcdedit /deletevalue {current} safeboot
  • Reboot once more and Windows will automatically start with AHCI drivers enabled.

Install Ubuntu

  • After the OS burn, insert the pendrive and restart the machine.
  • Press F12 or F10 depending your machine.
  • Select USB/Removable media.
  • Select install Ubuntu.
  • Select Language and other options.
  • When it comes to partition option, select something else.
  • In the unallocated space:
    • Give 2 GB Logical space to swap memory. The swap size depends on your RAM size.
    • Give remaining Primary space to / partition
  • Select Windows Boot Manager as Device for boot loader installation.
  • Continue with the remaining process.

Install Drivers (optional)

  • After successful installation of Ubuntu, update the system softwares.
  • To update the drivers:
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get dist-upgrade
    ubuntu-drivers devices
    sudo ubuntu-drivers autoinstall
    
  • You may now access both Windows and Ubuntu in a dual boot manner.

Reference:

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