0% found this document useful (0 votes)
130 views

Cs Linux

The document provides steps to install Red Hat Enterprise Linux 5 OS using virtual machine software. It details 21 steps for installing the OS, setting up basic configurations like keyboard, disk partitioning and provides screenshots of each step. Practical exercises on Linux commands like user management, date/time commands, file operations and directory structures are also included.

Uploaded by

Varsha Sadde
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
130 views

Cs Linux

The document provides steps to install Red Hat Enterprise Linux 5 OS using virtual machine software. It details 21 steps for installing the OS, setting up basic configurations like keyboard, disk partitioning and provides screenshots of each step. Practical exercises on Linux commands like user management, date/time commands, file operations and directory structures are also included.

Uploaded by

Varsha Sadde
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 57

BNN COLLEGE BHIWANDI

CLASS: FYCS

PRACTICAL NO. 1

Aim: Installation of Red Hat Enterprise Linux 5 OS

Step 1:Click on NEXT

DEPARTMENT OF COMPUTER SCIENCE Page 1


BNN COLLEGE BHIWANDI
CLASS: FYCS

Step 2: Select Typical virtual machine configuration

Step 3:Select a guest Operating system as Linux

DEPARTMENT OF COMPUTER SCIENCE Page 2


BNN COLLEGE BHIWANDI
CLASS: FYCS

Step 4:Provide virtual machine name and location.

Step 5:Select network type as bridged networking.

DEPARTMENT OF COMPUTER SCIENCE Page 3


BNN COLLEGE BHIWANDI
CLASS: FYCS

Step 6:Provide Disk size(InGB) and click on Finish button.

Step 7: Select the devices that we required for our Linux operating system.

DEPARTMENT OF COMPUTER SCIENCE Page 4


BNN COLLEGE BHIWANDI
CLASS: FYCS

Step 8: Browse ISO image click on Ok button.

Step 9:Click on start virtual machine.

DEPARTMENT OF COMPUTER SCIENCE Page 5


BNN COLLEGE BHIWANDI
CLASS: FYCS

DEPARTMENT OF COMPUTER SCIENCE Page 6


BNN COLLEGE BHIWANDI
CLASS: FYCS

Step 10: click on next.

Step 11: Select language[English(English)] and click on next.

DEPARTMENT OF COMPUTER SCIENCE Page 7


BNN COLLEGE BHIWANDI
CLASS: FYCS

Step 12:Select the appropriate keyboard for the system.

DEPARTMENT OF COMPUTER SCIENCE Page 8


BNN COLLEGE BHIWANDI
CLASS: FYCS

Step 13: Create custom layout and click on next.

DEPARTMENT OF COMPUTER SCIENCE Page 9


BNN COLLEGE BHIWANDI
CLASS: FYCS

Step 14: Provide mount point & file system type and click on next.

DEPARTMENT OF COMPUTER SCIENCE Page 10


BNN COLLEGE BHIWANDI
CLASS: FYCS

DEPARTMENT OF COMPUTER SCIENCE Page 11


BNN COLLEGE BHIWANDI
CLASS: FYCS

Step 15:Click into the map to choose a resion(Asian/Kolkata).

Step 16: Provide Root password and click on next.

DEPARTMENT OF COMPUTER SCIENCE Page 12


BNN COLLEGE BHIWANDI
CLASS: FYCS

Step 17: Click on next.

DEPARTMENT OF COMPUTER SCIENCE Page 13


BNN COLLEGE BHIWANDI
CLASS: FYCS

Step 18: Installation is completed now click on next.

DEPARTMENT OF COMPUTER SCIENCE Page 14


BNN COLLEGE BHIWANDI
CLASS: FYCS

DEPARTMENT OF COMPUTER SCIENCE Page 15


BNN COLLEGE BHIWANDI
CLASS: FYCS

Step 19: Select firewall Disabled and click on forword .

DEPARTMENT OF COMPUTER SCIENCE Page 16


BNN COLLEGE BHIWANDI
CLASS: FYCS

Step 20: Select SELinux Disabled and click on forword .

DEPARTMENT OF COMPUTER SCIENCE Page 17


BNN COLLEGE BHIWANDI
CLASS: FYCS

Step 21: Set the date and time for the System.

DEPARTMENT OF COMPUTER SCIENCE Page 18


BNN COLLEGE BHIWANDI
CLASS: FYCS

DEPARTMENT OF COMPUTER SCIENCE Page 19


BNN COLLEGE BHIWANDI
CLASS: FYCS

DEPARTMENT OF COMPUTER SCIENCE Page 20


BNN COLLEGE BHIWANDI
CLASS: FYCS

DEPARTMENT OF COMPUTER SCIENCE Page 21


BNN COLLEGE BHIWANDI
CLASS: FYCS

PRACTICAL NO. 2

Aim: Basic Lunux commands

