❌

Normal view

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

Day – 1 in Commands Practice

6 February 2024 at 15:58

Today Learned below commands.

List Commands

ls -> it listed out all the files
ls -l -> it gave long listing items
ls -lh -> it returns items with human readable file size
ls -lS -> it sorted out the files
ls -lSh -> it sorted the files also it returns file with human readable format
ls -R -> returned all the files in the directory

whoami -> shows the current user
hostname -> shows the hostname
hostname -I -> shows the IP address of the user

Date Commands

date -> displayed current date
date –date=”tomorrow” -> prints the tomorrow date
date –date=”3 years ago” -> prints the date 3 years ago.

CAT Commands : Concatenate commands

cat > test1.text -> creates a new file
cat test1.text | less -> show the file in page fize
q -> to quit

ECHO Commands

echo β€œHello world” -> it usually prints the data.

History Commands

history -> it displays the last 1000 commands executed in our machine. we can increase the limit
history 10 -> executes last 10 commands
history | head -> shows first 10 commands
history | tail -> last 10 commands
history !1000(event) -> executed the specified event command.

Remove command

rm -i test1.text -> it asks user permission whether to delete this or not
rm test1.text -> removes the files
rm * text -> removes all the files which are text file type.

Manual command

man ls -> shows all the information about ls command
man date -> displayes all the info about date command
z -> to down the page.
w -> to go up in the page.

Day – 1 in Commands Practice

6 February 2024 at 15:58

Today Learned below commands.

List Commands

ls -> it listed out all the files
ls -l -> it gave long listing items
ls -lh -> it returns items with human readable file size
ls -lS -> it sorted out the files
ls -lSh -> it sorted the files also it returns file with human readable format
ls -R -> returned all the files in the directory

whoami -> shows the current user
hostname -> shows the hostname
hostname -I -> shows the IP address of the user

Date Commands

date -> displayed current date
date –date=”tomorrow” -> prints the tomorrow date
date –date=”3 years ago” -> prints the date 3 years ago.

CAT Commands : Concatenate commands

cat > test1.text -> creates a new file
cat test1.text | less -> show the file in page fize
q -> to quit

ECHO Commands

echo β€œHello world” -> it usually prints the data.

History Commands

history -> it displays the last 1000 commands executed in our machine. we can increase the limit
history 10 -> executes last 10 commands
history | head -> shows first 10 commands
history | tail -> last 10 commands
history !1000(event) -> executed the specified event command.

Remove command

rm -i test1.text -> it asks user permission whether to delete this or not
rm test1.text -> removes the files
rm * text -> removes all the files which are text file type.

Manual command

man ls -> shows all the information about ls command
man date -> displayes all the info about date command
z -> to down the page.
w -> to go up in the page.

Ansible

By: Kannan
31 October 2023 at 15:29

Ansible Installation

  • Ansible Installation steps on Ubuntu machine
sudo apt update
sudo apt-add-repository ppa:ansible/ansible
sudo apt update
apt install ansible -y
sudo apt install ansible -y
ansible --version

If not able to get the ansible version follow the below steps

Image description

  • Virtual Machine setup

Download and install kvm and install ubuntu 22.04 server edition and centos 7 minimal server with 1GB RAM.

https://ubuntu.com/download/server#downloads
http://isoredirect.centos.org/centos/7/isos/x86_64/

  1. create a new virtual machine

  2. Select Local install media and select the downloaded ISO Package.

  3. set memory as "1024" CPU as "1"

  4. set Disk image as "25" modify the name and Click Finish to complete the process.

  5. Once done select the "Network&Hostname" Enable the Ethernet port.create the user account and set the root password.
    Follow the below cmds to assign different IP when clone

echo -n > /etc/machine-id
rm /var/lib/dbus/machine-id
ln -s /etc/machine-id /var/lib/dbus/machine-id

Ansible Config for target machine

  • Enter the inventory and hosts entry on the ansible machine.

Image description

  • Get the ssh keygen (.ssh) and find the target machine IP using (hostname -I)

  • Copy the source machine ssh public key to the target machine

ssh-copy-id -i id_rsa.pub kannan@192.168.122.133
  • If you want to change the hostname of the target machine go with the below cmd
sudo hostnamectl set-hostname ubuntu-node-1
exec bash
  • Ping the target machine from ansible machine
ansible all -m ping
  • Find the OS version of the target machine from ansible machine
ansible all -a "cat /etc/os-release"
  • To provide root privileges for the users

Image description

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
sudo su-
usermod -aG sudo kannan
sudo su - kannan
  • Let install Apache server(httpd) using adhoc cmds
ansible ubuntu -i hosts -m apt -a "name=apache2 state=present" --sudo
ansible all --list-hosts

ansible all -m package -a "name=httpd state=present"
ansible centos -m package -a "name=httpd state=present" -b

 ansible centos -m ansible.builtin.service -a "name=httpd state=started" -b

ansible ubuntu -m file -a "path=/home/kannan/test mode=755 state=directory" -b

  • Once Apache is installed on the Target machine bydefault its not active we need to enable,start and find the staus from ansible machine.
systemctl enable httpd
systemctl start httpd
systemctl status https

Now apache is running on the target machine.
We have done these all from ansible machine and get the output on target machine via ansible.

❌
❌