Monday, 20 December 2021

Jenkins cannot delete root-owned files/folders in jenkins-owned directories

 In this post we will discuss abut most frequent issues faced in Jenkins build.

When you try to use docker image to run your jobs you may end up in creating some file which are created by root user ( from Docker image ). In this case from next build onwards we will see some issues to clean old workspace. Even if you try to use cleanUP workspace plugin you will end up with permission issues. 

To avoid this issue please follow below steps
1) Install acl package based on your distribution.

 Debian
apt-get install acl
 Ubuntu
apt-get install acl
 Alpine
apk add acl
 Arch Linux
pacman -S acl
 Kali Linux
apt-get install acl
 CentOS
yum install acl
 Fedora
dnf install acl
2) Follow below steps to clean workspace and apply acl on workspace folder. After this change you will see any file or folder which is created in workspace folder will have complete ownership of jenkins user. 
$ rm -rf workspace # to avoid any inconsistencies in existing files
$ mkdir workspace
$ sudo setfacl -dm 'u:<your_jenkins_user_name>:rwx' workspace

Saturday, 9 October 2021

Linux Technical Interview Questions

In some questions I am encouraging to search online because it will help you practice for

searching more complicated questions in the future

(Good Luck)

1. When you login you get “$” prompt, what is the prompt for root?

#

2. Explain the difference between grep and egrep?

Search online

3. What is the port # for DNS, NTP and NFS?

53,123 and 111/2049

4. What is the configuration file name of DNS and where is it

located?

/etc/named.conf

5. How many new directories will be created after running the

following command

mkdir {a..c}{1..3}

9

6. Your PC is configured with a DNS server address but not the

default gateway. Can the PC access internet?

No

7. What is the difference between IP and Gateway?

Search online

8. Can you assign one static IP to 2 computers, if not then why?

No because it will create IP conflict

9. How to change IPs address to static?

ifconfig x.x.x.x

10. You are trying to ping a server by hostname and you get an error

message, “ping: unknown host …”. What could be the reason and

how to solve the problem so you can ping it by hostname?

Check for /etc/hosts or DNS to see if it has hostname to IP entry

11. Explain the difference between relative and absolute path?

Absolute path starts from / where relative path is your current

directory

12. List 3 different methods of adding user?

Search online

13. What is the command to change file/directory ownership and group?

chown and chgrp

14. List any 3 type of filesystem?

ext4,NTFS and FAT

15. When you login you get a message on the screen. What is the name

of that file and where is it located?

/etc/motd

16. What is /bin directory used for?

Search online

17. What are the different types of DNS Server

Master and secondary

18. How to change a user password?

passwd username

19. What is the version of Redhat Linux you have experience with?

7.4

20. List any 4 linux distributions?

Redhat, CentOS, Ubuntu and SUSE

21. How to logoff from the system?

exit

22. Give any 3 examples of operating systems?

Windows, Linux and MAC

23. How to create a directory?

mkdir

24. Where are the zone files located for DNS service?

/var/named/zonefiles

25. How to check kernel version?

uname –a

26. Which directory has all the configuration files?

/etc

27. How to become root user from a regular user?

su –

28. How many mega bytes in 1 giga bytes?

Search online

29. What is the purpose of having different network ports?

So the communication of each application goes through a dedicated

port

30. How to display first column of a file?

cat filename | awk ‘{print $1}’

31. What is the name of DNS rpm package?

bind

32. What is the difference between nslookup and dig commands?

Search online

33. How to check your user id and group id?

id

34. How to check a file’s permission?

ls –l

35. What is the difference between “kill” and “kill -9” command?

Search online

36. What is subnet?

Search online

37. You are troubleshooting an issue with Redhat support and they

have asked you to send the contents of /etc directory. How and

which method you will use to transfer the contents?

tar (compress) the entire /etc directory and ftp

38. What is root home directory?

/root

39. What is rsyslogd deamon and its purpose?

Search online

40. Your company has terminated a server administrator. What is first

thing as an administrator you should do to enhance the security?

Change root password

41. How to check the computer name or host name in Linux?

hostname

42. Which permission allows a user to run an executable with the

permissions of the owner of that file?

First 3 bits should have x

43. What is the command to untar a tarred file?

untar

44. What is /proc directory used for?

Search online

45. What is the purpose of nsswitch.conf file