1.Binary permision method: In this method Binary Number 1 & 0 assing and Removing
the permision.
Chmod for changing the permision:
#chmod 571 filename.txt
5 – Indicate that owner have only Read and Execute
7 – Indicate that group have all permision
1 – Indicate that other have only Execution permision
For Example:
#chmod 751 abc.txt

#cat >raju.txt
Cat commandis used to create tex t file

2.Symbolic Making Method:- In this method symbols are used for assingning and removing
the permision.
Symbols and thire Means:
r- Read
w- Write
X- Execute
g- Group
o- Other
u- Owner
a-All User
‘+’ – Assingning the permision
‘-’ – Removing the permision
Command changing the permision:
#chmod g+rw Filename.txt

DEPARTMENT OF COMPUTER SCIENCE Page 22


BNN COLLEGE BHIWANDI
CLASS: FYCS

PRACTICAL NO. 3

Aim: Documentations

info grep

man grep

DEPARTMENT OF COMPUTER SCIENCE Page 23


BNN COLLEGE BHIWANDI
CLASS: FYCS

man ls

man zip

DEPARTMENT OF COMPUTER SCIENCE Page 24


BNN COLLEGE BHIWANDI
CLASS: FYCS

PRACTICAL NO. 4

Aim : Basic Linunx Commands such as file and directory manipulation ,redirection
and piping.

Commands used in this practical are as follows:


(adduser,passwd,Ctrl—Alt-F1….F6 ,cal ,date,bc,who, whoami,tty,echo,touch,cat[>,>>],
Cp,mv,rm,mkdir,rmdir,cd,pwdd,logout/exit and all options of all respective commands ls
with all its options ,wildcard characters,file,wc,tee,| [pipe symbol])

1. Login as root user.


2. Create Your own user account with the name “tybsc1”.
3. Logout from the root user.
4. Open other virtual terminal and login with your user account ”tybsc1”.
5. Display the calendar of the current month of the current year.
6. Display the calendar of the year 2009.
7. Display the calendar of the month July of the year 1998.
8. Display today’s date.
9. Display date as mm/dd/yy.
10. Display current hour minutes and seconds.
11. Display time in hours,minutes and seconds as HH:MM:SS .
12. Display day of the week.
13. Display abbreviated weekday.
14. Display abbreviated month Jan-Dec.
15. Display time in AM/PM notation.
16. Display last two digits of the year.
17. Display the date and time on two different lines.
18. Calculate the following using bc command:-
i) 6+7 ii) 12*12 iii) 144/3 iv) scale=2 25/7 v) (8+2)*5

vi)(2+3)+8-4*(6-3) vii)2^6 viii) 12*12; 12/6

ix) ibase=2 11001010 x) obase =2 14

19.Display all the users currently logged in the system.


20. Display the login name of the current terminal.
21.Display all the users currenly logged in the system with heading .
22.Display the terminal file of the current terminal.
23.Display the message on to the terminal as “Hello World”.
24.Display the message on to the terminal as “Hello World”.
25.What will be the output of the following :-
i) x=10
echo The value of x is $x

ii) str=”This is first practical ”

DEPARTMENT OF COMPUTER SCIENCE Page 25


BNN COLLEGE BHIWANDI
CLASS: FYCS

echo This string is $str


iii) d=’date’
echo “Today’s date is $d”
iv) echo “The number of users currently logged in are `who` ”

26.Create five empty files with the name a1,b2,c3,d4 and e5.
27.Create three files with the name f6,g7,h8 using cat command with some meaningful
contents with atleast five lines each.
28. Display the contents of files f6,,g7,h8.
29.Display the contents of files along with the line numbers.
30.Copy contents of f6 to a1,g7 to b2, h8 to c3.
31.Add the contents of a1,b2,and c3 into “testfile”.
32.Create two directories with the name dd1 and dd2.
33.Copy the files a1 and b2 to the directories dd2.
34.Copy the files f6,g7 to the directory dd2.
35.Remove the directory dd2 along with its contents.
36.Rename the files a1 and b2, by newa1 and newb2.
37.Create a directory tree dir1/dir2/dir3/ in one command.
38.Change to this directory in one command.
39. Display the present working directory.
40.Create some files into it with come contents.
41.Remove the directory tree dir1/dir2/dir3 in one command. Is directory removed? If
no , why?
42. Save your work and logout from current terminal.

ANSWERS:

2)[root@localhost home]# adduser tybsc1


[root@localhost home]#

3)[root@localhost ~]# exit

4)[root@localhost ~]# su tybsc1

5)[tybsc1@localhost root]$ cal

DEPARTMENT OF COMPUTER SCIENCE Page 26


BNN COLLEGE BHIWANDI
CLASS: FYCS

6)[tybsc1@localhost root]$ cal 2009

7)[tybsc1@localhost root]$ cal 07 1998

8)[tybsc1@localhost root]$ date


Tue Feb 14 07:30:31 IST 2017

9)[tybsc1@localhost root]$ date +%D


02/14/17

10)[tybsc1@localhost root]$ date +%H


