Reading view

There are new articles available, click to refresh the page.

How to change Hostname in Linux from command line and GUI

Change hostname from command line

Step 1 : Check the hostname using command

$ hostname or hostnamectl

Step 2 : Change the hostname with the following command. In this example, we’ll change our hostname to LocalMachine.

$ sudo hostnamectl set-hostname LocalMachine

Step 3 : Lastly, edit the /etc/hosts file to reflect the change. For example:

$ sudo vim /etc/hosts

Change this:

To this:

Hostname changes can seen below:

Change hostname from Ubuntu GUI

Step 1 : Start by opening the Settings menu from GNOME’s application launcher.

Step 2 : Change the device name (hostname) inside the About tab. Click on the About tab at the bottom and then click on Device Name.

Step 3 : Type your new desired hostname and click Rename to finalize the changes.

Hostname finally changed

Thank you!!

How to change Hostname in Linux from command line and GUI

Change hostname from command line

Step 1 : Check the hostname using command

$ hostname or hostnamectl

Step 2 : Change the hostname with the following command. In this example, we’ll change our hostname to LocalMachine.

$ sudo hostnamectl set-hostname LocalMachine

Step 3 : Lastly, edit the /etc/hosts file to reflect the change. For example:

$ sudo vim /etc/hosts

Change this:

To this:

Hostname changes can seen below:

Change hostname from Ubuntu GUI

Step 1 : Start by opening the Settings menu from GNOME’s application launcher.

Step 2 : Change the device name (hostname) inside the About tab. Click on the About tab at the bottom and then click on Device Name.

Step 3 : Type your new desired hostname and click Rename to finalize the changes.

Hostname finally changed

Thank you!!

Node and npm Installation on Linux Ubuntu 22.04.4

STEP 1 : Uninstall node and npm

sudo apt-get remove node.js
sudo apt-get remove npm

STEP 2: sudo apt update

STEP 3: sudo apt-get install -y node.js

STEP 4: sudo apt-get install npm

STEP 5: npm cache clean -f && sudo npm install -g n && sudo n latest

STEP 6: Check the node version, if it shows the older version, open a new terminal.

STEP 7: Check node and npm version

STEP 8: sudo npm install -g create-react-app

STEP 9: create-react-app sample . (sample is project name), project name starts with small letters.

Project name sample folder can view in home directory

Thank You!

WordPress Installation

STEP 1: Install LAMP Stack before install wordpress

https://avvaruvanaja.wordpress.com/2024/03/03/lamp-stack-installation/(opens in a new tab)

STEP 2: Login to mariadb and create wordpress user and wordpress database and give privileges

mysql -u root -p

CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'kan123';
CREATE DATABASE wpdb;
GRANT ALL PRIVILEGES ON wpdb.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
exit;

STEP 3: Download the latest wordpress zip file

wget https://wordpress.org/latest.zip
unzip latest.zip
rm latest.zip
sudo mv wordpress/ /var/www/html/
sudo chown www-data:www-data -R /var/www/html/wordpress/
sudo chmod -R 755 /var/www/html/wordpress/

STEP 4: Create WordPress Configuration file

sudo vim /etc/apache2/sites-available/wordpress.conf

STEP 5: Enable the virtual host and the rewrite module

sudo a2ensite wordpress.conf
sudo systemctl reload apache2
sudo a2enmod rewrite
sudo systemctl restart apache2

STEP 6: In the browser

http://server_ip

Reference : https://github.com/tkdhanasekar/kaniyam-devops-course-materials/blob/main/Linux/wordpress_install.md

Thank You!

LAMP Stack Installation

  • A LAMP stack is a bundle of four different software technologies that developers use to build websites and web applications.
  • LAMP is acronymn for Linux – Operating System, Apache – Web Server, MYSQL – Database Server, PHP – Programming Language.
  • All four of these technologies are open source, which means they are community maintained and freely available for anyone to use.
  • Developers use LAMP stacks to create, host, and maintain web content.

LINUX – Linux is open source operating system, that you can install and configure to meet different application requirements.

APACHE – Apache is an open source web server that forms the second layer of the lamp stack. The Apache module stores websites files and exchanges information with a browser using HTTP, an internet protocol for transferring websire information in plain text. When a browser request a webpage, the Apache HTTP server does the following steps:

  • Receives the request
  • Processes the request and finds the required page file
  • Sends the relevant information back to the browser

MySQL – MYSQL is an open-source relational database management system and is the third layer of the LAMP stack. The LAMP model uses MySQL for storing, managing, and querying information in relational databases.

PHP – PHP which stands for PHP: Hypertext Preprocessor, is the fourth and final layer of the LAMP stack. It is a scripting language that allows websites to run dynamic processes. A dynamic process involves information in software that constantly changes. Web developers embed the PHP programming language in HTML to show real-time or updated information on websites.

Steps for LAMP Stack Installation

STEP 1 : Apache Installation

sudo apt update -y && apt upgrade -y
sudo apt install apache2 apache2-utils -y
sudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl status apache2
apache2 -v

Check on browser with ip of server we need to set www-data (Apache user) as the owner of document root.

sudo chown -R www-data:www-data /var/www/html

STEP 2: MariaDB Installation

sudo apt install mariadb-server mariadb-client
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo systemctl status mariadb

Creating root password for mariadb

mysql_secure_installation
Enter current password for root (enter for none): enter
Set root password? [Y/n] Y
New password:******
Re-enter new password:******
Remove anonymous users? [Y/n]Y
Disallow root login remotely? [Y/n]Y
Remove test database and access to it? [Y/n]Y
Reload privilege tables now? [Y/n]Y