It tells the system where to go to resolve hostnames

46. List 3 basic commands to navigate the filesystem?

cd, pwd and ls

47. Which service/daemon should be running on the server that allows

you to connect remotely?

sshd

48. What is the purpose of firewall?

Search online

49. List any 3 IT components?

Hardware, OS and Applications

50. Which directory has all the commands we use, e.g. ls, cd etc.?

/usr/bin or /bin

51. What is the difference between memory, virtual memory and cache?

Search online

52. Which of the following is correct?

a. Hardware  Operating System  Users

b. Operating System  Users  Hardware

c. Database  Hardware  Users

53. Which of the following is a communication command?

o grep

o mail

o touch

o cd

54. How to rename a file or directory?

mv

55. How to change a hostname in Linux?

Search online

56. How to check network interfaces in Linux?

ifconfig

57. Why is “tail –f logfilename” command used most often and what

does it do?

It will output all incoming logs in real time

58. What type of hardware have you worked on?

You should get yourself familiar with Dell, HP and UCS hardware

by going online and check the vendor websites

59. How to sort a file in reverse order?

cat filename | sort –r

60. What is the name of operating system that runs Unix?

Solaris, HP-UX etc.

61. List all byte sizes from smallest to largest?

Search online

62. How to check the total number of partition in Linux?

fdisk -l

63. How to access a linux system from a linux system?

ssh

64. Explain the procedure of bonding 2 NICs or interfaces together?

Search online

65. What is the exact command syntax to list the 5th column of a file

and cut the first 3 letters?

cat filename | awk ‘{print $5}’ | cut –c1-3

66. What is /etc/hosts file used for?

To resolve hostnames with IP address

67. List any 3 options of ‘df’ command and what they are used for?

Search online

68. What is the command to change file/directory permissions?

chmod

69. What is the purpose of pipe (|)?

To combine multiple commands

70. What is /etc directory used for?

For configuration files

71. Which command is used to list files in a directory?

ls –l

72. There is a command which gives you information about other

commands, please explain that command and what is it used for?

man

73. How to delete a file and a directory?

rm filename and rmdir dirname

74. What is the difference between “tail” and “tail -10”?

None

75. List 4 commands to display or read a file contents?

cat, more, less, vi

76. Which command is used to read the top 5 lines of a file?

head -5 filename

77. What are the different commands or methods to write to a file?

echo > filename and vi filename

78. What is swap space and how to check swap space?

Search online

79. What is inode and how to find an inode of a file?

Search online

80. Which file to edit for kernel tuning?

Search online

81. What is the latest version of Redhat?

Search online

82. Name the command to find specific word from a file?

grep word filename

83. You have scheduled a job using crontab but it does not run at the

time you specified, what could be the reason and how would you

troubleshoot?

Check your system time

Check your crontab entry

Check /var/log/messages

84. How to check system hardware information?

dmidecode

85. How to check network interface MAC address?

ifconfig

86. If I don’t want others to read my file1, how to do that?

Remove r from the last 3 bits of file permission

87. What is the purpose of “uniq” and “sed” command?

Search online

88. Which command is used to list the contents of a directory in the

most recent time and in reverse order, meaning the most updated

file should be listed on the bottom?

ls –ltr

89. What is the difference between tar, gzip and gunzip?

Search online

90. What are the different ways to install and OS?

DVD, DVD iso and network boot

91. How to view difference between two files?

diff file1 and file2

92. You noticed that one of the Linux servers has no disk space left,

how would you troubleshoot that issue?

If running LVM then add more disk and extend LVM

If not running LVM then add more disk, create a new partition and

link the new partition to an existing filesystem

93. How to check Redhat version release?

uname –a or /etc/redhat-release

94. What is the difference between TCP and UDP?

Search online

95. What is a zombie process?

Search online

96. How do you search for a pattern/word in a file and then replace

it in an entire file?

sed command

97. Explain the purpose of “touch” command?

To create an empty file

98. If a command hangs, how to stop it and get the prompt back?

Ctrl C

99. Which command is used to count words or lines?

wc

100. How to check the number of users logged in?

who

101. What is the command to view the calendar of 2011?

cal 2011

102. Which command is used to view disk space?

df –h

103. How to create a new group in Linux?

groupadd

104. What is the command to send a message to everyone who is logged

into the system?

wall

