I use Apache2 as the server to store my websites and mysql as the database.

Once they get set up, I don’t use them that frequently.

Then I forget the commands.

This is my Cheatsheet.

Apache2 Commands

Shutdown and Restart

sudo shutdown -r now

Update Package Library

sudo apt-get update

Apply Package Library Updates

sudo apt-get dist-upgrade

Change into public html directory

cd /var/www/html

Change into sites-available directory

cd /etc/apache2/sites-available

Change into sites-enabled directory

cd /etc/apache2/sites-enabled

Enable a site file. Run it in sites-available directory.

sudo a2ensite name_of_site_file_enabled 

Command to be run after site is enabled

sudo systemctl reload apache2

Disable a site file. Run it in sites-available directory.

sudo a2dissite name_of_site_file_disabled

Command to be run after site is disabled

sudo systemctl reload apache2

MYSQL Commands

Basic Configuration

database -> tables -> columns and rows

To Not Have To Type In Password, Create .my.cnf in ~ directory

[client]
user=user_name
password=user_password

Call Up The Mysql Console - At a command prompt

mysql

Create Database

CREATE database [name];

Delete Database

DROP DATABASE [name];

List All Databases

SHOW databases;

Show Tables From Specific Database

SHOW TABLES FROM database_name; (no need to switch to database first)

To Use A Specific Database

USE [database];

After Switching Into Database, To Show Table Names

SHOW TABLES;

After Switching Into Database, To Show Table Names And Types

SHOW  FULL TABLES;

Afer Switching Into Database, See Columns From Specific Table

SHOW COLUMNS FROM [name of table];

Afer Switching Into Database, to see all the data in the column

Select * from column_name  

Afer Switching Into Database, to see data from multiple columns

SELECT [column_name_1], [column_name_2] FROM [table_name];

Switch User

mysql -u<username> -p - switch mysql user

Visit Emlekezik.com