❌

Normal view

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

DevOps_Docker_Basic comments_08-09-23

By: Rizwan
8 September 2023 at 17:47

We are pulling some images from douckerhub and running into our localhost using the port number

we are gonna run the image using two ways that one is port allocation and default port allocation

Now add the group to docker for avoid the root permission $ sudo usermod -aG docker $USER and $ newgrp dockerto enable the docker

Search the images using docker search imagename ex docker search dnadna/apple

Then pull the image from outside

using the commend $ docker pull imagename (ex) $ docker pull dnana/apple and now see the existing images using $ docker images

Type -1 port allocation

now run he image once the image runes it will generate the combination of numerical and alphabetical id then its will generate the container id as well. we can see the images container status and id via $ container ps for running container and $ container ps -al is for exited as well of active container

Run the images $ docker run -d –name choosingname -p portnumber imagename (ex) $ docker run -d –name app1 -p 8080:80 dnadna/apple

Now the container runed and we see that using $dockerimage now we can see that via http:localhost:8080:80 in browser and output as

Type 2 Default port allocation by system

run without assigning port details

$ docker run -d -P –name chosingname dnadna/bolt

Now we can the default port as 32777 then http:localhost:32777 in browser then we can see

Here we can access the container and can change the out put when editing the source file here is html file in this we need to install the not inbuild application inside the container

ex

we can editing the index.html then we can change our desirable output

DevOps_Docker_Installation_Sept 07_23

By: Rizwan
7 September 2023 at 17:03

Installing Docker package and running basic commends.

First update the system as of today using the commend $ sudo apt-get update

Install the docker dependencies using the commend $ sudo apt-get install ca-certificates curl gnupg -y

Add Docker’s official GPG key using the commend $ sudo install -m 0755 -d /etc/apt/keyrings

$ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg –dearmor -o /etc/apt/keyrings/docker.gpg

Gave the permission using the commend $ sudo chmod a+r /etc/apt/keyrings/docker.gpg