Login to Mariadb

mariadb --version
mariadb -u root -p
MariaDB [(none)]> exit

STEP 3 : PHP Installation

sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.2 libapache2-mod-php8.2 php8.2-mysql php-common php8.2-cli php8.2-common php8.2-opcache php8.2-readline php-json

Enable the Apache php8.2 module then restart Apache Web server.

a2enmod php8.2

Restart the apache server and check the version

sudo systemctl restart apache2
php --version

Test with php test page

sudo vim /var/www/html/info.php
<?php phpinfo(); ?>
:wq! save and exit

In terminal

curl http://<server_ip>/info.php

Or in browser

http://<server_ip>/info.php

http://<server_ip>/CustomisedIndex.html

Reference:-https://github.com/tkdhanasekar/kaniyam-devops-course-materials/blob/main/Linux/lamp-stack.md. https://aws.amazon.com/what-is/lamp-stack/
Thank You!

Node and npm Installation on Linux Ubuntu 22.04.4

STEP 1 : Uninstall node and npm

sudo apt-get remove node.js
sudo apt-get remove npm

STEP 2: sudo apt update

STEP 3: sudo apt-get install -y node.js

STEP 4: sudo apt-get install npm

STEP 5: npm cache clean -f && sudo npm install -g n && sudo n latest

STEP 6: Check the node version, if it shows the older version, open a new terminal.

STEP 7: Check node and npm version

STEP 8: sudo npm install -g create-react-app

STEP 9: create-react-app sample . (sample is project name), project name starts with small letters.

Project name sample folder can view in home directory

Thank You!

WordPress Installation

STEP 1: Install LAMP Stack before install wordpress

https://avvaruvanaja.wordpress.com/2024/03/03/lamp-stack-installation/(opens in a new tab)

STEP 2: Login to mariadb and create wordpress user and wordpress database and give privileges

mysql -u root -p

CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'kan123';
CREATE DATABASE wpdb;
GRANT ALL PRIVILEGES ON wpdb.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
exit;

STEP 3: Download the latest wordpress zip file

wget https://wordpress.org/latest.zip
unzip latest.zip
rm latest.zip
sudo mv wordpress/ /var/www/html/
sudo chown www-data:www-data -R /var/www/html/wordpress/
sudo chmod -R 755 /var/www/html/wordpress/

STEP 4: Create WordPress Configuration file

sudo vim /etc/apache2/sites-available/wordpress.conf

STEP 5: Enable the virtual host and the rewrite module

sudo a2ensite wordpress.conf
sudo systemctl reload apache2
sudo a2enmod rewrite
sudo systemctl restart apache2

STEP 6: In the browser

http://server_ip

Reference : https://github.com/tkdhanasekar/kaniyam-devops-course-materials/blob/main/Linux/wordpress_install.md

Thank You!

LAMP Stack Installation

  • A LAMP stack is a bundle of four different software technologies that developers use to build websites and web applications.
  • LAMP is acronymn for Linux – Operating System, Apache – Web Server, MYSQL – Database Server, PHP – Programming Language.
  • All four of these technologies are open source, which means they are community maintained and freely available for anyone to use.
  • Developers use LAMP stacks to create, host, and maintain web content.

LINUX – Linux is open source operating system, that you can install and configure to meet different application requirements.

APACHE – Apache is an open source web server that forms the second layer of the lamp stack. The Apache module stores websites files and exchanges information with a browser using HTTP, an internet protocol for transferring websire information in plain text. When a browser request a webpage, the Apache HTTP server does the following steps:

  • Receives the request
  • Processes the request and finds the required page file
  • Sends the relevant information back to the browser

MySQL – MYSQL is an open-source relational database management system and is the third layer of the LAMP stack. The LAMP model uses MySQL for storing, managing, and querying information in relational databases.

PHP – PHP which stands for PHP: Hypertext Preprocessor, is the fourth and final layer of the LAMP stack. It is a scripting language that allows websites to run dynamic processes. A dynamic process involves information in software that constantly changes. Web developers embed the PHP programming language in HTML to show real-time or updated information on websites.

Steps for LAMP Stack Installation

STEP 1 : Apache Installation

sudo apt update -y && apt upgrade -y
sudo apt install apache2 apache2-utils -y
sudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl status apache2
apache2 -v

Check on browser with ip of server we need to set www-data (Apache user) as the owner of document root.

sudo chown -R www-data:www-data /var/www/html

STEP 2: MariaDB Installation

sudo apt install mariadb-server mariadb-client
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo systemctl status mariadb

Creating root password for mariadb

mysql_secure_installation
Enter current password for root (enter for none): enter
Set root password? [Y/n] Y
New password:******
Re-enter new password:******
Remove anonymous users? [Y/n]Y
Disallow root login remotely? [Y/n]Y
Remove test database and access to it? [Y/n]Y
Reload privilege tables now? [Y/n]Y

Login to Mariadb

mariadb --version
mariadb -u root -p
MariaDB [(none)]> exit

STEP 3 : PHP Installation

sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.2 libapache2-mod-php8.2 php8.2-mysql php-common php8.2-cli php8.2-common php8.2-opcache php8.2-readline php-json

Enable the Apache php8.2 module then restart Apache Web server.

a2enmod php8.2

Restart the apache server and check the version

sudo systemctl restart apache2
php --version

Test with php test page

sudo vim /var/www/html/info.php
<?php phpinfo(); ?>
:wq! save and exit

