Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MyFirstSubmission #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions Krushna-Prasad-Sahoo/DevopsTask_first_second.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
##### DevOps Task -- 01 #######

--> Yes , I have installed Docker in Red Hat Linux.

---------------------------
Devops Late Night Questions
---------------------------

1 . Yes , I'm using httpd docker image , put html the code inside it .
I can access the webpage successfully .

2. To delete all the exited containers in command is :
# docker rm -rf $(docker ps -aq)


!!!!!!!!!!!!-------------------------------------------!!!!!!!!!!!!!!!!!!!


##### DevOps Task -- 01 #######

1. After putting my own codes inside webserver container I used commit command for
creating my customised web server :
# docker commit mynginx_server web_image:v1

2. For launching 10 containers :

# vim container.py
~ import os
~ os.system("systemctl start docker")
~ os.system("docker container run -dit --name container_one centos:latest ")
~ os.system("docker container run -dit --name container_two centos:latest ")
~ os.system("docker container run -dit --name container_three centos:latest ")
~ os.system("docker container run -dit --name container_four centos:latest ")
~ os.system("docker container run -dit --name container_five centos:latest ")
~ os.system("docker container run -dit --name container_six centos:latest ")
~ os.system("docker container run -dit --name container_seven centos:latest ")
~ os.system("docker container run -dit --name container_eight centos:latest ")
~ os.system("docker container run -dit --name container_nine centos:latest ")
~ os.system("docker container run -dit --name container_ten centos:latest ")
~ tell = input("\nDo you want to see the all container list ? Type yes or no ")
~ if tell == 'yes' :
os.system("docker ps -aq ")
~ else :
exit();
# python3 container.py


3. For running nginx server in my host machine on port no. 7777 I exposed it . Nginx
runs on port no 80 . So I can enable port forwarding while launching the container by
using -p 7777:80 in the command .
64 changes: 64 additions & 0 deletions Krushna-Prasad-Sahoo/Linux_Assignments.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

#####______ ASSIGNMENT -- 01 ______######


1. The 'useradd' command is used for creating new user. The variables defined in
'/etc/default/useradd' file causes the command to produce other files. The command
also reads the content of the '/etc/login.defs' file, which contains configuration
for the shadow password suite such as password expiration policy, ranges of user IDs
used when creating system and regular users and more. This command adds an entry to the
'/etc/passwd', '/etc/shadow', '/etc/group' and '/etc/gshadow' files.

2. The command for creating multiple subdirectories inside any directory using a single
mkdir command is :
# mkdir -p car/{audi/headlight , bmw/dashboard , peugeot/tail_light }/wheels
This will create a parent directory 'car' inside which 3 subdirectories
'audi' , 'bmw' , 'peugeot' will be created . Inside them 'headlight' , 'dashboard' &
'tail_light' subdirectories will be created respectively. And the last directory 'wheels'
will be created inside just previous subdirectories.

3. 'tac' command is used to concatenate and print files in reverse. This command writes the
file to standard output as showing the last line first and so on.
'cat' command is also used for the same purpose as 'tac' like showing the contents of
file , concatenation , overwrite etc but not in reverse order. It gives output in forward
direction.

----------------------------------------------------------------------------------------------------

#####______ ASSIGNMENT -- 02 ______######