$ echo \
β€œdeb [arch=”$(dpkg –print-architecture)” signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
β€œ$(. /etc/os-release && echo β€œ$VERSION_CODENAME”)” stable” | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Now update system using the commend $ sudo apt-get update

Install docker – plugins using the commend $ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Install docker-compose plugin $ sudo curl -L β€œhttps://github.com/docker/compose/releases/download/v2.21.0/docker-compose-$(uname -s)-$(uname -m)” -o /usr/local/bin/docker-compose

$ ls -lsh /usr/local/bin/docker-compose

Now give the permission using the commend $ chmod +x /usr/local/bin/docker-compose

sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

Now check the version of docker using the commend $ sudo docker version

Now check the version of docker using the commend $ sudo docker compose version

We need to enable the docker like booting up..we need to enable and restart the docker using the commend $ sudo systemctl restart docker and $ sudo systemctl enable docker // $ sudo systemctl status docker –no-pager -l

Once installed the docker app now create the group using the commend $ sudo groupadd docker…then create the user commend $ sudo usermod -aG docker $USER

Now activate the group $ newgrp docker

Update the system using the commend $ sudo apt update

We can saw the downloaded docker images using the commend $ docker images and we can see the running container using $ docker ps

Now we can pull the images using pull commend $ docker pull Nameoftheapplication before we can view the existing images using search commend $ docker search Nameoftheapplication

Now run the image using the commend $ docker run -d –name choosingname -p 8081:80 Nameoftheapplication ex $ docker run -d –name Kaniyam_apache2 -p 8080:80 ubuntu/apache2

once done the id will id will be generated in system

we can view the backend running containers using the commend $ docker ps

I we want to del the container then first stop the container using the commend of $ docker stop kaniyam_apache2 then delete

Removing the container using the commend $ sudo docker rm 353f1b70d2bc or $ sudo docker rm choosingname

Now we can execute the commend of in browser http://IPadress:8080/ its basically localhost:post

DevOps_GITHUB_3rd week of Aug

By: Rizwan
28 August 2023 at 18:44

The first day of basic knowledge about github..

We need to create the repo by clicking new or + and naming as projects1 and select which its need to public or private and we are creating tokens to help us push the projects into git hub

first create the repto using new or + in repo filed

Settings >> Developer settings >> Personal access tokens >> classic token once followed the path then write up our desc and giving the access like delete,repo,admin etc by selecting the boxes to access commends once done it will end up as generating token of combined alphabetical and number combination of 50+ letters and number. copy and paste it somewhere cus we cant find out once we close the window. here we can change the access of the token by revoke token as well. also we can give the days to be active the tokens

First install the git into System using the commend $ sudo apt install git then start the Git hub using the commend of $ git init then get a clone using the commend $ git clone our link(which we are finding out from the http in repo) (ex)$ git clone https://github.com/Rizwanbharathi/project4.git

once we cloned the github we could see the project4 in out system than change the directory using the commend of $ cd Directoryname (etc) $ cd project4 then create some testing file of inside the directory by using the commend of cat > testfile.txt and cat > test.txt

when we are using the commed of $ git status we can see the files are red cus we didnot commit this into our virtual host so Now we need to add this into our virtual host by $ git add . here . contains every directory or files which we have worked on the system now we can see all ready to commit by using the commend of $ git status all dir all green

finally commit this using the $ git commit -m β€œtest file to add” ist will commit every file that we have worked on it now conf the file using the commend $ git config ourgmailid (etc) $ git confi rizwanbharathi@gmail.com is we using first time it will ask our user name and password for conf then once its done we need to push this into main using the commend @ git push -u origin main

now we can saw our testfiles in our git hub repo page

Installing Drupal using the LAMP

By: Rizwan
28 August 2023 at 18:07

We are installing Drupal using the Linux, apache2,Mariadb, php.

STEP-1 Maria db

First we are creating Drupal user and Drupal database then give privileges

Download the file using the commend $ wget https://www.drupal.org/download-latest/zip and Unzip the file

then move the file into /var/www/html/ where we gonna execute the so we will gave the execute permission for the particular file and changing the ownership mode

STEP -2

Now configure the executable file that creating new conf file into /etc/apache2/site-available the commend $ sudo vim /etc/apache2/sites-available/drupal.conf and write up

<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html/drupal-10.1.2/
ServerName drupal.in
<Directory /var/www/html/drupal-10.1.2/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
~              

Now map the IP into the executable file

STEP – 3

Now enable the virtual host using the commends

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

Now Execute the link in browser http://drupal.in/

DevOps_Linux_emacs_16-07-23

By: Rizwan
16 August 2023 at 17:59

emacs commend is common commend like the vim commend but here we could store our day to activity and can use as tracking purpose

first install it using $ sudo apt install amacs then confi the bashrc commend using $ vim ~/.bashrc and add the alias emacs=’emacs -nw –color=no’

Now create the file using $ emacs test.txt (ex) $ emacs sample.txt now add some input and save the file using cnt +x and cnt + c and its will ask whart need to be execute y-yes,n-no

ALT SHIFT+x -EDIT
ALT SHIFT < -FIRST LINE ALT SHIFT > -LAST LINE
ALT +x linum-mode β€” Adding the number for the lines
Select the line using the mouse courser and copy it cntl + w and paste it cntl + y
Now home key used to go for the staring of the line and end using the end of the line

we can use the **topic and track the doto list as well as expend and un-expend the name and track the datas

DevOps_Site creation_php_15-08-23

By: Rizwan
16 August 2023 at 17:31

Creating site using php.

Here we are creating the site using the php commends

Trying to install the php using ~$ sudo add-apt-repository ppa:ondrej/php but its not installed due to ubuntu issues(unable to locate the package) . The php package for ubuntu 23.01 can’t installed the package so first we removed unwanted packages using $ sudo apt remove

when we trying to update the system using $ sudo apt update got the error of previous php broken package error that doesn’t have the releases file in ubuntu so now removed the broken package of php

Now trying to install it via some modified commends which is $ 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 now see the version of php using $ php –version

php installed successfully and creating the site using php

Now the issues resolved and successfully installed the php now creating the dpuser in mysql using MariaDB [(none)]> CREATE USER β€˜wpuser’@’localhost’ IDENTIFIED BY β€˜password123’; (ex) MariaDB [(none)]>CREATE USER β€˜rizwan’@’localhost’ IDENTIFIED BY β€˜password123’; once the database created now create the MariaDB [(none)]> CREATE DATABASE wpdb; (EX) MariaDB [(none)]> CREATE DATABASE Rizwan;

Now give the permission for the databases using the commend GRANT ALL PRIVILEGES ON wpdb.* TO β€˜wpuser’@’localhost’; (ex) GRANT ALL PRIVILEGES ON Rizwan.* TO β€˜rizwan’@’localhost’; now give FLUSH PRIVILEGES; for granting the permission for the user

Set the IP address and the server ip using the commend of $ vim hosts and mapp the ip address with concern sever

now back to localhost and here confi. the wordpress.conf using the commend $ sudo vim /etc/apache2/sites-available/wordpress.conf

there need to write the arguments format

<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html/wordpress
ServerName <server_ip>
<Directory /var/www/html/wordpress/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

:wq! save and exit

ex

Now enable the virutual hosts using the commend of $ sudo a2ensite wordpress.conf and $ sudo systemctl reload apache2 then $ sudo a2enmod rewrite and finally $ sudo systemctl restart apache2

now we can see our server ip in browser which is http://server_ip (ex) http://rizwan.in/

Now set the default setting and hit the let go we will see our inputs

Creating site using php.

Here we are creating the site using the php coomends

first install the php package for ubuntu 23.01 cant installed the package so first we removed unwanted packages using $ sudo apt remove

Now the issues resolved and succefully installed the php now creating the dpuser in mysql using MariaDB [(none)]>CREATE USER β€˜wpuser’@’localhost’ IDENTIFIED BY β€˜password123’; (ex)

DevOps_Linux_Cronjob_12-08-23

By: Rizwan
13 August 2023 at 16:46

Automated Remote Backup and Cron job

Install the ssh package using ~$ sudo apt install sshpass this package helps to execute automated password

Create the empty file using $ touch .filename and right this filename using $ vim .filename insert (i)and enter the password inside the file and save(esc) :wq!

now automate the password using $ sshpass -f β€œ.filenameβ€˜ and we can execute following our commend(full commend) and it will execute (ex) ~$ sshpass -f”.filename” sudo mysqldump -u root -p database > database_date +"%Y-%B-%d_%R".sql

Create the empty file using $ touch .filename1 and right this filename using $ vim .filename1 insert (i)and enter the password inside the file and save(esc) :wq!

now automate the password using $ sshpass -f β€œ.filename1β€² and we can execute following our commend(full commend) and it will execute (ex) ~$ sshpass -f”.filename” sudo mysqldump -u root -p database > database_date +"%Y-%B-%d_%R".sql

Create the directory and move the file into the directory commend $ Mkdir backup and we use crantob to take backup in particular time frequently by modifing the crontab -e

add this on last line

To run the script every midnight 11.55 P.M

55 23 * * * /bin/bash /path/remote-backup.sh

To run the script every 3 minutes

*/3 * * * * /bin/bash /path/remote-backup.sh

In the backup directory each 3 min the file will be backup

Now assign the path and script by following commend and the output will stored in backup directory commend $ sshpass -f β€œ.secrets1” rsync -arv -e β€œssh -p 2222” backup/ user@user:/path ( ex ) $ sshpass -f β€œ.secrets1” rsync -arv -e β€œssh -p 2222” backup/rizwan@kaniyam.hopto.org/home/rizwan now we are adding this all 3 step in single shell script

Here we need to create the directory of remout.backip where we gonna write the content of each two into same script

!/bin/bash

sshpass -f β€œ.secrets” sudo mysqldump -u root -p –all-databases > all-databases_date +"%Y-%B-%d_%R".sql
mv *.sql backup/
sshpass -f β€œ.secrets1” rsync -arv -e β€œssh -p 2222” backup/ rizwan@kaniyam.hopto.org:/home/rizwan

and save and exit now we need to give permission to execute the commend using $ chmod +x file_name ex $ chmod +x remote-backup.sh

We can see whatever the script written in execution file using cat commend

now we can excute this using the commend of $ sh filename.sh ex $ sh remote-backup.sh

DevOps_Linux_Mariadb_backups and restore_11-08-2023

By: Rizwan
12 August 2023 at 14:20

we will do the backup for single and multiple databases mysql.

First enable binary log to backup and restore the the database using the commend :~$ sudo vim /etc/mysql/mariadb.conf.d/50-server.cnf in log bin as removing # and save

In user@hostname page backup the particular commend calle $ sudo mysqldump -u root -p NAME > NAME.sql (Ex) $ sudo mysqldump -u root -p AAA > AAA.sql

once backup done check with $ ls commend whether is backup or not..if it backup the database will be shown in the interface.
We can view outside of the backup databased using the commed of $ cat name.sqol

Its completed login back to mariadb and delete the database using the commend MariaDB [(none)]> drop database NAME;
Example β€” MariaDB [(none)]> drop database AAA; and exit the mariadb

Create the restore database in mariadb as empty set of database

Once created the restore database now log off the mariadb and back to user@hostname and revert this restore database into the empty database using the commend $ sudo mysql -u root restoreAA < AAA.sql

When we check the restore.sql and it will show the AAA.sql datas inside the mariadb

Multiple databases

DO the backup in user@hostaname via $ sudo mysqldump -u root -p –databases BBB CCC > BC.sql

and delete the databases using the commend drop database BBB and drop database CCC inside the mariadb

Create the create the empty databases at same name CCC and BBB

Same way but here we are backup the databases in combined dataset and restoring in the same manor but it restored in respective databases.

Restore it im user terminal ~$ sudo mysqldump -u root –databases BBB CCC < BC.sql

we can view the original datas inside of the respective databases.

ALL DATABASES

We can backup the all databases using the commend in terminal $ sudo mysqldump -u root –all-databases > all-databases.sql

Back to mariadb and delete the databases using the commend of drop

back to terminal and use the commend to restore $ sudo mysql -u root < all-databases.sql

check back to mariadb we can find the all databases

TIME STAMP

We can restore the databases with time stamp using the commend in terminal $ mysqldump -u root -p BBB > BBB_date +"%Y-%B-%d_%R".sql

Again delete the database using drop commend and create the empty data base in mariadb

Back to terminal and restore the databases using the commend ~$ sudo mysql -u root BBB < BBB_2023-August-12_18:47.sql

Now check back in mariadb will find the original database with datas

COMPRESSING THE DATABASE(size reduction)

we can compress the database using the commend $ sudo mysqldump -u root -p BBB | gzip > BBB.sql.g

but we cant restore the gz file so again we converting the file using the commend :~$ gzip -d BBB.sql.g

UNZIP and UPLOAD BULK DATA is in Mariadb

Download the ZIP file and unzip using t $ unzip file.zip in terminal and uploda the data is in mariadb using the commend MariaDB [(none)]> source /path/filename.sql

LAMP Stack installed with provided comments

DevOps_linux_Mariadb_10_08_23

By: Rizwan
10 August 2023 at 18:01

Using mariadb we are creating database, creating tables, records inserting datas in the tables, deleting the databases

Install it using the commend ~$ sudo apt install mariadb-server mariadb-client

find out the status whether active and enabled using the commend ~$ sudo systemctl status mariadb.service and enabled using the commends $sudo systemctl enable mariadb.service

to set default password for Mariadb is root account using the $ sudo mysql_secure_installation and change the root password

We can $ sudo mysql -u root -p and once give our password this will end up in the mariadb prompt where we gonna create the data base and managing data base.

Create the database using the commend MariaDB [(none)]> create database name;

Show the existing data base using the commend MariaDB [(none)]> show databases;

To edit the created database Mariadb[none]> use ;

Whatever we created those all empty set and if we to feed the dataset will design the dataset using the commend

Creating the table using commend MariaDB [database name]> create table table_name ( number INT NOT NULL, rowname1 VARCHAR(100) NOT NULL, rowname2 VARCHAR(50) );

To feed the table using the commend MariaDB [kaniyam]> INSERT INTO students (id, name, courses) VALUES (β€˜1’, β€˜Rizwan’, β€˜Linux’),(β€˜2’, β€˜Dheeran’, β€˜AWS’),(β€˜1’, β€˜Negha’, β€˜GIT’);

once we ingested the values in table we can see the table using the commend MariaDB [kaniyam]> show kaniyam;

To view the tables == MariaDB [kaniyam]> show tables;

To delete the databases using the commend MariaDB [kaniyam]> drop database kaniyam;

DevOps_SSH Server_09-08-23

By: Rizwan
9 August 2023 at 03:46

ssh-keygen

Login with password and without password using ssh

First we did some demo as provided details. We can login via the user id as per they modified at their end which is included the password/Permission. In root user we can see with W commend that user usage with IP whom ever logged in the particular IP

check whether the ssh installed default or need to install manually using the commend $ sudo systemctl status sshd.service

Once you know if not installed install using this commend $ sudo apt install openssh-server openssh-client

First generate the private and public user key using $ssh-keygen here we had created two key pressing enter to each lines which is public key with end in pub and private key.

based on public key give the cat commend know the key with our username@system-name and based on $ cd .ssh and :~/.ssh$ ls know the keys which ever user in system

We run the user key with password & without password and created the private and public key.

❌
❌