In terminal

curl http://<server_ip>/info.php

Or in browser

http://<server_ip>/info.php

http://<server_ip>/CustomisedIndex.html

Reference:-https://github.com/tkdhanasekar/kaniyam-devops-course-materials/blob/main/Linux/lamp-stack.md. https://aws.amazon.com/what-is/lamp-stack/
Thank You!

MariaDB on Linux OS

Steps to install MariaDB on Linux

Step 1: Install mariadb
Step 2:create root password for mariadb
Step 3: 1:create database
Step 4:create tables
Step 5:insert, view, filter, delete records in tables
Step 6:delete database, tables
Step 7:create remote db user , password , grant privileges
Step 8:access remote db from local machine

Step 1: To install Mariadb. Run the below command on Ubuntu terminal.

Step 2: To Check the status of Mariadb, type the below command.

Step 3: Irrespective of reboot, to have Mariadb is up(Running) all the time, Run the below command.

Step 4: To Configure, Mariadb root password

Step 5: To login to Mariadb

Database prompt looks like below

Step 6: To view Databases

Default Mariadb Database table will show

Step 7: To create a Database

Step 8: To view the database name “AMariaDB”. type the command ” show databases; “

Created CMariaDB and BMariaDB

Step 9: To use database

Step 10: To view tables in a AMariaDB Database, Type the below command.

Step 11: To create a table with name ” friends .

Step 12: To check table name friends created.

Step 13: To create a record in table ” friends “.

Step 14: To view the record created in table ” friends “.

Step 15: To create multiple records in table “friends”.

To view the record created in table ” friends “.

Step 16: To view a particular record from the table ” friend “

Step 17: To delete a particular record from the table ” friends “

Step 18: To delete a table ” friends “

Step 19: To delete a database ” AMariaDB

Before database deletion ” AMariaDB”

After database deletion ” AMariaDB”

Step 20: To access a remote database , create a user myuser and password for the user, grant all privileges.

Step 21: edit the config file bind address from 127.0.0.1 to 0.0.0.0

Before edit

After edit

Step 22: Restart your MariaDB service , type the below command

Step 23: From your local machine. Type the below command.

$ mysql -u myuser -p -h <remote_dbserver_ip>
MariaDB [(none)]>

Step 24: To make mariadb to connect in custom port instead of 3306/TCP Use the commands below to change the default MySQL/MariaDB Database port in Linux.

vim /etc/mysql/mariadb.conf.d/50-server.cnf

Step 25: Add the parameter under [mysqld] port = 4406

port = 4406
: wq! save and exit
sudo systemctl restart mariadb.service


Step 26: connect remote db with custom port 4406
mysql -u myuser -p -h <remote_dbserver_ip> -P 4406
mysql -u kaniyam -p -h kaniyam.hopto.org -P 4406


Reference: https://github.com/tkdhanasekar/kaniyam-devops-course-materials/blob/main/Linux/mariadb.md

Thank you!

Apache WebServer Service on Linux Ubuntu 22.04.4

Steps for Apache WebServer Service On Linux Terminal

Step 1: To install Apache Webserver. Run the below command on Ubuntu terminal.

Step 2: To check the system status whether Apache2 server is running, Run the below Linux command.

Step 3: Irrespective of reboot, to have Apache server is up(Running) all the time, Run the below command

Step 4: Run the below Linux command to check where the Apache2 server files are?

Step 5: To check what files are available in html folder, Run the below command

Step 6: Ubuntu default Apache2 page is available in “index.html”. Go to web browser, and type localhost, Ubuntu default Apache2 page appears.

Step 7: Using IP address also can view Ubuntu Apache2 default page, open web browser and type 127.0.0.1

Step 8: If you have bad memory to remember IP address, its possible to rename the IP address to any other name. Run the below command in terminal.

Step 9: To rename the localhost press ‘ i ‘ and type “kaniyam.in” . To save the file and exit from the vim editor, press [Esc] + :wq or [Esc] + 😡

Step 10: Go to web browser and type ” kaniyam.in ” . Ubuntu default page Apache2 appears!.

Step 11: To see what is inside the “index.html” i.e; Ubuntu default Apache2 page, run the below command.

Step 12: index.html page

Step 13: To remove the ” index.html “, type the below command.

Step 14: Creating a new html file with an image. Save the html file as ” CustomisedIndex.html “. The image file “January1st.jpeg” should be in the same in folder as html file. Run the below command.

Step 15: To list all the files and to check html file and image are in same folder. Type the below command.

Step 16: Copy html file (CustomisedIndex.html) to Apache default html directory (/var/www/html/). Type the below command.

Step 17: To Check CustomisedIndex.html is copied to html directory. Type the Linux command.

Step 18: Copy image file (January1st.jpeg) to Apache default html directory (/var/www/html/). Type the below command.

Step 19: To Check January1st.jpeg image file is copied to html directory. Type the Linux command.

Step 20: Open Web browser, type localhost/CustomisedIndex.html

Step 21: Type the below command to check all the Apache2 web server configuration files

Step 22: Apache2 by default run on port 80, port number can be customise too.

Step 23: Nginx is another Open source Web Server. Follow the same steps as Apache2 Web server.

Reference: https://github.com/tkdhanasekar/kaniyam-devops-course-materials/blob/main/Linux/apache-local-installation.md

Thank you!

MariaDB on Linux OS

Steps to install MariaDB on Linux