07
[tybsc1@localhost root]$ date +%M
33
[tybsc1@localhost root]$ date +%S
15

DEPARTMENT OF COMPUTER SCIENCE Page 27


BNN COLLEGE BHIWANDI
CLASS: FYCS

11)[tybsc1@localhost root]$ date +%H:%M:%S


07:36:05

12)[tybsc1@localhost root]$ date +%A


Tuesday

13)[tybsc1@localhost root]$ date +%a


Tue

14)[tybsc1@localhost root]$ date +%h


Feb

15)[tybsc1@localhost root]$ date +%r


07:41:48 AM

16)[tybsc1@localhost root]$ date +%y


17

17)[tybsc1@localhost root]$ date +%D%n%T


02/14/17
07:44:53

18)[tybsc1@localhost root]$ bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
i)6+7
13

ii)12*12
144

iii)144/3
48

iv)scale=2
25/7
3.57

v)
(8+2)*5
50

vi)(2+3)+8-4*(6-3)
1

vii)

DEPARTMENT OF COMPUTER SCIENCE Page 28


BNN COLLEGE BHIWANDI
CLASS: FYCS

2^6
64

viii)
12*12;12/6
144
2.00

ix)ibase=2
11001010
202

x)obase=2
14
1110

19)[tybsc1@localhost root]$ who


root pts/0 2017-02-14 07:24 (:0.0)
[tybsc1@localhost root]$

20)[tybsc1@localhost root]$ who am i


root pts/0 2017-02-14 07:24 (:0.0)

21)[tybsc1@localhost root]$ who -uH


NAME LINE TIME IDLE PID COMMENT
root pts/0 2017-02-14 07:24 . 3938 (:0.0)

22)[tybsc1@localhost root]$ tty


/dev/pts/0

23)[tybsc1@localhost root]$ echo Hello world


Hello world

24)[tybsc1@localhost root]$ echo "Hello world"


Hello world

25)(i)[tybsc1@localhost root]$ x=10


[tybsc1@localhost root]$ echo "The Value of x is $x"
The Value of x is 10

(ii)[tybsc1@localhost root]$ str="This is first Practical"


[tybsc1@localhost root]$ echo "The string is $str"
The string is This is first Practical

(iii)[tybsc1@localhost root]$ d=`date`


[tybsc1@localhost root]$ echo "Today's date is $d"
Today's date is Tue Feb 14 08:10:09 IST 2017

DEPARTMENT OF COMPUTER SCIENCE Page 29


BNN COLLEGE BHIWANDI
CLASS: FYCS

(iv)[tybsc1@localhost root]$ echo "The nunmber of users currently logged in are


`who`"
The nunmber of users currently logged in are root pts/0 2017-02-14 07:24 (:0.0)

26)[tybsc1@localhost ~]$ touch a1 b2 c3 d4 e5

27)[tybsc1@localhost ~]$ cat>f6

Hello everyone !
How are you ?
I am fine .
Whats going on ?
Hows your life ?
Is everthing fine ?

[tybsc1@localhost ~]$ cat > g7


Johny Johny ,Yes Papa
Eating Sugar ? no papa!
Telling lies?
No Papa !
open your mouth ..
Ha Ha Ha !

[tybsc1@localhost ~]$ cat > h8


Always forgive your enemy but don't forget their names!
Old is Gold
Simple Living High Thinking
Honesty is the best policy
Love everyone

28)[tybsc1@localhost ~]$ cat f6

Hello everyone !
How are you ?
I am fine .
Whats going on ?
Hows your life ?
Is everthing fine ?

[tybsc1@localhost ~]$ cat g7


Johny Johny ,Yes Papa
Eating Sugar ? no papa!
Telling lies?

DEPARTMENT OF COMPUTER SCIENCE Page 30


BNN COLLEGE BHIWANDI
CLASS: FYCS

No Papa !
open your mouth ..
Ha Ha Ha !

[tybsc1@localhost ~]$ cat h8


Always forgive your enemy but don't forget their names!
Old is Gold
Simple Living High Thinking
Honesty is the best policy
Love everyone

29)[tybsc1@localhost ~]$ cat -n f6


1
2 Hello everyone !
3 How are you ?
4 I am fine .
5 Whats going on ?
6 Hows your life ?
7 Is everthing fine ?

[tybsc1@localhost ~]$ cat -n g7


1 Johny Johny ,Yes Papa
2 Eating Sugar ? no papa!
3 Telling lies?
4 No Papa !
5 open your mouth ..
6 Ha Ha Ha !

[tybsc1@localhost ~]$ cat -n h8


1 Always forgive your enemy but don't forget their names!
2 Old is Gold
3 Simple Living High Thinking
4 Honesty is the best policy
5 Love everyone

30)[tybsc1@localhost ~]$ cp f6 a1
[tybsc1@localhost ~]$ cat a1

Hello everyone !
How are you ?
I am fine .
Whats going on ?
Hows your life ?
Is everthing fine ?
[tybsc1@localhost ~]$