105. Which command is used to check total number of disks?

fdisk –l

106. What is an mail server record in DNS?

MX

107. What does the following command line do?

ps -ef | awk '{print $1}' | sort | uniq

List the first column of all running processes, sort them and

remove duplicates

108. You get a call that when a user goes to www.yourwebsite.com it

fails and gets an error, how do you troubleshoot?

Check for user internet

Check to see if user computer has DNS for hostname lookup

Check to see if the server is up that is running that website

Check to see if the server’s web service is running

Check for DNS availability which is resolving that website

109. List 4 different directories in /?

/etc, /bin, /tmp, /home

110. What is the output of the following command:

$tail -10 filename | head -1

It will show the first line from the last 10 lines of a file

111. What are the different fields in /etc/passwd file?

Search online

112. Which command is used to list the processes?

ps –ef

113. What is the difference between “hostname” and “uname” commands?

Hostname will give you system name and uname will give you OS

information

114. How to check system load?

top and uptime command

115. How to schedule jobs?

crontab and at

116. What is the 3rd field when setting up crontab?

Day of the month

117. What is the command to create a new user?

useradd

118. What is the “init #” for system reboot?

6

119. How to restart a service?

systemctl restart servicename

120. How to shutdown a system?

shutdown or init 0

121. What is “ftp” command used for?

To transfer files from one computer to another

122. Explain cron job syntax? First is minute, second is..?

Min, house, day of the month, month, day of the week and command

123. How to delete a package in Linux?

rpm –e packagename

124. What is the file name where user password information is saved?

/etc/shadow

125. Which command you would use to find the location of chmod

command?

which chmod

126. Which command is used to check if the other computer is online?

ping othercomputer

127. Please explain about LAN, MAN and WAN?

Search online

128. How to list hidden files in a directory?

ls –la

129. What is the difference between telnet and ssh?

ssh is secure where telnet is not

130. How to run a calculator on Linux and exit out of it?

bc and quit

131. List any 4 commands to monitor system?

top, df –h, iostat, dmesg

132. You are notified that your server is down, list the steps you

will take to troubleshoot?

Check the system physically

Login through system console

Ping the system

Reboot or boot if possible

133. What is difference between static and DHCP IP?

Search online

134. How to write in vi editor mode?

i = insert, a = insert in next space, o = insert in new line

135. What is the difference between “crontab” and “at” jobs?

crontab is for repetitive jobs where at is for one time job

136. What is vCenter server in VMWare?

Search online

137. What is “dmidecode” command used for?

To get system information

138. What is the difference between SAN and NAS?

Search online

139. What is the location of system logs? E.g. messages

/var/log directory

140. How to setup an alias and what is it used for?

alias aliasname=”command”

It is used to created short-cuts for long commands

141. What is the purpose of “netstat” command?

Search online

142. What are terminal control keys, list any 3?

Crtl C, D and Z

143. Which command(s) you would run if you need to find out how many

processes are running on your system?

ps –ef | wc –l

144. What are the different types of shells?

sh, bash, ksh, csh etc.

145. How to delete a line when in vi editor mode?

dd

146. Which is the core of the operating system?

a) Shell

b) Kernel

c) Commands

d) Script

147. Which among the following interacts directly with system

hardware?

a) Shell

b) Commands

c) Kernel

d) Applications

148. How to save and quit from vi editor?

Shift ZZ or :wq!

149. What is the difference between a process and daemon?

Search online

150. What is the process or daemon name for NTP?

ntpd

151. What are a few commands you would run if your system is running

slow?

top, iostat, df –h, netstat etc.

152. How to install a package in Redhat Linux?

yum install packagename

153. What is the difference between “ifconfig” and “ipconfig”

commands?

ifconfig for Linux and ipconfig for Windows

154. What is the first line written in a shell script?

Define shell

e.g. #!/bin/bash

155. Where is the network (Ethernet) file located, please provide

exact directory location and file name?

/etc/sysconfig/network-scripts/ifcfg-nic

156. Why do we use “last” command?

To see who has logged in the system whether active or logged off

157. What is RHEL Linux stands for?

Search online

158. To view your command history, which command is used and how to

run a specific command?

history and history #

159. What is NTP and briefly explain how does it work and where is the

config files and related commands of NTP?

Search online

160. How to disable firewall in Linux?

Search online