Step 1: Install mariadb
Step 2:create root password for mariadb
Step 3: 1:create database
Step 4:create tables
Step 5:insert, view, filter, delete records in tables
Step 6:delete database, tables
Step 7:create remote db user , password , grant privileges
Step 8:access remote db from local machine

Step 1: To install Mariadb. Run the below command on Ubuntu terminal.

Step 2: To Check the status of Mariadb, type the below command.

Step 3: Irrespective of reboot, to have Mariadb is up(Running) all the time, Run the below command.

Step 4: To Configure, Mariadb root password

Step 5: To login to Mariadb

Database prompt looks like below

Step 6: To view Databases

Default Mariadb Database table will show

Step 7: To create a Database

Step 8: To view the database name “AMariaDB”. type the command ” show databases; “

Created CMariaDB and BMariaDB

Step 9: To use database

Step 10: To view tables in a AMariaDB Database, Type the below command.

Step 11: To create a table with name ” friends .

Step 12: To check table name friends created.

Step 13: To create a record in table ” friends “.

Step 14: To view the record created in table ” friends “.

Step 15: To create multiple records in table “friends”.

To view the record created in table ” friends “.

Step 16: To view a particular record from the table ” friend “

Step 17: To delete a particular record from the table ” friends “

Step 18: To delete a table ” friends “

Step 19: To delete a database ” AMariaDB

Before database deletion ” AMariaDB”

After database deletion ” AMariaDB”

Step 20: To access a remote database , create a user myuser and password for the user, grant all privileges.

Step 21: edit the config file bind address from 127.0.0.1 to 0.0.0.0

Before edit

After edit

Step 22: Restart your MariaDB service , type the below command

Step 23: From your local machine. Type the below command.

$ mysql -u myuser -p -h <remote_dbserver_ip>
MariaDB [(none)]>

Step 24: To make mariadb to connect in custom port instead of 3306/TCP Use the commands below to change the default MySQL/MariaDB Database port in Linux.

vim /etc/mysql/mariadb.conf.d/50-server.cnf

Step 25: Add the parameter under [mysqld] port = 4406

port = 4406
: wq! save and exit
sudo systemctl restart mariadb.service


Step 26: connect remote db with custom port 4406
mysql -u myuser -p -h <remote_dbserver_ip> -P 4406
mysql -u kaniyam -p -h kaniyam.hopto.org -P 4406


Reference: https://github.com/tkdhanasekar/kaniyam-devops-course-materials/blob/main/Linux/mariadb.md

Thank you!

Apache WebServer Service on Linux Ubuntu 22.04.4

Steps for Apache WebServer Service On Linux Terminal

Step 1: To install Apache Webserver. Run the below command on Ubuntu terminal.

Step 2: To check the system status whether Apache2 server is running, Run the below Linux command.

Step 3: Irrespective of reboot, to have Apache server is up(Running) all the time, Run the below command

Step 4: Run the below Linux command to check where the Apache2 server files are?

Step 5: To check what files are available in html folder, Run the below command

Step 6: Ubuntu default Apache2 page is available in “index.html”. Go to web browser, and type localhost, Ubuntu default Apache2 page appears.

Step 7: Using IP address also can view Ubuntu Apache2 default page, open web browser and type 127.0.0.1

Step 8: If you have bad memory to remember IP address, its possible to rename the IP address to any other name. Run the below command in terminal.

Step 9: To rename the localhost press ‘ i ‘ and type “kaniyam.in” . To save the file and exit from the vim editor, press [Esc] + :wq or [Esc] + 😡

Step 10: Go to web browser and type ” kaniyam.in ” . Ubuntu default page Apache2 appears!.

Step 11: To see what is inside the “index.html” i.e; Ubuntu default Apache2 page, run the below command.

Step 12: index.html page

Step 13: To remove the ” index.html “, type the below command.

Step 14: Creating a new html file with an image. Save the html file as ” CustomisedIndex.html “. The image file “January1st.jpeg” should be in the same in folder as html file. Run the below command.

Step 15: To list all the files and to check html file and image are in same folder. Type the below command.

Step 16: Copy html file (CustomisedIndex.html) to Apache default html directory (/var/www/html/). Type the below command.

Step 17: To Check CustomisedIndex.html is copied to html directory. Type the Linux command.

Step 18: Copy image file (January1st.jpeg) to Apache default html directory (/var/www/html/). Type the below command.

Step 19: To Check January1st.jpeg image file is copied to html directory. Type the Linux command.

Step 20: Open Web browser, type localhost/CustomisedIndex.html

Step 21: Type the below command to check all the Apache2 web server configuration files

Step 22: Apache2 by default run on port 80, port number can be customise too.

Step 23: Nginx is another Open source Web Server. Follow the same steps as Apache2 Web server.

Reference: https://github.com/tkdhanasekar/kaniyam-devops-course-materials/blob/main/Linux/apache-local-installation.md

Thank you!

Linux Ubuntu 22.04.4 LTS (Jammy Jellyfish)-Installation on Mac OS

Step 1: Downloand the link https://cdimage.ubuntu.com/jammy/daily-live/current/

Step 2: Click on ” 64-bit PC (AMD64) desktop image

Step 3 : Go to Downloads folder, Click on jammy-desktop-arm64.iso – click open

