Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
CREATING SUB-DIRECTORY UNDER DIRECTORY USING ONE MKDIR COMMAND


priya@ubuntu:~$ pwd
/home/priya
priya@ubuntu:~$ mkdir -p A/B/C
priya@ubuntu:~$ ls
A Documents examples.desktop Pictures priya Desktop Downloads Music Public Templates Videos
priya@ubuntu:~$ cd A
priya@ubuntu:~/A$ ls
B
priya@ubuntu:~/A$ cd B
priya@ubuntu:~/A/B$ ls
C
priya@ubuntu:~/A/B$













Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Ques: When we create a new user some hidden files are created in the directory of the same user at that time. How is it done ?

Ans: 'adduser' command reads the content of the /etc/login.defs file. This file 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. So as this file contains login details so some hidden files are created at the time of creating a new user.
15 changes: 15 additions & 0 deletions Priyansh Lakhotia/Linux Task 1/Task-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Task 1

Ques: Why a directory of username is not created when we run the command '$ useradd username' in the home whereas it is created when we use the command '$ adduser username' ?

Ans: By default 'useradd' command creates a user's home directory under /home directory with username.


The useradd program has been deprecated in favor of adduser. From man useradd:
useradd is a low level utility for adding users. Administrators should usually use adduser instead.

adduser is a friendlier frontend to useradd and will do things like create user directories by default. When you run it with only a username as an argument, you will be prompted to provide additional information such as the password

In general, you should always use adduser instead of useradd since this will also set up the required groups automatically. As explained in man adduser:

"adduser and addgroup add users and groups to the system according to command line options and configuration information in /etc/adduser.conf. They are friendlier front ends to the low level tools like useradd, groupadd and usermod programs, by default choosing Debian policy conformant UID and GID values, creating a home directory with skeletal configuration, running a custom script, and other features. "
82 changes: 82 additions & 0 deletions Priyansh Lakhotia/Linux Task 2/Session 4-Task 2.txt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
Ques 1: How can you change the umask value permanently ?

Ans 1: This can be achived by writing a new Umask value in your shell’s configuration file (~/.bashrc for Bash) or in the /etc/profile file.


Ques 2:Add a new user without using adduser or useradd commands

Ans:
Step 1:Add an entry for the user in /etc/passwd file.
Step 2:Add an entry for the group in /etc/group file.
Step 3:Create the home directory for the added user.
Step 4:Set the new user password using the passwd command.



Ques 3:Can we change the UMASK value to 0888?

Ans 3: No we cannot change the value of UMASK to 0888 because the maximum value of UMASK can be 0777.
Even if we try to do so than we will get the following error:

priya@ubuntu:~$ umask 0888
bash: umask: 0888: octal number out of range
priya@ubuntu:~$



Ques 4: New user with unique user id
Ans 4: We can create new user with unique userid with ‘-u‘ option. For example, the following command will create a user ‘superuser‘ with custom userid ‘888‘.
And also we can verify the user with the command cat /etc/passwd | grep superuser.
Code:

priya@ubuntu:~$ sudo -i
[sudo] password for priya:
root@ubuntu:~# useradd -u 888 superuser
root@ubuntu:~# cat /etc/passwd | grep superuser
superuser:x:888:1003::/home/superuser:/bin/sh
root@ubuntu:~#




Ques 5:How can we change group of a file?

Ans: The chgrp command changes the group ownership of given files.
command - $ chgrp newgroupname filename

Ques 5(a):To check the group name of a file

Ans: By using the command
$ ls -l filename


Ques 5(b): Changing the group of the folder and the files present in the same folder using a simple command

Ans 5(b): This can be done by using a command:

$ sudo chgrp -r groupname filename

























144 changes: 144 additions & 0 deletions Priyansh Lakhotia/Linux Task 3/sesssion #5 - Task 3.txt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
Ques 1: How to create a new user and at the same time define a pre-existing group to it ?

Ans 1: This can be achived by using the command

sudo adduser -g username groupname
(this groupname can be existing)



Ques 2:How to unzip the bz2 file

Ans 2: bz2 file is unzipped using
$ bzip2 -d filename.bz2
(here d means decompress)

e.g.,

