A handy list of commands for Ubuntu Terminal

Package Update and Installation:

sudo apt-get update

sudo apt-get install tree

sudo apt install zip unzip

Directory Tree Structure:

tree folder_name

Zip a folder:

zip -r output_file.zip input_folder

Unzip a folder:

unzip file.zip

Check Versions:

  • Ubuntu: lsb_release -a
  • MySQL DB: select VERSION();
  • Python: python --version
  • Pip: pip --version
  • Virtualenv: virtualenv --version

Run MySQL on Ubuntu:

sudo apt-get install mysql-server

/usr/bin/mysql -u root -p

Create MySQL User:

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'user_password';

/usr/bin/mysql -u newuser -p

select * from mysql.user;

Show, Create and Drop MySQL Databases:

show databases;

CREATE DATABASE database_name;

DROP DATABASE database_name;

Use MySQL Database and Show Tables from Database:

USE database_name

show tables from database_name

Grant and Show Privileges to MySQL User:

GRANT ALL PRIVILEGES ON database_name.* TO 'newuser'@'localhost';

SHOW GRANTS FOR 'newuser'@'localhost';

Revoke Privileges and Drop MySQL User:

REVOKE ALL PRIVILEGES ON database_name.* FROM 'newuser'@'localhost';

DROP USER 'newuser'@'localhost';

Quit MySQL Console:

quit;

\q

Installing and Upgrading Pip:

pip install --upgrade pip

Creating, activating and deactivating a virtual environment:

Create a separate project directory

mkdir my_project

cd my_project

Install virtualenv

sudo apt-get update

sudo apt-get install python3-venv

Creating the virtual environment

python -m venv my_venv on windows

python3 -m venv my_venv on linux

Activating the virtual environment

venv\Scripts\activate.bat on windows

source venv/bin/activate on linux

Deactivating the virtual environment

deactivate

Removing a Virtual environment:

rm -r my_venv/

I'll keep updating this list from time to time.

Subscribe here to stay informed!