161. How to configure mail server relay for sendmail service?

Edit /etc/mail/sendmail.mc file and add SMART_HOST entry

162. Where is samba log file located?

/var/log/samba

163. What is mkfs command used for?

To create a new filesystem

164. If you create a new group, which file does it get created in?

/etc/group

165. Which file has DNS server information (e.g. DNS resolution)?

/etc/resolv.conf

166. What are the commands you would run if you need to find out the

version and build date of a package (e.g. http)?

rpm –qi http

167. On the file permissions? What are the first 3 bits for and who is

it for?

Read, write and execute. They are used for the owner of the file

168. How to create a soft link?

ln –s

169. How to write a script to delete messages in a log file older than

30 days automatically?

Search online

170. How to quit out of “man” command?

q

171. Which command is used to partition disk in Linux?

fdisk

172. What is the difference between “shutdown” and “halt” command?

Search online

173. What is the exact syntax of mounting NFS share on a client and

also how to un-mount?

Search online

174. What experience do you have with scripting, explain?

if-the, do-while, case, for loop scripts

175. How to get information on all the packages installed on the

system?

rpm –qa

176. Explain VMWare?

Search online

177. You are tasked to examine a log file in order to find out why a

particular application keep crashing. Log file is very lengthy,

which command can you use to simplify the log search using a

search string?

grep for error, warning, failure etc. in /var/log/messages file

178. What is /etc/fstab file and explain each column of this file?

Search online

179. What the latest version of Windows server?

Search online

180. What is the exact command to list only the first 2 lines of

history output?

history | head -2

181. How to upgrade Linux from 7.3 to 7.4?

yum install update

182. How to tell which shell you are in or running?

$0

183. You have tried to “cd” into a directory but you have been denied.

You are not the owner of that directory, what permissions do you

need and where?

- - - - - - - r – x

184. What is CNAME record in DNS?

Entry for hostname to hostname

185. What is the name of VMWare operating system?

ESXi

186. What is the client name used to connect to ESXi or vCenter

server?

vSphere client

187. You get a call from a user saying that I cannot write to a file

because it says, permission denied. The file is owned by that

user, how do you troubleshoot?

Give write permission on the first 3 bits

188. What is the latest version of VMWare?

Search online

189. What is the name of firewall daemon in Linux?

firewalld

190. Which command syntax you can use to list only the 20th line of a

file?

Search online

191. What is the difference between run level 3 and 5?

3 = Boot system with networking, 5 = boot system with networking

and GUI

192. List a few commands that are used in troubleshooting network

related issue?

netstat, tcpdump etc.

193. What is the difference between domain and nameserver?

Search online

194. You open up a file and it has 3000 lines and it scrolled up

really fast, which command you will use to view it one page at a

time?

more or less

195. How to start a new shell. E.g. start a new ksh shell?

Simply type ksh, or bash

196. How to kill a process?

kill processID

197. How to check scheduled jobs?

crontab –l

198. How to check system memory and CPU usage?

free and top

199. Which utility could you use to repair the corrupted file system?

fsck

200. What is the command to make a service start at boot?

systemctl enable servicename

201. How to combine 2 files into 1? E.g. you 3 lines in file “A” and 5

lines in file “B”, which command syntax to use that will combine

into one file of 3+5 = 8 lines

cat fileA >> fileB

202. What is echo command used for?

To output to a screen

203. What does the following command do?

echo This year the summer will be great > file1

It will create a new file “file1” with the content as “This year

the summer will be great”

204. Which file to modify to allow users to run root commands

/etc/sudoers

205. You need to modify httpd.conf file but you cannot find it, Which

command line tool you can use to find file?

find / -name “httpd.conf”

206. Your system crashed and being restarted, but a message appears,

indicating that the operating system cannot be found. What is the

most likely cause of the problem?

The /boot file is most likely corrupted

Tuesday, 5 October 2021

Disable host key checking while connecting ssh in Linux

 

Environment and Prerequisite

  • Linux
  • SSH(OpenSSH)


Host Key Checking

  • When we connect to remote server by using ssh, client compares client’s saved key and remote server’s key to authenticate server.
  • This process prevents from Man-in-the-middle attack.


Disable Host Key Checking When Using SSH

  • Remote host’s key will be added if there is no added key in ~/.ssh/known_hosts.
  • Connect to remote server even though saved key is different from server’s key.