priya@ubuntu:~/shubh$ ls -lh
total 50M
-rwxrwxrw- 1 priya priya 50M Apr 8 12:46 1
-r--r---w- 1 priya priya 0 Apr 8 10:56 11
-rw-r--r-- 1 priya priya 0 Apr 7 13:58 file
dr--rw---x 2 priya priya 4.0K Apr 7 14:04 folder
dr-xr---wx 2 priya priya 4.0K Apr 8 10:56 hello
priya@ubuntu:~/priya$ yes "Priyansh" >> 11
bash: 11: Permission denied
priya@ubuntu:~/priya$ cat 11
priyaz@ubuntu:~/priya$ yes "Priyansh" >> 11
bash: 11: Permission denied
priya@ubuntu:~/priya$ yes "Priyansh" > 11
bash: 11: Permission denied
priya@ubuntu:~/priya$ touch 12
priya@ubuntu:~/priya$ yes "Priyansh" > 12
^C
priya@ubuntu:~/priya$ ls -lh
total 89M
-rwxrwxrw- 1 priya priya 50M Apr 8 12:46 1
-r--r---w- 1 priya priya 0 Apr 8 10:56 11
-rw-r--r-- 1 priya priya 40M Apr 8 12:48 12
-rw-r--r-- 1 priya spriya 0 Apr 7 13:58 file
dr--rw---x 2 priya priya 4.0K Apr 7 14:04 folder
dr-xr---wx 2 priya priya 4.0K Apr 8 10:56 hello
priya@ubuntu:~/shubh$ bzip2 1
priya@ubuntu:~/shubh$ ls -lh
total 40M
-r--r---w- 1 priya priya 0 Apr 8 10:56 11
-rw-r--r-- 1 priya priya 40M Apr 8 12:48 12
-rwxrwxrw- 1 priya priya 4.5K Apr 8 12:46 1.bz2
-rw-r--r-- 1 priya priya 0 Apr 7 13:58 file
dr--rw---x 2 priya priya 4.0K Apr 7 14:04 folder
dr-xr---wx 2 priya priya 4.0K Apr 8 10:56 hello
priya@ubuntu:~/priya$ bzip2 -d 1.bz2
priya@ubuntu:~/priya$ ls
1 11 12 file folder hello
priya@ubuntu:~/priya$


Ques 3 : Archive and compress files with data and folder using bz2 extension

Ans 3:This can be achived by using the command
$ tar -cvzf filename.tar.bz2 file1name file2name foldername

priya@ubuntu:~$ cd shubh
priya@ubuntu:~/shubh$ mkdir newfolder
priya@ubuntu:~/shubh$ cd newfolder
priya@ubuntu:~/shubh/newfolder$ touch newfile1
priya@ubuntu:~/shubh/newfolder$ touch newfile2
priya@ubuntu:~/shubh/newfolder$ ls
newfile1 newfile2
priya@ubuntu:~/shubh/newfolder$ cd ..
priya@ubuntu:~/shubh$ ls
1 11 12 file folder hello newfolder
priya@ubuntu:~/shubh$ tar -cvzf compressed.tar.bz2 1 12 newfolder
1
12
newfolder/
newfolder/newfile1
newfolder/newfile2
priya@ubuntu:~/priya$ ls
1 11 12 compressed.tar.bz2 file folder hello newfolder
priya@ubuntu:~/priya$



Ques 4 :How can we add a user and at the same time define its shell as /bin/bash.
Ans 4 : This can be achived by using the command:
$ sudo useradd -s /bin/bash username

priya@ubuntu:~/priya$ cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/bash
/bin/rbash
/bin/dash
priya@ubuntu:~/shubh$ sudo useradd -s /bin/bash spiderman
[sudo] password for priya:
priya@ubuntu:~/shubh$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-network:x:100:102:systemd Network Management,,,:/run/systemd/netif:/usr/sbin/nologin
systemd-resolve:x:101:103:systemd Resolver,,,:/run/systemd/resolve:/usr/sbin/nologin
syslog:x:102:106::/home/syslog:/usr/sbin/nologin
messagebus:x:103:107::/nonexistent:/usr/sbin/nologin
_apt:x:104:65534::/nonexistent:/usr/sbin/nologin
uuidd:x:105:111::/run/uuidd:/usr/sbin/nologin
avahi-autoipd:x:106:112:Avahi autoip daemon,,,:/var/lib/avahi-autoipd:/usr/sbin/nologin
usbmux:x:107:46:usbmux daemon,,,:/var/lib/usbmux:/usr/sbin/nologin
dnsmasq:x:108:65534:dnsmasq,,,:/var/lib/misc:/usr/sbin/nologin
rtkit:x:109:114:RealtimeKit,,,:/proc:/usr/sbin/nologin
cups-pk-helper:x:110:116:user for cups-pk-helper service,,,:/home/cups-pk-helper:/usr/sbin/nologin
speech-dispatcher:x:111:29:Speech Dispatcher,,,:/var/run/speech-dispatcher:/bin/false
whoopsie:x:112:117::/nonexistent:/bin/false
kernoops:x:113:65534:Kernel Oops Tracking Daemon,,,:/:/usr/sbin/nologin
saned:x:114:119::/var/lib/saned:/usr/sbin/nologin
pulse:x:115:120:PulseAudio daemon,,,:/var/run/pulse:/usr/sbin/nologin
avahi:x:116:122:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/usr/sbin/nologin
colord:x:117:123:colord colour management daemon,,,:/var/lib/colord:/usr/sbin/nologin
hplip:x:118:7:HPLIP system user,,,:/var/run/hplip:/bin/false
geoclue:x:119:124::/var/lib/geoclue:/usr/sbin/nologin
gnome-initial-setup:x:120:65534::/run/gnome-initial-setup/:/bin/false
gdm:x:121:125:Gnome Display Manager:/var/lib/gdm3:/bin/false
shubhangvats:x:1000:1000:Shubhang Vats,,,:/home/shubhangvats:/bin/bash
yash:x:1001:1001:,,,:/home/yash:/bin/bash
regex:x:999:1002::/home/regex:/bin/sh
superuser:x:888:1003::/home/superuser:/bin/sh
vats:x:1002:1004:,,,:/home/vats:/bin/bash
spiderman:x:1003:1005::/home/spiderman:/bin/bash
priya@ubuntu:~/shubh$
35 changes: 35 additions & 0 deletions Priyansh Lakhotia/Python Task 1/Python Session 1(Task 1).txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Assignment 1 - Unicode vs ASCII