[tybsc1@localhost ~]$ cp g7 b2
[tybsc1@localhost ~]$ cat b2
Johny Johny ,Yes Papa

DEPARTMENT OF COMPUTER SCIENCE Page 31


BNN COLLEGE BHIWANDI
CLASS: FYCS

Eating Sugar ? no papa!


Telling lies?
No Papa !
open your mouth ..
Ha Ha Ha !

[tybsc1@localhost ~]$ cp h8 c3
[tybsc1@localhost ~]$ cat c3
Always forgive your enemy but don't forget their names!
Old is Gold
Simple Living High Thinking
Honesty is the best policy
Love everyone

31)[tybsc1@localhost ~]$ cat a1 b2 c3 >testfile


[tybsc1@localhost ~]$ cat testfile

Hello everyone !
How are you ?
I am fine .
Whats going on ?
Hows your life ?
Is everthing fine ?
Johny Johny ,Yes Papa
Eating Sugar ? no papa!
Telling lies?
No Papa !
open your mouth ..
Ha Ha Ha !Always forgive your enemy but don't forget their names!
Old is Gold
Simple Living High Thinking
Honesty is the best policy
Love everyone

32)[tybsc1@localhost ~]$ mkdir dd1 dd2


[tybsc1@localhost ~]$

33)[tybsc1@localhost ~]$ cp a1 b2 dd1


[tybsc1@localhost ~]$ ls dd1
a1 b2

34)[tybsc1@localhost ~]$ cp f6 g7 dd2


[tybsc1@localhost ~]$ ls dd2
f6 g7
[tybsc1@localhost ~]$

35)[tybsc1@localhost ~]$ rm -r dd2


[tybsc1@localhost ~]$ ls
a1 b2 c3 d4 dd1 e5 f6 g7 h8 testfile

DEPARTMENT OF COMPUTER SCIENCE Page 32


BNN COLLEGE BHIWANDI
CLASS: FYCS

36)[tybsc1@localhost ~]$ mv a1 newa1


[tybsc1@localhost ~]$ cat newa1

Hello everyone !
How are you ?
I am fine .
Whats going on ?
Hows your life ?
Is everthing fine ?

[tybsc1@localhost ~]$ mv b2 newb2


[tybsc1@localhost ~]$ cat newb2
Johny Johny ,Yes Papa
Eating Sugar ? no papa!
Telling lies?
No Papa !
open your mouth ..
Ha Ha Ha !

37)[tybsc1@localhost ~]$ mkdir -p dir1/dir2/dir3

38)[tybsc1@localhost ~]$ cd dir1/dir2/dir3

39)[tybsc1@localhost dir3]$ pwd


/home/tybsc1/dir1/dir2/dir3

40)[tybsc1@localhost dir3]$ cat > Demo2


This is first file inn dir3
welcome

[tybsc1@localhost dir3]$ ls
Demo

[tybsc1@localhost dir3]$ cat > Demo2


This is second file in dir3.

[tybsc1@localhost dir3]$ ls
Demo Demo2

41)[tybsc1@localhost dir3]$ cd ..
[tybsc1@localhost dir2]$ cd ..
[tybsc1@localhost dir1]$ cd ..
[tybsc1@localhost ~]$ rmdir -p dir1/dir2/dir3
rmdir: dir1/dir2/dir3: Directory not empty
(Directory tree doesn't get removed becauses dir3 which is last directory and not
empty)

42)Write the Commands for the following :

DEPARTMENT OF COMPUTER SCIENCE Page 33


BNN COLLEGE BHIWANDI
CLASS: FYCS

1.List all the files and directories.


2.List all the files and directories in multicolumn format.
3.List all the files identifying directories and executable files.
4. List the Contents of the directory along with all hidden files.
5.List recursive list of all files and directories.
6.Give the file listing in reverse order.
7.Give long listing of all files and directories .(Listing all files and directories with
their attributes and file permissions.)
8.List all file names sorted by last modification time.
9.Give Listing sorted by last modification time.
10.Display all files sorted according to the extension.
11.Display all files sorted according to the extension in reverse order.
12.Display all files sorted according to the last modification time in reverse order.
13.Display all files and directories including hidden files and executable files.
14. Display detailed listing inicluding hidden files sorted in reverse order.
15.List the contents of the directory “dd1”.
16.Give listing of “dd1” with their attributes and file permissions.
17.List all file names with one screen at a time.
18.List all file names with 2 characters.
19.List all files names with 3 characters.
20.List all file names starting with a lowercase character ‘a’.
21. List all file names starting with a uppercase character ‘A’.
22. List all fie names starting with vowel.
23.List all filenames with the last character as “a’ or ‘b’ or ‘c’ or ‘d’.
24.List all file names with exactly three characters in which second character is a
vowel.
25.List all files with three characters in which first character is an uppercase letter and
second character is a digit.
26.List all filenames starting with an uppercase letter vowel and ends with a digit.
27.List all filenames in which last two characters is a digit in range 1 to 9.
28.List all filenames with four characters in which first character is ‘a’ and third
character is ‘b’.
29.List all filenames whose first character is anything other than a smallcase letter
vowel.
30.List all files and directories with five characters whose first character is in the range
a to m, second character is in the range c to z, and third character is in the range 4 to 9.
31.Find the type of all files.
32.Display and count the number of lines ,words and characters of file “demo”.
33.Display and count the number of lines of file “demo”.
34.Display and count the number of words of file “demo”.
35.Display and count the number of characters of file “demo’.
36.Display and count the number of lines ,words and characters of file “demo” and
“example ”
and “test” .
37.Count the number of all files and direrctories.
38. Count the number of all users currently logged in to the system.
39.Store the number of users currently logged in to the system in file “testdemo”.
40.Display and store the listing of all filenames in file “list ”.