1. Disable when using ssh command

  • Use StrictHostKeyChecking=no option.
ssh -o StrictHostKeyChecking=no [DOMAIN_OR_IP]


2. Edit ssh config file

~/.ssh/config

  • Add option to specific host like below.
Host twpower-private-server
    HostName [IP ADDRESS]
    StrictHostKeyChecking no
    Port 22
    User [USERNAME]
    IdentityFile [IDENTITY KEY FILE]

/etc/ssh/ssh_config

  • There is * in config file. So this disables host key checking to all hosts.
  • /etc/ssh/ssh_config defines all the default settings for the client utilities for all users on that system.
Host *
    StrictHostKeyChecking no


Sunday, 3 October 2021

Git Basic Tutorial

git init

The git init command is the first command that you will run on Git. The git init command is used to create a new blank repository. It is used to make an existing project as a Git project. Several Git commands run inside the repository, but init command can be run outside of the repository.

The git init command creates a .git subdirectory in the current working directory. This newly created subdirectory contains all of the necessary metadata. These metadata can be categorized into objects, refs, and temp files. It also initializes a HEAD pointer for the master branch of the repository.

Command: git init



git add

The git add command is used to add file contents to the Index (Staging Area).This command updates the current content of the working tree to the staging area. It also prepares the staged content for the next commit. Every time we add or update any file in our project, it is required to forward updates to the staging area.

The git add command is a core part of Git technology. It typically adds one file at a time, but there some options are available that can add more than one file at once.

The "index" contains a snapshot of the working tree data. This snapshot will be forwarded for the next commit.

The git add command can be run many times before making a commit. These all add operations can be put under one commit. The add command adds the files that are specified on command line.

The git add command does not add the .gitignore file by default. In fact, we can ignore the files by this command.

Command: git add $(filename)

 

git commit

It is used to record the changes in the repository. It is the next command after the git add. Every commit contains the index data and the commit message. Every commit forms a parent-child relationship. When we add a file in Git, it will take place in the staging area. A commit command is used to fetch updates from the staging area to the repository.

The staging and committing are co-related to each other. Staging allows us to continue in making changes to the repository, and when we want to share these changes to the version control system, committing allows us to record these changes.

Commits are the snapshots of the project. Every commit is recorded in the master branch of the repository. We can recall the commits or revert it to the older version. Two different commits will never overwrite because each commit has its own commit-id. This commit-id is a cryptographic number created by SHA (Secure  Hash  Algorithm) algorithm.

Command: git commit



git clone

In Git, cloning is the act of making a copy of any target repository. The target repository can be remote or local. You can clone your repository from the remote repository to create a local copy on your system.

The git clone is a command-line utility which is used to make a local copy of a remote repository. It accesses the repository through a remote URL.

Command: git clone $(repository link)

 

git stash

Sometimes we want to switch the branches, but we are working on an incomplete part of your current project. we don't want to make a commit of half-done work. Git stashing allows us to do so. The git stash command enables you to switch branches without committing the current branch.

Generally, the stash's meaning is "store something safely in a hidden place." The sense in Git is also the same for stash; Git temporarily saves your data safely without committing.

Stashing takes the messy state of your working directory, and temporarily save it for further use.

Command: git stash

 

git ignore

In Git, the term "ignore" is used to specify intentionally untracked files that Git should ignore. It doesn't affect the Files that already tracked by Git.

Generally, the Ignored files are artifacts and machine-generated files. These files can be derived from your repository source or should otherwise not be committed.

Git ignore files is a file that can be any file or a folder that contains all the files that we want to ignore. The developers ignore files that are not necessary to execute the project. Git itself creates many system-generated ignored files. Usually, these files are hidden files. There are several ways to specify the ignore files. The ignored files can be tracked on a .gitignore file that is placed on the root folder of the repository. No explicit command is used to ignore the file.

There is no explicit git ignore command; instead, the .gitignore file must be edited and committed by hand when you have new files that you wish to ignore. The .gitignore files hold patterns that are matched against file names in your repository to determine whether or not they should be ignored.

There is no command in Git to ignore files; alternatively, there are several ways to specify the ignore files in git. One of the most common ways is the .gitignore file.

Steps to create .gitignore file in linux Step – 1

cat > .gitignore

*.txt

