Sei sulla pagina 1di 18

Ex.No.

1a

Reg.No: 16507613 Name: KUMARESAN

LOGIN:
login as: KALAI
KALAI@172.18.1.225's password:
Last login: Thur Jun 9 15:37:02 2016 from 172.18.1.191

[KALAI@KUMARESAN ~]$

LOGOUT:
[KALAI@KUMARESAN ~]$exit

Ex.No.1b

Reg.No: 16507613 Name: KUMARESAN

ls
[KALAI@KUMARESAN ~]$ ls KALAI

kumar kumaresasn yokesh

cd
[KALAI@KUMARESAN ~]$ cd KALAI
[KALAI@KUMARESAN KALAI]$

pwd
[KALAI@KUMARESAN ~]$ pwd

/home/KALAI/KALAI

mkdir
[KALAI@KUMARESAN ~]$ mkdir linux

rmdir
[KALAI@KUMARESAN ~]$ rmdir linux

Ex.No.1c
Reg.No: 16507613 Name: KUMARESAN

cat
[KALAI@KUMARESAN ~]$ cat> yokesh
kumar
kumaresan
raja
kuna

chmod
[KALAI@KUMARESAN ~]$ chmod 641 friend
[KALAI@KUMARESAN ~] ls –l friend
-rw-r----x 1 KALAI KALAI 25 2016-06-23 13:09 friend

[KALAI@KUMARESAN ~]$ chmod 2 yokesh

cp
[KALAI@KUMARESAN ~]$ cp kumaresan KALAI
[KALAI@KUMARESAN ~]$ cat KALAI
kumar
kumaresan
raja
kuna

mv
[KALAI@KUMARESAN ~]$ mv kumaresan KALAI
[KALAI@KUMARESAN ~]$ cat KALAI
kumar
kumaresan
raja
kuna

rm
[KALAI@KUMARESAN ~]$ rm kumaresan

more
[KALAI@KUMARESAN ~]$ more kumaresan
KALAI
kumar
yokesh
raja
kunasekar

Reg.No: 16507613 Name: KUMARESAN


diff
[KALAI@KUMARESAN ~]$ diff kumaresan friend

1,3c1,2

< KALAI
< kumar
< yokesh
---
> kumaresan
> saravanan
5c4
< kunasekar
---
> yokesh

[KALAI@KUMARESAN ~]$ diff -w kumaresan friend

1,3c1,2
< KALAI
< kumar
< yokesh
---
> kumaresan
> saravanan
5c4
< kunasekar
---
> yokesh

cmp
[KALAI@KUMARESAN ~]$ cmp kumaresan friend

kumaresan friend differ: byte 1, line 1

Ex.No. 2

Reg.No: 16507613 Name: KUMARESAN


wc
[KALAI@KUMARESAN ~]$ wc kumaresan
5 5 32 kumaresan

od
[KALAI@KUMARESAN ~]$ od kumaresan

0000000 071163 005151 072553 060555 005162 067571 062553 064163

0000020 071012 065141 005141 072553 060556 062563 060553 005162

0000040

ip
[KALAI@KUMARESAN ~]$ ip kumaresan
Object "kumaresan" is unknown, try "ip help".

cal
[KALAI@KUMARESAN ~]$ cal 4 2016

April 2016
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

date
[KALAI@KUMARESAN ~]$ date
Mon Aug 8 12:11:33 IST 2016

who
[KALAI@KUMARESAN ~]$ who
KALAI tty1 2016-08-08 11:51 (:0)
KALAI pts/0 2016-08-08 11:53 (:0.0)

tty
[KALAI@KUMARESAN ~]$ tty
/dev/pts/0
Reg.No: 16507613 Name: KUMARESAN

ln
[KALAI@KUMARESAN ~]$ ln kumaresan raja
[KALAI@KUMARESAN ~]$ cat raja
KALAI
kumar
kalai
kannan
yokesh
raja
kunasekar

Ex.No.3

Reg.No: 16507613 Name: KUMARESAN

pr
[KALAI@KUMARESAN ~]$ pr kumaresan

2016-08-08 12:01 kumaresan Page 1


KALAI
kumar
yokesh
raja
kunasekar

head
[KALAI@KUMARESAN ~]$ head -3 kumaresan
KALAI
kumar
yokesh

tail
[KALAI@KUMARESAN ~]$ tail -3 kumaresan
yokesh
raja
kunasekar

cut
[KALAI@KUMARESAN ~]$ cut -c 3 kumaresan
i
m
k
j
n
Reg.No: 16507613 Name: KUMARESAN

paste
[KALAI@KUMARESAN ~]$ paste kumaresan friend

KALAI kumaresan
kumar saravanan
yokesh raja
raja yokesh
kunasekar

nl
[KALAI@KUMARESAN ~]$ nl kumaresan

1 KALAI
2 kumar
3 yokesh
4 raja
5 kunasekar

sort
[KALAI@KUMARESAN ~]$ sort kumaresan

kumar
kunasekar
raja
KALAI
yokesh

Ex.No.4

Reg.No: 16507613 Name: KUMARESAN