DEPARTMENT OF COMPUTER SCIENCE Page 34


BNN COLLEGE BHIWANDI
CLASS: FYCS

Answers :
Write the commands for the following:

1)[tybsc1@localhost ~]$ ls
c3 d4 dd1 dir1 e5 f6 g7 h8 newa1 newb2 testfile

2)[tybsc1@localhost ~]$ ls -x
c3 d4 dd1 dir1 e5 f6 g7 h8 newa1 newb2 testfile

3)[tybsc1@localhost ~]$ ls -F
c3 d4 dd1/ dir1/ e5 f6 g7 h8 newa1 newb2 testfile

4)[tybsc1@localhost ~]$ ls -a
. .bash_history .bash_profile c3 dd1 e5 g7 .lesshst newb2
.. .bash_logout .bashrc d4 dir1 f6 h8 newa1 testfile

5)[tybsc1@localhost ~]$ ls -R
.:
c3 d4 dd1 dir1 e5 f6 g7 h8 newa1 newb2 testfile

./dd1:
a1 b2

./dir1:
dir2

./dir1/dir2:
dir3

./dir1/dir2/dir3:
Demo Demo2

6)[tybsc1@localhost ~]$ ls -r
testfile newb2 newa1 h8 g7 f6 e5 dir1 dd1 d4 c3

7)[tybsc1@localhost ~]$ ls -l
total 80
-rw-rw-r-- 1 tybsc1 tybsc1 137 Feb 14 08:36 c3
-rw-rw-r-- 1 tybsc1 tybsc1 0 Feb 14 08:17 d4
drwxrwxr-x 2 tybsc1 tybsc1 4096 Feb 14 08:54 dd1
drwxrwxr-x 3 tybsc1 tybsc1 4096 Feb 14 09:08 dir1
-rw-rw-r-- 1 tybsc1 tybsc1 0 Feb 14 08:17 e5
-rw-rw-r-- 1 tybsc1 tybsc1 98 Feb 14 08:20 f6
-rw-rw-r-- 1 tybsc1 tybsc1 99 Feb 14 08:24 g7
-rw-rw-r-- 1 tybsc1 tybsc1 137 Feb 14 08:29 h8
-rw-rw-r-- 1 tybsc1 tybsc1 98 Feb 14 08:34 newa1
-rw-rw-r-- 1 tybsc1 tybsc1 99 Feb 14 08:35 newb2
-rw-rw-r-- 1 tybsc1 tybsc1 334 Feb 14 08:38 testfile

DEPARTMENT OF COMPUTER SCIENCE Page 35


BNN COLLEGE BHIWANDI
CLASS: FYCS

8)[tybsc1@localhost ~]$ ls -t
dir1 dd1 testfile c3 newb2 newa1 h8 g7 f6 d4 e5

9)[tybsc1@localhost ~]$ ls -lt


total 80
drwxrwxr-x 3 tybsc1 tybsc1 4096 Feb 14 09:08 dir1
drwxrwxr-x 2 tybsc1 tybsc1 4096 Feb 14 08:54 dd1
-rw-rw-r-- 1 tybsc1 tybsc1 334 Feb 14 08:38 testfile
-rw-rw-r-- 1 tybsc1 tybsc1 137 Feb 14 08:36 c3
-rw-rw-r-- 1 tybsc1 tybsc1 99 Feb 14 08:35 newb2
-rw-rw-r-- 1 tybsc1 tybsc1 98 Feb 14 08:34 newa1
-rw-rw-r-- 1 tybsc1 tybsc1 137 Feb 14 08:29 h8
-rw-rw-r-- 1 tybsc1 tybsc1 99 Feb 14 08:24 g7
-rw-rw-r-- 1 tybsc1 tybsc1 98 Feb 14 08:20 f6
-rw-rw-r-- 1 tybsc1 tybsc1 0 Feb 14 08:17 d4
-rw-rw-r-- 1 tybsc1 tybsc1 0 Feb 14 08:17 e5
[tybsc1@localhost ~]$