/newfolder/* Step – 2 Press Clt + D Step – 3

git add .gitignore

git commit -m "ignored directory created."

 

git origin master

The term "git origin master" is used in the context of a remote repository. It is used to deal with the remote repository. The term origin comes from where repository original situated and master stands for the main branch.

Master is a naming convention for Git branch. It's a default branch of Git. After cloning a project from a remote server, the resulting local repository contains only a single local branch. This branch is called a "master" branch. It means that "master" is a repository's "default" branch.

In most cases, the master is referred to as the main branch. Master branch is considered as the final view of the repo. Your local repository has its master branch that always up to date with the master of a remote repository.

In Git, The term origin is referred to the remote repository where you want to publish your commits. The default remote repository is called origin, although you can work with several remotes having a different name at the same time. It is said as an alias of the system.

The origin is a short name for the remote repository that a project was initially being cloned. It is used in place of the original repository URL. Thus, it makes referencing much easier.

Origin is just a standard convention. Although it is significant to leave this convention untouched, you could ideally rename it without losing any functionality.

Commands:

git pull origin master (is used to push the changes to the remote repository) git push origin master (is used to access the repository from remote to local)

 

git remote

In Git, the term remote is concerned with the remote repository. It is a shared repository that all team members use to exchange their changes. A remote repository is stored on a code hosting service like an internal server, GitHub, Subversion, and more. In the case of a local repository, a remote typically does not provide a file tree of the project's current state; as an alternative, it only consists of the .git versioning data.

To check the configuration of the remote server, run the git remote command. The git remote command allows accessing the connection between remote and local.

Command: git remote (want to see the original existence of your cloned repository)



git checkout

In Git, the term checkout is used for the act of switching between different versions of a target entity. The git checkout command is used to switch between branches in a repository.

The git checkout command operates upon three different entities which are files, commits, and branches. Sometimes this command can be dangerous because there is no undo option available on this command.

It checks the branches and updates the files in the working directory to match the version already available in that branch, and it forwards the updates to Git to save all new commit in that branch.

Command: git checkout $(branch_name)

 

git pull

The term pull is used to receive data from GitHub. It fetches and merges changes from the remote server to your working directory. The git pull command is used to pull a repository.

Pull request is a process for a developer to notify team members that they have completed a feature. Once their feature branch is ready, the developer files a pull request via their remote server account. Pull request announces all the team members that they need to review the code and merge it into the master branch.

The pull command is used to access the changes (commits)from a remote repository to the local repository. It updates the local branches with the remote-tracking branches. Remote tracking branches are branches that have been set up to push and pull from the remote repository. Generally, it is a collection of the fetch and merges command. First, it fetches the changes from remote and combined them with the local repository.

Command: git pull (repository link)



git push

The push term refers to upload local repository content to a remote repository. Pushing is an act of transfer commits from your local repository to a remote repository. Pushing is capable of overwriting changes; caution should be taken when pushing.

Moreover, we can say the push updates the remote refs with local refs. Every time you push into the repository, it is updated with some interesting changes that you made. If we  do not specify the  location of  a repository,  then it will push to default location   at origin master.

The "git push" command is used to push into the repository. The push command can be considered as a tool to transfer commits between local and remote repositories.

Git push origin master is a special command-line utility that specifies the remote branch and directory. When you have multiple branches and directory, then this command assists you in determining your main branch and repository.

Generally, the term origin stands for the remote repository, and master is considered as the main branch. So, the entire statement "git push origin master" pushed the local content on the master branch of the remote location.

Command: git push origin master


Monday, 30 August 2021

Azure CLI commands

Get what version of the CLI you have

az --version

Get help

az help


Logging to Azure portal

Login with web

az login

Login in CLI

az login -u myemail@address.com

List accounts

az account list

Set subscription

az account set --subscription "xxx"


Listing locations and resources / general

List all locations

az account list-locations

List all my resource groups

az resource list


Creating a basic VM / Resource Group / Storage Account

Get all available VM sizes

az vm list-sizes --location eastus

Get all available VM images for Windows and Linux

az vm image list --output table

Create a Resource group

az group create --name demo-rg --location eastus2

Create a Linux VM

az vm create --resource-group demo-rg --name myvmfordemo --image ubuntults --admin-username adminazure

Create a Windows VM

az vm create --resource-group demo-rg --name mywindowsvmfordemo  --image win2016datacenter   --admin-username adminazure

Create a Storage account.

az storage account create -g demo-rg -n mystorageaccount -l eastus2 --sku Standard_LRS


DELETING A RESOURCE GROUP

Permanetly deletes a resource group

az group delete --name demo-rg


Managing VM's

List your VMs

az vm list

Start a VM

az vm start --resource-group myResourceGroup --name myVM

Stop a VM

az vm stop --resource-group myResourceGroup --name myVM

Deallocate a VM

az vm deallocate --resource-group myResourceGroup --name myVM

Restart a VM

az vm restart --resource-group myResourceGroup --name myVM

Redeploy a VM

az vm redeploy --resource-group myResourceGroup --name myVM

Delete a VM

az vm delete --resource-group myResourceGroup --name myVM

Create image of a VM

az image create --resource-group myResourceGroup --source myVM --name myImage

Create VM from image

az vm create --resource-group myResourceGroup --name myNewVM --image myImage

List VM extensions

az vm extension list --resource-group azure-playground-resources --vm-name azure-playground-vm

Delete VM extensions

az vm extension delete --resource-group azure-playground-resources --vm-name azure-playground-vm --name bootstrapper

Sunday, 1 August 2021

Apache Tomcat 9 Installation on Centos 8

Pre-Requirement:

Update repo details
sudo sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*

sudo sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

Please Follow below instructions to install and configure Tomcat on CentOS 8 machine

1)  Install epel-release.

sudo yum install epel-release -y
2) Install open-jdk
sudo yum install java-11-openjdk -y
3)  Download Apache Tomcat 
  cd /opt/        sudo wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.50/bin/apache-tomcat-9.0.50.tar.gz
  sudo tar -zxvf apache-tomcat-9.0.50.tar.gz   sudo mv apache-tomcat-9.0.50 tomcat
  sudo chmod -R 777 tomcat
  sudo chown -R vagrant:vagrant tomcat
4) Configure Apache Tomcat 9 as system service. 
    Create tomcat service file and add below content.

    sudo vi /etc/systemd/system/tomcat.service


[Unit]
Description=Tomcat 9
After=network.target

[Service]
Type=forking

User=vagrant
Group=vagrant

Environment="JAVA_HOME=/usr/lib/jvm/jre"
Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom"
Environment="CATALINA_BASE=/opt/tomcat"
Environment="CATALINA_HOME=/opt/tomcat"
Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid"

ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh

[Install]
WantedBy=multi-user.target
  
5) Start tomcat service
sudo systemctl start tomcat
6) Enable tomcat service
sudo systemctl enable tomcat

Friday, 23 July 2021

Docker installation on CentOS 8

 CentOS 8 uses the YUM package manager version v4.0.4. This version now uses DNF (Dandified YUM).

1) Use DNF to add and enable the official Docker CE repository. Type the following command in your terminal window:

sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo

2) To list all the available docker-ce packages, type:

dnf list docker-ce --showduplicates | sort -r
3) Install docker now
sudo dnf install docker-ce -y
4) Enable docker service to be start during system boot up
sudo systemctl enable docker

5) Start docker service
sudo systemctl start docker

6) Add current user to Docker User Group - We may need to restart session again to run docker cli commands with current user
sudo usermod -aG docker $USER
7) We need to disable firewalld for DNS resolution inside Docker containers to work
sudo systemctl disable firewalld
8) Test Docker setup.
docker run hello-world
After running above command you should be able to see below output.
Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/




Saturday, 19 June 2021

Configure Maven on Jenkins

 In this tutorial we are going to discuss how to configure Maven in Jenkins machine.

a) Install Maven manually on Jenkins VM

Run below commands

cd /opt/

wget https://mirrors.estointernet.in/apache/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz

tar -zxvf apache-maven-3.8.1-bin.tar.gz

Now maven will be unpacked to /opt/apache-maven-3.8.1

Login to Jenkins > Go to Manage Jenkins > Global Tools Configuration

Click  on Maven Installation under Maven


Add maven path as mentioned in screenshot.



b) Install Maven from Jenkins Console

Login to Jenkins > Click on Manage Jenkins ( Left side )


Click on Global Tool Configurations

Click on Maven Installation under Maven


Click on Save

With this steps we have maven is integrated in your Jenkins. You can start using maven for build automation of the product.