ASCII and Unicode are two character encodings. They are standards on how to represent different characters in binary so that they can be written, stored, transmitted, and read in digital media. The main difference between the two is in the way they encode the character and the number of bits that they use for each. ASCII originally used seven bits to encode each character. This was later increased to eight with Extended ASCII to address the apparent inadequacy of the original. In contrast, Unicode uses a variable bit encoding program where you can choose between 32, 16, and 8-bit encodings. Using more bits lets you use more characters at the expense of larger files while fewer bits give you a limited choice but you save a lot of space. Using fewer bits (i.e. UTF-8 or ASCII) would probably be best if you are encoding a large document in English.

One of the main reasons why Unicode was the problem arose from the many non-standard extended ASCII programs. Unless you are using the prevalent page, which is used by Microsoft and most other software companies, then you are likely to encounter problems with your characters appearing as boxes. Unicode virtually eliminates this problem as all the character code points were standardized.





Assignment 2 - Different types of Python Compilers:

The different types of Python compilers are :

1) CPython.
It is the most widely used interpreter in Python. Developed in C and Python, the bindings for the interpreter must be written in a foreign language other than Python. CPython uses a Global Interpreter Lock (GIL) on each process. Thus Python bytecode for a single process is executed on a single thread.

2) Jython or Jpython.
Jython is an implementation that has been designed for the seamless integration of Python code over JVM. The advantage of this integration is that it provides an opportunity for amalgamation of a popular scripting language like python to a vast library of the JVM. Jython compiles files to .class extensions.

3)IronPython.
Iron Python is a python implementation designed with the target of the dot net framework. This project is maintained presently by a small community of users in Github. To be used for scripting this has a requisite of installing the Python tools for visual studio which is available as an extension for visual studio IDE. The full implementation is written in C#.

4)ActivePython.
ActivePython is a commercial version of Python scripting platform designed and developed by the Open source organization called ActiveState. It provides Python bundles along with some additional packages.


5)PyJS (it also is formerly known as Pyjamas).
PyJs is a rich internet application particularly used in the development of client-side web applications and desktop applications using Python scripting. The PyJs has a compiler that translates Python to JavaScript and is primarily designed over the Ajax framework.

6)Nuitka.
Nuitka is an ideal example of a source to source compiler. The compiler allows the user to feed python codes and produce C/C++ extensions even if the computer has no python version installed in it.

7)Stackless Python
It is an advanced version of programming language interpreter used by the developers in multithreaded programming without compromising on performance complexity and performance issues faced by the conventional multithreaded programming languages.
8 changes: 8 additions & 0 deletions Priyansh Lakhotia/Python Task 2/question1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# What should be the output of ( 3 + 4 ** 6 - 9 * 10 / 2 ) ?

#Solution:

a = (3+4**6-9*10/2)
print (a)

#Answer is 4054.0
14 changes: 14 additions & 0 deletions Priyansh Lakhotia/Python Task 2/question2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Question 2
'''
Lets say I have some string "hello this side regex"
Find out the count of the total vowels
vowels - ['a','e','i','o','u']
'''

vowels = ['a','e','i','o','u']
text = ("hello this side regex")
total_vowels = 0
for i in text:
if i in vowels:
total_vowels = (total_vowels + 1)
print (total_vowels)
13 changes: 13 additions & 0 deletions Priyansh Lakhotia/Python Task 2/question3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#Question 3
'''
Find out the area of triangle
- 1/2 * b * h (formula of area)
- You have to take value from user about the base, & the height
'''


base = int(input("Enter the length of the base of the triangle: "))
height = int(input("Enter the height of the triangle: "))
area = (0.5 * base * height)
print ("Area of the triangle is ", area)

11 changes: 11 additions & 0 deletions Priyansh Lakhotia/Python Task 2/question4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Question 4
'''
Print the calendar on the terminal. If you give the year.
- Allow the user to input the year.
- Then should that calendar of that year
'''

import calendar
year = int(input("Enter year: "))
print("The calendar of year ",year, " is: ")
print(calendar.calendar(year))
21 changes: 21 additions & 0 deletions Priyansh Lakhotia/Python Task 3/question1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Question 1
'''
Find the Armstrong Number between the two numbers which are input by user
Note: Armstrong number : 153 -> 1*1*1 + 5*5*5 + 3*3*3
'''
#Solution:

number1 = int(input("Enter the starting number"))
number2 = int(input("Enter the ending number"))

for i in range(number1, number2 + 1):
sum = 0
temp = i
while temp > 0:
digit = temp % 10
sum = sum + digit ** 3
temp = temp // 10
if i == sum:
print (i)


Loading