10)[tybsc1@localhost ~]$ ls -X
c3 d4 dd1 dir1 e5 f6 g7 h8 newa1 newb2 testfile

11)[tybsc1@localhost ~]$ ls -Xr


testfile newb2 newa1 h8 g7 f6 e5 dir1 dd1 d4 c3

12)[tybsc1@localhost ~]$ ls -rt


e5 d4 f6 g7 h8 newa1 newb2 c3 testfile dd1 dir1
[tybsc1@localhost ~]$

13)[tybsc1@localhost ~]$ ls -aF


./ .bash_history .bash_profile c3 dd1/ e5 g7 .lesshst newb2
../ .bash_logout .bashrc d4 dir1/ f6 h8 newa1 testfile

14)[tybsc1@localhost ~]$ ls -ar


testfile newa1 h8 f6 dir1 d4 .bashrc .bash_logout ..
newb2 .lesshst g7 e5 dd1 c3 .bash_profile .bash_history .
[tybsc1@localhost ~]$

15)[tybsc1@localhost ~]$ ls dd1


a1 b2

16)[root@localhost tybsc1]# ls -l dd1/


total 16
-rw-rw-r-- 1 tybsc1 tybsc1 98 Feb 14 08:54 a1
-rw-rw-r-- 1 tybsc1 tybsc1 99 Feb 14 08:54 b2

17)[root@localhost tybsc1]# ls |more


abc

DEPARTMENT OF COMPUTER SCIENCE Page 36


BNN COLLEGE BHIWANDI
CLASS: FYCS

Abcd
abhishek
Alpha
c3
d4
dd1
dir1
e5
enigma
f6
g7
h8
newa1
newb2
testfile

18)[root@localhost tybsc1]# ls ??
c3 d4 e5 f6 g7 h8

19)[root@localhost tybsc1]# ls ???


abc

dd1:
a1 b2
[root@localhost tybsc1]#

20)[root@localhost tybsc1]# ls a*
abc abhishek

21)[root@localhost tybsc1]# ls A*
Abcd Alpha

22)[root@localhost tybsc1]# ls [a,e,i,o,u]*


abc abhishek e5 enigma

23)[root@localhost tybsc1]# ls *[a,b,c,d]


abc Abcd Alpha enigma

24)[root@localhost tybsc1]# ls ?[a,e,i,o,u,A,E,I,O,U]?


bad big boy CAN fat mAn

25)[root@localhost tybsc1]# ls [A-Z][0-9]?


A2Z B1D C5s D2d

26)[root@localhost tybsc1]# ls [A,E,I,O,U]*[0-9]


Aero1 Enigma3 Intel8

27)[root@localhost tybsc1]# ls *[1-9][1-9]

DEPARTMENT OF COMPUTER SCIENCE Page 37


BNN COLLEGE BHIWANDI
CLASS: FYCS

alpha911 Gama64 x86

28)[root@localhost tybsc1]# ls a?b?


anbc

29)[root@localhost tybsc1]# ls [!a,e,i,o,u]*


A2Z Alpha big C5s d4 fat h8 newa1 x86
Abcd B1D boy CAN Enigma3 g7 Intel8 newb2
Aero1 bad c3 D2d f6 Gama64 mAn testfile

dd1:
a1 b2

dir1:
dir2

30)[root@localhost tybsc1]# ls [a-m][c-z][4-9]??


mu8we

31)[root@localhost tybsc1]# file *


A2Z: empty
abc: empty
Abcd: empty
abhishek: empty
Aero1: empty
Alpha: empty
alpha911: empty
anbc: empty
B1D: empty
bad: empty
big: empty
boy: empty
c3: ASCII English text
C5s: empty
CAN: empty
D2d: empty
d4: empty
dd1: directory
dir1: directory
e5: empty
enigma: empty
Enigma3: empty
f6: ASCII text
fat: empty
g7: ASCII text
Gama64: empty
h8: ASCII English text
Intel8: empty

DEPARTMENT OF COMPUTER SCIENCE Page 38


BNN COLLEGE BHIWANDI
CLASS: FYCS

mAn: empty
mu8we: empty
newa1: ASCII text
newb2: ASCII text
testfile: ASCII English text
x86: empty

32)[root@localhost tybsc1]# wc demo


4 26 148 demo

33)[root@localhost tybsc1]# wc -l demo


4 demo

OR
[root@localhost tybsc1]# cat demo|wc -l
4

34)[root@localhost tybsc1]# wc -w demo


26 demo

35)[root@localhost tybsc1]# wc -c demo


148 demo

36)[root@localhost tybsc1]# wc demo example test


4 26 148 demo
6 29 170 example
7 35 217 test
17 90 535 total

37)[root@localhost tybsc1]# ls |wc -l


39

38)[root@localhost tybsc1]# who |wc -l


1

39)[root@localhost tybsc1]# who |wc -l>testdemo


[root@localhost tybsc1]# cat testdemo
1