What s UTM?

  • UTM is Universal Turing Machine.
  • UTM (based on QEMU), is fully featured system emulator and Virtual machine host for iOS and MacOS
  • QEMU is free and open source emulator.
  • UTM allows you run Windows, Linux and more on your Mac, iPhone and iPad.
  • UTM runs only on MacOS(11.0 or later).
  • If your Mac uses an Apple Silicon (M1 or M2) chip, you can virtualize a copy of macOS that is compiled for ARM64 (aarch64) unmodified. This means that you can run another copy of macOS (or as many as the system memory allows) directly on your Mac CPU.
  • if you try to run a copy of Windows that is compiled for x86 or AMD64 on an Apple Silicon Mac, you cannot use virtualization. This is because the Windows OS is compiled for a different architecture (which is x86 or AMD64) while Apple Silicon is using ARM64 (aarch64). Instead, you have to use emulation.

Installing UTM

There are two ways to install UTM:

  • Through the Mac App Store
  • Direct download from https://mac.getutm.app
  • The only difference between the two methods is for the Mac App Store, you need to pay $10 while the direct download is free.

Once the UTM package is downloaded, drag it onto the Applications folder:

Step 4: on ” Create a new Virtual machine”

Step 5: Click on Linux

Step 6: Click on Virtualize

Step 7: Click on Continue

Step 8: CPU core is 4, click on continue

Step 9: Click Downloads and continue

Step 10: Click on icon ” Install Ubuntu 22.04.4 LTS

Step 11: Click on Try or Install Ubuntu

Step 12: Select English, click to continue

Step 13: Select on English(US), Click on continue

Step 14: Select either Normal installation or Minimal installation, click on continue

Step 15: Select ” Something else” and click on continue

Step 16: Select the free space check box, New Partition Table is highlighted, click on it.

Step 17: Create a partition for root – “/ ” is root.

Step 18:

Step 19: Create a partition for “swap area”

Step 20: Create a partition for EFI system

Step 21: Keep the cursor and check the box on ” /dev/vda1 ext4 / , click “Install Now”

Step 22: Click on Continue

Step 23: Click on Continue

Step 24: Mention Username, password and click on continue

Step 25: Click on Continue

Step 26: Ubuntu Welcome screen will appear

Step 27:

Step 28:

Step 29:

Step 30: Top Left most corner of your screen, Click on Power off icon, select Power off…

Step 31: Select Power off

Step 32: Click ok

Step 33: Top left most corner select CD/DVD :

Step 34: Select Eject

Step 35:

Step 36: Click on UserName

Step 37: Type Password

Ubuntu 22.04.4 Screen appears, Ready to Explore!!!

Thank You!!

Linux Ubuntu 22.04.4 LTS (Jammy Jellyfish)-Installation on Mac OS

Step 1: Downloand the link https://cdimage.ubuntu.com/jammy/daily-live/current/

Step 2: Click on ” 64-bit PC (AMD64) desktop image

Step 3 : Go to Downloads folder, Click on jammy-desktop-arm64.iso – click open

What s UTM?

  • UTM is Universal Turing Machine.
  • UTM (based on QEMU), is fully featured system emulator and Virtual machine host for iOS and MacOS
  • QEMU is free and open source emulator.
  • UTM allows you run Windows, Linux and more on your Mac, iPhone and iPad.
  • UTM runs only on MacOS(11.0 or later).
  • If your Mac uses an Apple Silicon (M1 or M2) chip, you can virtualize a copy of macOS that is compiled for ARM64 (aarch64) unmodified. This means that you can run another copy of macOS (or as many as the system memory allows) directly on your Mac CPU.
  • if you try to run a copy of Windows that is compiled for x86 or AMD64 on an Apple Silicon Mac, you cannot use virtualization. This is because the Windows OS is compiled for a different architecture (which is x86 or AMD64) while Apple Silicon is using ARM64 (aarch64). Instead, you have to use emulation.

Installing UTM

There are two ways to install UTM:

  • Through the Mac App Store
  • Direct download from https://mac.getutm.app
  • The only difference between the two methods is for the Mac App Store, you need to pay $10 while the direct download is free.

Once the UTM package is downloaded, drag it onto the Applications folder:

Step 4: on ” Create a new Virtual machine”

Step 5: Click on Linux

Step 6: Click on Virtualize

Step 7: Click on Continue

Step 8: CPU core is 4, click on continue

Step 9: Click Downloads and continue

Step 10: Click on icon ” Install Ubuntu 22.04.4 LTS

Step 11: Click on Try or Install Ubuntu

Step 12: Select English, click to continue

Step 13: Select on English(US), Click on continue

Step 14: Select either Normal installation or Minimal installation, click on continue

Step 15: Select ” Something else” and click on continue

Step 16: Select the free space check box, New Partition Table is highlighted, click on it.

Step 17: Create a partition for root – “/ ” is root.

Step 18:

Step 19: Create a partition for “swap area”

Step 20: Create a partition for EFI system

Step 21: Keep the cursor and check the box on ” /dev/vda1 ext4 / , click “Install Now”

Step 22: Click on Continue

Step 23: Click on Continue

Step 24: Mention Username, password and click on continue

Step 25: Click on Continue

Step 26: Ubuntu Welcome screen will appear

Step 27:

Step 28:

Step 29:

Step 30: Top Left most corner of your screen, Click on Power off icon, select Power off…

Step 31: Select Power off

Step 32: Click ok

Step 33: Top left most corner select CD/DVD :

Step 34: Select Eject

Step 35:

Step 36: Click on UserName

Step 37: Type Password

Ubuntu 22.04.4 Screen appears, Ready to Explore!!!

Thank You!!

PostgreSQL Database Commands : DDL

1. How to list the database names in postgreSQL?

Syntax

\l

  • Default database available in postgreSQL are: Postgres, template 0 and template 1
  • payilagam is user defined database