1. For changing the umask value permanently we can go to '/etc/profile' file using vi editor
and change there the umask value.
# vi /etc/profile
` umask 027

2. To add the a new user without using useradd/adduser command is :
-Add an entry for the user in '/etc/passwd' file.
-Add an entry for the group in '/etc/group' file.
-Create the home directory for the added user.
-Set the new user password using the passwd command.

3. I think no, not supported by the system.

4. To add a new user with id 1345 & checking out it :
# useradd -u 1345 Regex
# id -u Regex

5. # chgrp newgrp myfile
# ls -l

--------------------------------------------------------------------------------------------------------

#####______ ASSIGNMENT -- 03 ______######

1. # bzip2 file.txt -> is used for compressing any file

2. # bzip2 -d file.txt.bz2 -> is used for decompressing that file.
# bunzip file.txt.bz2 -> it can also be used for unzipping.

3. Suppose the file we want to read is info.txt. Using standard input output funtion :
# cat info.txt > $(tty) or
# cat info.txt > /dev/tty3

4. To change the shell to '/bin/sh' of a user while adding it :
# useradd -s /bin/sh new_user
65 changes: 65 additions & 0 deletions Krushna-Prasad-Sahoo/Python_Assignment.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
##-----------ASSIGNMENT-----------##

Python Class 1 :

1. Jpython is an implementation of the Python programming language designed to run on the Java platform.
Cpython is the reference implementation of the Python programming language. Written in C and Python, CPython is the default and most widely used implementation of the language.
2. Python 3 default storing of strings is Unicode whereas Python 2 stores need to define Unicode string value with "u." Python 3 value of variables never changes whereas in Python 2 value of the global variable will be changed while using it inside for-loop.
Also Python 3 has good standards and powerful library over Python 2 .
3. ASCII originally used seven bits to encode each character. However, Unicode uses a variable bit encoding program where you can choose between 32, 16, and 8-bit encodings.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Python Class 2 :

1. The output of 3 + 4 ** 6 - 9 * 10 / 2 is -> 4054.0

2. def Check_Vow(string, vowels):
final = [each for each in string if each in vowels]
print(len(final))
print(final)
string = "Hello this side regex"
vowels = "AaEeIiOoUu"
Check_Vow(string, vowels);

3. b, h = input("Enter the value of base and height of the trianhle space seprated : ").split(" ")
print(f"Area of Triangle : {1/2 * int(b) * int(h)} ")

4. import calendar
y=int(input("Enter the year="))
for i in range(1,13):
print(calendar.month(y,i))
--------------------------------------------------------------------------------------------------------------

Python Class 3 :

1. //Armstrong Number

lower=int(input("Enter the lower limit: "))
upper = int(input("Enter the upper limit: "))
arm_num=[]
for num in range(lower,upper + 1):
sum = 0
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** 3
temp //= 10
if num == sum:
arm_num.append(num)
print("\nThe armstrong Numbers between "+str(lower)+" and "+str(upper)+" are:")
for i in arm_num:
print(i)

2. //Remove all punctuations
punctuations = '''!()-[]{};:'"\\,<>./?@#$%^&*_~'''
statement=input("\nEnter your string: ")
extract = ""
for char in statement:
if char not in punc:
extract = extrct + char
print(extract)

3. //sorting the list
given_list = ['Apple', 'banana', 'cat','apple']
final_list=sorted(given_list)
print("\nThe Sorted List is: ",final_list)
74 changes: 74 additions & 0 deletions Krushna-Prasad-Sahoo/Python_Assignment2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
##------------------- ASSIGNMENT - 02 ---------------##

1. LIST_STATES = ["GOA","RAJASTHAN","KARNATAKA","GUJRAT","MANIPUR","MADHYA PRADESH"]
for i in LIST_STATES:
print(i[0])

2. LIST = ['GAnga', 'Tapti', 'Kaveri', 'Yamuna', 'Narmada' ]
count = 0
for i in LIST:
j = 0
summ = 0
for j in i:
summ = summ + ord(j)
LIST[count] = summ
count = count + 1
print(LIST)

3. import datetime
def change(given_time):
format = '%b %d %Y %I:%M%p'
new_str = datetime.datetime.strptime(date_time, format)
return new_str
given_time = ' Dec 4 2018 10:07AM '
print(change(given_time))

4. tuple = ('a','l','g','o','r','i','t','h','m')
print(tuple[0:])
tuple = tuple[:2] + tuple[3:]
print(tuple)

5. REGex=[1,2,3,4,5,6,7,8,9,0,77,44,15,33,65,89,12]
a=[]
b=[]
for i in REGex:
if i > 20:
a.append(i)
if i <= 10:
b.append(i)
print(a)
print(b)

6. import os
os.system("tput setaf 2 ")
os.system("cal")
os.system("ifconfig")
os.system("date")
os.system("init 0")

7. *args - It is used to pass a non-keyworded, variable-length argument list.
-------
example
-------
def tryy(*args):
for i in args:
print (i)
tryy('Hiii', 'There', 'how', 'are' , 'you')

******************************

**kwagrs - It has double stars which allows to pass a key-value pair to a function.
-------
example
-------

def tryy(**kwargs):
for key, value in kwargs.items():
print ("%s : %s" %(key, value))
tryy(First_name = 'Krushna', Middle_name = 'Prasad', Last_name = 'Sahoo')