grep
[KALAI@KUMARESAN ~]$ cat>profit
hai
hello
welcome to linux lab
^Z
[9]+ Stopped cat > profit
[KALAI@KUMARESAN ~]$ cat>loss
hai friend
how are you
^Z
[10]+ Stopped cat > loss
[KALAI@KUMARESAN ~]$ grep hello profit
hello

egrep
[KALAI@KUMARESAN ~]$ egrep [k] kumaresan

kumar
yokesh
kunasekar

fgrep
[KALAI@KUMARESAN ~]$ fgrep hai profit loss
profit:hai
loss:hai friend

Ex.No.5

Reg.No: 16507613 Name: KUMARESAN

ps
[KALAI@KUMARESAN ~]$ ps

PID TTY TIME CMD


2074 pts/0 00:00:00 bash
2264 pts/0 00:00:00 ps

nohup
[KALAI@KUMARESAN ~]$ nohup ls
nohup: ignoring input and appending output to `nohup.out'

[KALAI@KUMARESAN ~]$ tail nohup.out


value.sh
values.sh
cse
decrement
decrement.sh
file
nohup.out

kill
[KALAI@KUMARESAN ~]$ kill -9 2974
[KALAI@KUMARESAN ~]$
[1]+ Killed cat > file

nice
[KALAI@KUMARESAN ~]$ nice -15 cat
^Z
[1]+ Stopped nice -15 cat
[KALAI@KUMARESAN ~]$ ps -l
F S UID PID PPID C PRI NI TTY TIME CMD
0 S 501 3421 3420 0 80 0 pts/1 00:00:00 bash
0 T 501 3447 3421 0 95 15 pts/1 00:00:00 cat
0 R 501 3448 3421 1 80 0 pts/1 00:00:00 ps

Ex.No. 6

Reg.No: 16507613 Name: KUMARESAN

write
[KALAI@KUMARESAN ~]$ write KALAI
Message from KALAI@localhost.localdomain on pts/2 at 15:02 ...
Welcome to linux lab
EOF

mail
[KALAI@KUMARESAN ~]$ mail KALAI
Subject: hai
Cc: hai students
[KALAI@KUMARESAN ~]$ /home/KALAI/dead.letter... Saved message in
/home/KALAI/dead.letter

wall
[KALAI@KUMARESAN ~]$ wall
hai to all
Broadcast message from KALAI (pts/2) (Mon Jul 4 15:12:50 2012):
hai to all

Ex.No. 7

Reg.No: 16507613 Name: KUMARESAN

Display all two character filenames


[KALAI@KUMARESAN kumar]$ ls ??

Raja
Yokesh
Kalai
Kannan

Display all filenames consisting of two lowercase letters


[KALAI@KUMARESAN kumar]$ ls *[a-z]??

Raja:
Yokesh:

Display all filenames ending with “c”


[KALAI@KUMARESAN kumar]$ ls *c

Music:
Public:

[KALAI@KUMARESAN ~]$ ls *[s]

Documents:
Downloads:
Pictures:
Templates:
Videos:

Display all filenames starting with a “c” and ending with a “digit”
[KALAI@KUMARESAN ~]$ ls c*[0-9]

c1:
c2:
c3:

Display all filenames beginning with “p” and having at somewhere


[KALAI@KUMARESAN ~]$ ls p*?p*

Peper

Paper

Ex.No. 5

Reg.No: 16507613 Name: KUMARESAN

[KUMARESAN@KALAI ~]$ vi filename.sh

#!/bin/bash
ps -u

[KUMARESAN@KALAI ~]$ sh filename.sh


Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND

KUMARESAN 26467 0.0 0.3 5112 1652 pts/0 Ss 07:54 0:00 bash

KUMARESAN 26728 0.0 0.2 5048 1064 pts/0 S+ 08:10 0:00 sh file name

KUMARESAN 26729 0.0 0.1 4764 1008 pts/0 R+ 08:10 0:00 ps -u

Ex.No.7

Reg.No: 16507613 Name: KUMARESAN

[KUMARESAN@KALAI ~]$ vi question.sh

echo "unix is"


echo "a)an turkish assistaint manager club"
echo "b)united organization"
echo "c)computer os"
echo "d)all of the above"
read answer
case $answer in
a)echo wrong -the answer is c;;
b)echo wrong -the answer is c;;
c)echo right answer;;
d)echo wrong -the answer is c;;
esac
[KUMARESAN@KALAI ~]$ sh question.sh

unix is
a)an turkish assistaint manager club
b)united organization
c)computer os
d)all of the above
a
wrong -the answer is c

[KUMARESAN@KALAI ~]$ sh question


unix is
a)an turkish assistaint manager club
b)united organization
c)computer os
d)all of the above
c
rignt answer

Ex.No. 8a

Reg.No: 16507613 Name: KUMARESAN

[KUMARESAN@KALAI ~]$ vi determine

#!/bin/bash
if [ $# -ne 1 ]
then
echo "usage -$o file name"
exist 1
fi
if [ -f $1 ]
then
echo "$1 file exist"
else
echo "sorry, $1 file dose not exist"
fi

[KUMARESAN@KALAI ~]$ sh determine kalai


kalai file exist

Ex.No. 8b

Reg.No: 16507613 Name: KUMARESAN

[KUMARESAN@KALAI ~]$ vi report


for name
do
if test -d $name
then
echo "$ name is a directory"
elif test -f $name
then
echo "$name is a file"
else
echo "i don't know what $name is"
fi
done

[KUMARESAN@KALAI ~]$ sh report kumar

kumar is a directory

EX NO 4.B

Reg.No: 16507613 Name: KUMARESAN

[KUMARESAN@KALAI ~]$ vi format.sh

#!bin/bash
TODAY=$(date +”%X%Z%a%d%b%Y”
echo “--------------------“
echo today date:$TODAY”
echo “----------------------“

[KUMARESAN@KALAI ~]$ sh formate.sh

Today date:02:15:54 pm EDT Thu 30 aug 2016


EX NO4A

Reg.No: 16507613 Name: KUMARESAN

[KUMARESAN@KALAI ~]$ vi good.sh

hours=`date|cut -c12-13`
if [ $hours -le 12 ]
then
echo "Good Morning"
else
if [ $hours -le 16 ]
then
echo "Good Afternoon"
elif [ $hours -le 20 ]
then
echo "Good Evening"
else
echo "Good Night"
fi
fi

[KUMARESAN@KALAI kumar]$ sh good


.sh

Good Afternoon

Ex.No.2

Reg.No:16507614 Name:Srikumar

[SRIKUMAR@SRI ~]$ vi copy.sh


echo "Enter dest file:"
read d
echo "Enter file1:"
read f1
echo "Enter file2:"
read f2
cat $f1 $f2 > $d
status=$?
if [ $status -eq 0 ]
then
echo "file copied successfully"
else
echo "problem in copying file"
fi

OUTPUT:

[SRIKUMAR@SRI ~] $ cat>f1
BEEE
Operating Systems
C Programming
[SRIKUMAR@SRI ~]$ cat>f2
BEEE Lab
Linux Practical
C Programming Practical
CA Practical

[SRIKUMAR@SRI ~]$ cat f3


elcot@elcot[~]$sh copy.sh
Enter dest file:
f3
Enter file1:
f1
Enter file2:

f2
file copied successfully

[SRIKUMAR@SRI ~]$ sh copy.sh


Enter dest file: f3
Enter file1: f1
Enter file2:
f6
cat: NAME : BHARATH .S REG NO : 16500791
EX 6

[BH@BHARATH~]$ vi cals .sh


Read n
Case “$n’im
1)”
Echo”aaddition
F3=$((f1+f2))
Echo”the result is:$ f3”
;;
2)
Echo “subtraction”
let “f4=$f1 -$f2”
echo “the result is :$f4”
;;
3)
Echo “Multiplication”
Let “ f5 =$f1 * $f2”
Echo : the result is: $f5”
;;
4)
Echo “Division”
Let “ f6 =$f1/$f2”
;;
Esac
Echo” Do you want to continue(press:1 otherwish press any key to
quit)”
read j
done

[BH@BHARATH~] $ sh calc .sh


Enter the First Operand;
34
The second Operand;
45
1->Addition
2->subtraction
3->multiplication
4->Division
Enter your choice
1
Addition
The result is :79

f6: No such file or directory


problem in copying file
Ex. No.3

Reg.No:16507614 Name:Srikumar

[SRIKUMAR@SRI ~]$ vi file.sh


echo "Enter file name:"
read f
sed -n '3,5p' "$f"

OUTPUT:

[SRIKUMAR@SRI ~]$ sh line.sh


Enter a file name:
display
read n
while [$n-ge 0]
do
NAME: BHARATH.S
ex 1
REG NO: 16500791

[BH@BHARATH~]$ vi decrement.sh
#!bin/bash
Echo ”Enter a numberical value”
read i
Echo “the decremented values are”
While test $i – ne 0

DO
Echo “$i”
I= expr$i-1

[BH@BHARATH~]$ sh decrement.sh
Enter a numerical value
5
The decremented value are
5
4
3
2
1
0

[BH@BHARATH localhost ~ ]$ vi copy.sh


Each “ Enter dest file:”
Read d
Echo “Enter file 1:”
Read 1
Echo “Enter file 2:”
Read f2
cat $ f1 $f2 > $d
status=$?
If[$status-eq 0]
Then
Echo “file copied successfully”
Else
Echo ”problem in copying file”
Fi
Output:
[BH@BHARATH LOACKHOST~] $ cat>fl
English
Eg
[BH@BHARATH LOACKHOST~] $ cat>f2
English
Physics practical
Ca practical
Linux practical

[BH@BHARATH LOACKHOST~] $ cat>f3


[BH@BHARATH LOACKHOST~] $ sh copy.sh
Enter dest file:
F3
Enter file 1:
F1
Enter file2:
F2
File copyed successfully

[BH@BHARATH LOACKHOST~] $ sh copy.sh


Enter dest file : f3
Enter file :fl
Enter file2:
F6
Cat:f6: No such file or directory
Problem in copying file

Potrebbero piacerti anche