2. How to create a database ?

Syntax

The basic syntax of CREATE DATABASE statement is as follows −

CREATE DATABASE dbname;

3. How to swich connection to a new Database?

\c database name

Old Database name is “payilagam”, been switch to new database name “java” as shown above.

4. How to create a schema name in postgresql Database?

Syntax: CREATE SCHEMA [IF NOT EXISTS] schema_name;

5. How to list the schema names?

\dn

Schema names are like package name in java. basics, online are user defined schema name in ‘payilagam’ Database. public is default schema name

SQL commands are like instructions to a table.

  • It is used to interact with the database with some operations.
  • It is also used to perform specific tasks, functions, and queries of data.
  • SQL can perform various tasks like creating a table, adding data to tables, dropping the table, modifying the table, set permission for users.

These SQL commands are mainly categorized into five categories: 

  • DDL – Data Definition Language
  • DQL – Data Query Language
  • DML – Data Manipulation Language
  • DCL – Data Control Language
  • TCL – Transaction Control Language

DDL (Data Definition Language)

  • DDL or Data Definition Language actually consists of the SQL commands that can be used to define the database schema.
  • It simply deals with descriptions of the database schema and is used to create and modify the structure of database objects in the database.
  • DDL is a set of SQL commands used to create, modify, and delete database structures but not data.
  • These commands are normally not used by a general user, who should be accessing the database via an application.

List of DDL commands: 

  • CREATE: This command is used to create the database or its objects (like table, index, function, views, store procedure, and triggers).
  • DROP: This command is used to delete objects from the database.
  • ALTER: This is used to alter the structure of the database.
  • TRUNCATE: This is used to remove all records from a table, including all spaces allocated for the records are removed.
  • COMMENT: This is used to add comments to the data dictionary.
  • RENAME: This is used to rename an object existing in the database.

DDL commands: CREATE

6. How to create table in PostgreSQL Database?

SYNTAX

CREATE table table_name(column 1 datatype size, column 2 datatype size, column 3 datatype size….. column N datatype size);

Here table_name is name of the table, column is the name of column.

7. How to describe the table in postgreSQL?

\d table_name

DDL commands: ALTER

  • The ALTER TABLE statement in SQL is used to add, remove, or modify columns in an existing table.
  • The ALTER TABLE statement is also used to add and remove various constraints on existing tables.

8. How to ALTER table Add column statement?

SYNTAX

ALTER TABLE table_name add column column_name datatype(size);

9. How to ALTER table DROP column statement?

SYNTAX

ALTER TABLE table_name drop column column_name ;

10. How to ALTER table name?

SYNTAX

ALTER TABLE table_name rename to new table_name;

11. How to ALTER column name?

SYNTAX

ALTER TABLE table_name rename column column_name to new column_name;

Before altering the column name:-

After altering the column name:-

DDL commands: DROP

Drop is used to delete the whole database or just a table.

12. How to drop a table?

SYNTAX

DROP table table_name;

DDL commands: TRUNCATE
  • TRUNCATE is used to delete the data inside the table not the whole table.
  • TRUNCATE statement is a Data Definition Language (DDL) operation that is used to mark the extent of a table for deallocation (empty for reuse).

13. How to TRUNCATE a table?

SYNTAX

TRUNCATE table table_name;

DROP vs TRUNCATE
  • Truncate is normally ultra-fast and it’s ideal for deleting data from a temporary table.
  • Truncate preserves the structure of the table for future use, unlike drop table where the table is deleted with its full structure.
  • Table or Database deletion using a DROP statement cannot be rolled back, so it must be used wisely.

Thank you!!

References:

https://www.geeksforgeeks.org/sql-drop-truncate/?ref=lbp

PostgreSQL installation on Mac

Installing Postgres.app

  • Download   ➜   Move to Applications folder   ➜   Double ClickIf you don’t move Postgres.app to the Applications folder, some features may not work (more info)
  • Click “Initialize” to create a new server
  • Configure your $PATH to use the included command line tools (optional):sudo mkdir -p /etc/paths.d &&
    echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp

Step1:- Type in url, or copy – https://www.postgresql.org/

click on downlad->

Step2:- click on macOS

Step 3:- Scroll little down the page, click on link Postgres.app

Step 4:- click on downloads icon.

Step 5:- click on latest release Download icon.

Step 6:- It takes few seconds to download and is visible on top roght side of the screen with down arrow in blue color. Double click on pop_up box.

Step 7:- Once you double click on download box, postgres blue dialogue box will appear with symbol of elephant and application folder as shown below. place the cursor on elephant and drag the elephant to application.

Step 8:- Go to down left most screen with happyface(Finder)- click on it, screen will appear, click on Applications, scroll down to see Postgres. click on it.

Step 9:- Click on open.

Step 10:- Three Default database icons will dispaly after initialisation.

Step 11:- Open Terminal on mac and type to configure your path:

sudo mkdir -p /etc/paths.d &&
echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp

Step 12:- Give your System password.

Step 13:- close the teminal and quit the terminal.
go to launchpad -> serach for terminal-> click on terminal-> terminal will open.

postgreSQL app is in Running state:

Step 14:- open the terminal/command prompt and type

     sudo -i -u postgres

Step 15:- Type System Password

Step 16:- type psql, your psql version and default database will dispaly as postgres=#

later you can proceed with creating your own database, schema,table name!!!

Thank you!