40)[root@localhost tybsc1]# ls |tee list


A2Z
abc
Abcd
abhishek
Aero1
Alpha
alpha911

DEPARTMENT OF COMPUTER SCIENCE Page 39


BNN COLLEGE BHIWANDI
CLASS: FYCS

anbc
B1D
bad
big
boy
c3
C5s
CAN
D2d
d4
dd1
demo
dir1
e5
enigma
Enigma3
example
example~
f6
fat
g7
Gama64
h8
Intel8
mAn
mu8we
newa1
newb2
test
test~
testdemo
testfile
x86

DEPARTMENT OF COMPUTER SCIENCE Page 40


BNN COLLEGE BHIWANDI
CLASS: FYCS

PRACTICAL NO. 5

Aim: File Operations

TAC COMMAND
REV COMMAND

Paste command

DEPARTMENT OF COMPUTER SCIENCE Page 41


BNN COLLEGE BHIWANDI
CLASS: FYCS

PRACTICAL NO. 6

Aim: Use Environment

who command
whoami command
whereis command
pwd command

history command

DEPARTMENT OF COMPUTER SCIENCE Page 42


BNN COLLEGE BHIWANDI
CLASS: FYCS

alias command

DEPARTMENT OF COMPUTER SCIENCE Page 43


BNN COLLEGE BHIWANDI
CLASS: FYCS

PRACTICAL NO. 7

Aim: Vi editor

Vi is the standard file editor for Unix and Vim is the standard file editor for Linux

For Red hat Linux vi and Vim both are same

There are three mode of vi editor

1. command mode
2. insert mode
3. save and Exit Mode

1. Command mode is again divided into 3 mode :

a. Cursor movement
b. Copy, paste, delete, undo
c. Text search

a) Cursor Movement :

 J : Down
 K : UP
 L : RIGHT
 H : LEFT
b. Copy, paste delete, undo :

 dd : delete particular line


 yy : copy particular line
 u : Undo
 p : paste
 ndd : n is the number of line to be deleted
 nyy : n is the number of line to be copied

DEPARTMENT OF COMPUTER SCIENCE Page 44


BNN COLLEGE BHIWANDI
CLASS: FYCS

2. Insert Mode

Option i, insert, a ,o, O

i : insert mode start at the point where cursor is. Same is used with

insert option

a : insert mode start after one character

o : insert mode start after one line

Save and Exit

:qQuiet

:q! forcely quiet

:wq! save and forcely quiet

:wq save and exit

DEPARTMENT OF COMPUTER SCIENCE Page 45


BNN COLLEGE BHIWANDI
CLASS: FYCS

PARCTICAL NO. 8

Aim: Linux Security

add new user


add password to newuser
delete newuser

DEPARTMENT OF COMPUTER SCIENCE Page 46


BNN COLLEGE BHIWANDI
CLASS: FYCS

PRACTICAL NO. 9

Aim: Network

SETUP: SETUP command is used for changing the IP address manually


Step 1:Type the ”Setup” command.
#setup

Step 2: select the Network configuration.

Step 3: Select the New Device.

DEPARTMENT OF COMPUTER SCIENCE Page 47


BNN COLLEGE BHIWANDI
CLASS: FYCS

Step 4: Network Configuration as Ethernet and click on Add.

Step 5: Fill up the Devernet Configuration.

DEPARTMENT OF COMPUTER SCIENCE Page 48


BNN COLLEGE BHIWANDI
CLASS: FYCS

Step 6:After Configuration and Save Exit.

Ping command

DEPARTMENT OF COMPUTER SCIENCE Page 49


BNN COLLEGE BHIWANDI
CLASS: FYCS

ifconfig command

traceroute command

DEPARTMENT OF COMPUTER SCIENCE Page 50


BNN COLLEGE BHIWANDI
CLASS: FYCS

route command

DEPARTMENT OF COMPUTER SCIENCE Page 51


BNN COLLEGE BHIWANDI
CLASS: FYCS

PRACTICAL NO. 10

Aim: Shell Scripting

Q.1 Write a shell script to the positive and negative numbers

#!/bin/sh

echo "please Enter the the number="


read a
if [ $a -gt 0 ]
then
echo "Positive Number"
else
if [ $a -lt 0 ]
then
echo "Negative Number"
else
echo "Zero"
fi
fi

Q.2 Write a shell script to find given file exists or not exists

#!/bin/sh

echo "enter the filename="


read f
if [ -e $f ]
then
echo "File exists"
else
echo "File not exists"
fi

Q.3 Write a shell script to find factorial of given number

#!/bin/sh

echo "Enter the number="

DEPARTMENT OF COMPUTER SCIENCE Page 52


BNN COLLEGE BHIWANDI
CLASS: FYCS

read a

fact=1

while [ $a -gt 1 ]
do
fact=$(($fact * $a))
a=$(($a-1))
done
echo $fact

Q.4 Write a shell script to find leap year

#!/bin/sh