PostgreSQL

  • PostgreSQL is an advanced, enterprise-class, and open-source relational database system.
  • PostgreSQL supports both SQL (relational) and JSON (non-relational) querying.
  • PostgreSQL is a powerful, open source object-relational database system that uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads.
  • PostgreSQL is a highly stable database backed by more than 20 years of development by the open-source community.
  • PostgreSQL is used as a primary database for many web applications as well as mobile and analytics applications.

History of PostgreSQL

  • The PostgreSQL project started in 1986 at Berkeley Computer Science Department, University of California.
  • The project was originally named POSTGRES, in reference to the older Ingres database which also developed at Berkeley. The goal of the POSTGRES project was to add the minimal features needed to support multiple data types.
  • In 1996, the POSTGRES project was renamed to PostgreSQL to clearly illustrate its support for SQL. Today, PostgreSQL is commonly abbreviated as Postgres.
  • Since then, the PostgreSQL Global Development Group, a dedicated community of contributors continues to make the releases of the open-source and free database project.
  • Originally, PostgreSQL was designed to run on UNIX-like platforms. And then, PostgreSQL was evolved run on various platforms such as Windows, macOS, and Solaris.

Common Use cases of PostgreSQL

The following are the common use cases of PostgreSQL.

  • A robust database in the LAPP stack -LAPP stands for Linux, Apache, PostgreSQL, and PHP (or Python and Perl). PostgreSQL is primarily used as a robust back-end database that powers many dynamic websites and web applications.
  • General purpose transaction database -Large corporations and startups alike use PostgreSQL as primary databases to support their applications and products.
  • Geospatial database-PostgreSQL with the PostGIS extension supports geospatial databases for geographic information systems (GIS).

Language support

PostgreSQL support most popular programming languages:

  • Python
  • Java
  • C#
  • C/C+
  • Ruby
  • JavaScript (Node.js)
  • Perl
  • Go
  • Tcl

Many companies have built products and solutions based on PostgreSQL. Some featured companies are Apple, Fujitsu, Red Hat, Cisco, Juniper Network, Instagram, etc.

List of various features found in PostgreSQL

  • Data Types
    • Primitives: Integer, Numeric, String, Boolean
    • Structured: Date/Time, Array, Range / Multirange, UUID
    • Document: JSON/JSONB, XML, Key-value (Hstore)
    • Geometry: Point, Line, Circle, Polygon
    • Customizations: Composite, Custom Types
  • Data Integrity
    • UNIQUE, NOT NULL
    • Primary Keys
    • Foreign Keys
    • Exclusion Constraints
    • Explicit Locks, Advisory Locks
  • Concurrency, Performance
    • Indexing: B-tree, Multicolumn, Expressions, Partial
    • Advanced Indexing: GiST, SP-Gist, KNN Gist, GIN, BRIN, Covering indexes, Bloom filters
    • Sophisticated query planner / optimizer, index-only scans, multicolumn statistics
    • Transactions, Nested Transactions (via savepoints)
    • Multi-Version concurrency Control (MVCC)
    • Parallelization of read queries and building B-tree indexes
    • Table partitioning
    • All transaction isolation levels defined in the SQL standard, including Serializable
    • Just-in-time (JIT) compilation of expressions
  • Reliability, Disaster Recovery
    • Write-ahead Logging (WAL)
    • Replication: Asynchronous, Synchronous, Logical
    • Point-in-time-recovery (PITR), active standbys
    • Tablespaces
  • Security
    • Authentication: GSSAPI, SSPI, LDAP, SCRAM-SHA-256, Certificate, and more
    • Robust access-control system
    • Column and row-level security
    • Multi-factor authentication with certificates and an additional method
  • Extensibility
    • Stored functions and procedures
    • Procedural Languages: PL/pgSQL, Perl, Python, and Tcl. There are other languages available through extensions, e.g. Java, JavaScript (V8), R, Lua, and Rust
    • SQL/JSON path expressions
    • Foreign data wrappers: connect to other databases or streams with a standard SQL interface
    • Customizable storage interface for tables
    • Many extensions that provide additional functionality, including PostGIS
  • Internationalisation, Text Search
    • Support for international character sets, e.g. through ICU collations
    • Case-insensitive and accent-insensitive collations
    • Full-text search

Disadvantages of PostgreSQL

  • Postgres is not owned by one organization. … 
  • Changes made for speed improvement requires more work than MySQL as PostgreSQL focuses on compatibility.
  • Many open source apps support MySQL, but may not support PostgreSQL.
  • On performance metrics, it is slower than MySQL.

Thank you!!

References:

https://www.postgresql.org/about/

ArrayList vs HashSet

ArrayList HashSet

 Difference between HashSet and ArrayList in Java 

HashSetArrayList
ImplementationSetList
Internal implementationbacked by HashMapbacked by Array
DuplicatesUnique valuespermit duplicates
OrderingUnorderedMaintains order
Index based  NoYes
  • Syntax: ArrayList:-

ArrayList list=new ArrayList();

  • Syntax: HashSet:-

HashSet set=new HashSet();

  1. Implementation: Implementation : ArrayList implements List interface while HashSet implements Set interface in Java.
  2. Internal implementation: ArrayList is backed by an Array while HashSet is backed by an HashMap.
  3. Duplicates : ArrayList allows duplicate values while HashSet doesn’t allow duplicates values.
  4. Constructor : ArrayList have three constructor which are ArrayList(), ArrayList(int capacity) ArrayList(int Collection c) while HashSet have four constructor which are HashSet(), HashSet(int capacity), HashSet(Collection c) and HashSet(int capacity, float loadFactor)
  5. Ordering : ArrayList maintains the order of the object in which they are inserted while HashSet is an unordered collection and doesn’t maintain any order.
  6. Indexing : ArrayList is index based we can retrieve object by calling get(index) method or remove objects by calling remove(index) method while HashSet is completely object based. HashSet also does not provide get() method.
  7. Null Object: ArrayList not apply any restriction, we can add any number of null value while HashSet allow one null value.

Basic Operation’s Time complexity :-  

          ArrayList common operation’s time complexity

         add() – takes O(1) time;( tbd)?
         get() – it takes constant time O(1);
         remove() –it takes linear time complexity O(n) . It iterate the entire array to find the element qualifying for removal.
        contains() – It also take linear time complexity O(n).

For HashSet, the add(), remove() and contains() operations cost constant O(1) time

Converting ArrayList to HashSet:

Thank you!!

References: https://www.geeksforgeeks.org/difference-between-arraylist-and-hashset-in-java/

https://www.tutorialspoint.com/convert-an-arraylist-to-hashset-in-java

String Methods

JAVA STRING CHARAT()

  • The Java String class charAt() method returns a char value at the given index number.
  • The index number starts from 0 and goes to n-1, where n is the length of the string.
  • It returns StringIndexOutOfBoundsException, if the given index number is greater than or equal to this string length or a negative number.
Signature

public char charAt(int index)  

  • Method Name = charAt
  • Parameter = int index
  • Return type  = char
  • The method accepts index as a parameter.
  • The starting index is 0.
  • It returns a character at a specific index position in a string.
  • It throws StringIndexOutOfBoundsException if the index is a negative value or greater than this string length.

Example

Java String length()

The Java String class length() method finds the length of a string. The length of the Java string is the same as the Unicode code units of the string.

Signature

public int length()  

  • Method Name = length()
  • Parameter =
  • Return type  = int
Returns

Length of characters. In other words, the total number of characters present in the string.

EXAMPLE

Java String isEmpty()

The Java String class isEmpty() method checks if the input string is empty or not. Here empty means the number of characters contained in a string is zero.

Signature

public boolean isEmpty()    

  • Method Name = isEmpty()
  • Parameter =
  • Return type  = boolean (true if length is 0 otherwise false)
Returns

true if length is 0 otherwise false.

Example
Java String trim()

The Java String class trim() method eliminates leading and trailing spaces. The Unicode value of space character is ‘\u0020’. The trim() method in Java string checks this Unicode value before and after the string, if it exists then the method removes the spaces and returns the omitted string.

The string trim() method doesn’t omit middle spaces.
Signature

public String trim()  

  • Method Name = trim()
  • Parameter =
  • Return type  = String
Returns

string with omitted leading and trailing spaces

EXAMPLE
Java String toLowerCase()

The java string toLowerCase() method returns the string in lowercase letter. In other words, it converts all characters of the string into lower case letter.

The toLowerCase() method works same as toLowerCase(Locale.getDefault()) method. It internally uses the default locale.

Signature

There are two variant of toLowerCase() method. The signature or syntax of string toLowerCase() method is given below:

  1. public String toLowerCase()  
  2. public String toLowerCase(Locale locale)  

The second method variant of toLowerCase(), converts all the characters into lowercase using the rules of given Locale.

  • Method Name = toLowerCase()
  • Parameter =
  • Return type  = String in lowercase letters
Returns

string in lowercase letter.

EXAMPLE

Java String toUpperCase()

The java string toUpperCase() method returns the string in uppercase letter. In other words, it converts all characters of the string into upper case letter.

The toUpperCase() method works same as toUpperCase(Locale.getDefault()) method. It internally uses the default locale.

Signature
  1. public String toUpperCase()  
  2. public String toUpperCase(Locale locale)  

The second method variant of toUpperCase(), converts all the characters into uppercase using the rules of given Locale.

  • Method Name = toUpperCase()
  • Parameter =
  • Return type  = String in Uppercase letters
Returns

string in uppercase letter.

EXAMPLE

Java String contains()
  • The Java String class contains() method searches the sequence of characters in this string.
  • It returns true if the sequence of char values is found in this string otherwise returns false.
Signature

public boolean contains(CharSequence sequence)  

  • Method Name = contains()
  • Parameter = CharSequence sequence
  • Return type  = true if the sequence of char value exists, otherwise false.
Parameter

sequence : specifies the sequence of characters to be searched.

Returns

true if the sequence of char value exists, otherwise false.

EXAMPLE

Java String concat
  • The Java String class concat() method  combines string at the end of the string. It returns a combined string. It is like appending another string.
Signature

public String concat(String anotherString)    

  • Method Name = concat()
  • Parameter = string
  • Return type  = combined string
Parameter

anotherString : another string i.e., to be combined at the end of this string.

Returns

combined string

EXAMPLE

Java String startsWith()

The Java String class startsWith() method checks if this string starts with the given prefix. It returns true if this string starts with the given prefix; else returns false.

Signature
  1. public boolean startsWith(String prefix)  
  2. public boolean startsWith(String prefix, int offset)  
Parameter

prefix : Sequence of character

offset: the index from where the matching of the string prefix starts.

Returns

true or false

EXAMPLE

Java String endsWith()

The Java String class endsWith() method checks if this string ends with a given suffix. It returns true if this string ends with the given suffix; else returns false.

Signature

public boolean endsWith(String suffix)   

Parameter

suffix : Sequence of character

Returns

true or false

EXAMPLE

Thank you!!

❌