echo "Enter the year="


read year

year=$(( $year % 4))

if [ $year -eq 0 ]
then
echo "leap year"
else
echo "Not leap year"
fi

Q.5 Write a shell script to find the given number is even or odd

#!/bin/sh

echo "Enter the number="


read n

n=$(( $n % 2 ))

if [ $n -eq 0 ]
then
echo "Even Number"
else
echo "Odd Number"
fi

Q.6 Write a shell program to execute the following commands :


To display the calendar of the current year of the current month.
To Display today’s date.
To display the list of all uses currently logged in.

DEPARTMENT OF COMPUTER SCIENCE Page 53


BNN COLLEGE BHIWANDI
CLASS: FYCS

To display the message is “HELLO WORLD”.


To perform some calculations.

command
[root@localhost tybsc1]# vi prog1
echo "The Calender of month and year."
cal

echo "Today's Date:"


date

echo "List of Current Users :"


who
echo "Message hello World"
bc

O/P:
[root@localhost tybsc1]# sh prog1
The Calender of month and year.
March 2017
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Today's Date:
Fri Mar 3 20:30:09 IST 2017
List of Current Users :
root pts/0 2017-03-03 18:15 (:0.0)
root pts/1 2017-03-03 19:41 (:0.0)
root pts/2 2017-03-03 20:29 (:0.0)
Message hello World
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
4*5
20
5*8
40
8/4
2

Q.7 Write a shell program to execute the following commands :


To Display present working directory.
To Display today’s date and time on two different lines.

DEPARTMENT OF COMPUTER SCIENCE Page 54


BNN COLLEGE BHIWANDI
CLASS: FYCS

To display your terminal address.


To display login name of the user currently logged in.
To Display all processes of the user.
To display all files and directories in current working directory.

command

[root@localhost ~]# vi prog2

echo "The Present working directory"


pwd
echo "Today's date and current time is :"
date "+DATE%D%nTime%T"
echo "My Terminal address:"
tty

O/P:

[root@localhost ~]# vi prog2


echo "Login name of user currently logged in is :"
who am i
echo "All process of the user is:"
ps
echo "All process of the user is :"
ls

[root@localhost ~]# sh prog2


The Present working directory
/root
Today's date and current time is :
DATE03/03/17
Time20:53:56
My Terminal address:
/dev/pts/1
Login name of user currently logged in is :
root pts/1 2017-03-03 19:41 (:0.0)
All process of the user is:
PID TTY TIME CMD
4267 pts/1 00:00:00 bash
4581 pts/1 00:00:00 sh
4585 pts/1 00:00:00 ps
All process of the user is :
anaconda-ks.cfg install.log prog2 test_u1
coast install.log.syslog sor_coast Tybsc
Desktop prog1 sor_west west

DEPARTMENT OF COMPUTER SCIENCE Page 55


BNN COLLEGE BHIWANDI
CLASS: FYCS

Q.8 Write a shell script to initialize values to two variables and perform +,-,*,/ between
two numbers and print the result.
command

a) #!/bin/sh

echo "enter the number"


read a
echo "enter the number"
read b
let "c=$a+$b"
#echo "the output is ="$(($a+$b))
echo "The addtion is="$c
O/P
The addition of 10+20 is 30

b) #!/bin/sh

echo "enter the number"


read a
echo "enter the number"
read b
let "c=$a-$b"
#echo "the output is ="$(($a-$b))
echo "The substraction is="$c
O/P
The substraction of 30-20 is 10

c) #!/bin/sh

echo "enter the number"


read a
echo "enter the number"
read b
let "c=$a*$b"
#echo "the output is ="$(($a*$b))
echo "The multiplication is="$c
O/P
The multiplication of 10*20 is 200

d) #!/bin/sh

echo "enter the number"


read a
echo "enter the number"
read b
let "c=$a/$b"
#echo "the output is ="$(($a/$b))
echo "The division is="$c
O/P
The division of 10/5 is 2

DEPARTMENT OF COMPUTER SCIENCE Page 56


BNN COLLEGE BHIWANDI
CLASS: FYCS

Q.9 Write a shell script to read a number from user and check whether it is greater
than 10 or not .

command

[root@localhost ~]# vi prog5

echo "Enter any number"


read x
if [ $x -gt 10 ]
then
echo "$x is greater than 10"
else
echo "$x is not greater than 10"
fi

O/P:
[root@localhost ~]# sh prog5
Enter any number
5
5 is not greater than 10
[root@localhost ~]# sh prog5
Enter any number
12
12 is greater than 10

Q.10 Write a shell script to read two numbers from user nd find the greater of two.

command

[root@localhost ~]# vi prog10

echo "enter two number"


read x y
if [ $x -gt $y ]
then
echo "$x is greater"
else
echo "$y is greater"
fi

o/p

root@localhost ~]# sh prog10


enter two number
32 23
32 is greater

DEPARTMENT OF COMPUTER SCIENCE Page 57

You might also like