BASIC NETWORK COMMANDS
[user1@localhost user1]$ cat>file
we can create a file
[user1@localhost user1]$ ls -l
-rw-r--r-- 1 user1 26jpmc 37 Dec 2 19:11 file
drwxr-xr-x 2 user1 26jpmc 4096 Dec 2 14:09 anbu
[user1@localhost user1]$ chmod 777 file
[user1@localhost user1]$ ls -l
-rwxrwxrwx 1 user1 26jpmc 37 Dec 2 19:11 file
drwxr-xr-x 2 user1 26jpmc 4096 Dec 2 14:09 anbu
[user1@localhost user1]$ rm file
[user1@localhost user1]$ pwd
/home/26jpmc/user1
[user1@localhost user1]$ mkdir new
user1@localhost user1]$ ls
new anbu
[user1@localhost user1]$ rmdir new
[user1@localhost user1]$ cd anbu
[user1@localhost anbu]$ ls
fact fon ooe sal
[user1@localhost anbu]$ cp sal salary
[user1@localhost anbu]$ mv ooe odd
[user1@localhost anbu]$ logname
User2
[user1@localhost anbu]$ id
uid=541(user1) gid=501(26jpmc) groups=501(26jpmc)
[user1@localhost anbu]$ uname
Linux
[user1@localhost anbu]$ tty
/dev/pts/6
[user1@localhost anbu]$ who
User3 pts/5 Dec 1 18:48 (170.100.40.46)
User4 pts/14 Dec 1 18:49 (170.100.40.1)
user5 pts/7 Dec 1 18:51 (170.100.40.19)
user6 pts/4 Dec 1 19:17 (170.100.40.3)
[user1@localhost anbu]$ who am i
User7 pts/6 Dec 1 20:09 (170.100.40.45)
[user1@localhost anbu]$ cal
December 1999
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
Factorial number:
echo enter the number
read n
i=1
f=1
while [ $i -le $n ]
do
f=` expr $i \* $f `
i=` expr $i \+ 1 `
done
echo result is $f
[user1@localhost anbu]$ sh fact
enter the number
4
result is 24
Odd or Even:
echo enter the number
read a
f=` expr $a % 2 `
if test $f -eq 1
then
echo $a is ood
else
echo $a is even
fi
[user1@localhost anbu]$ sh odd
enter the name
11
11 is odd
Basic Salary:
echo enter the basic salary
read bs
if [ $bs -lt 1500 ]
then
hra=` echo $bs \* 10 / 100 bc `
da=` echo $bs \* 90 / 100 bc `
else
hra=500
dra=` echo $bs \* 98 / 100 bc `
fi
gs=` echo $bs + $hra + $da bc `
echo gs=Rs. $gs
[user1@localhost anbu]$ sh sal
enter the basic salary
1200
gs=Rs. 2400
File or Not:
echo enter the file name
read fname
if [ -f $fname ]
then
echo filename
else
echo not filename
fi
[user1@localhost anbu]$ sh fon
enter the file name
salary
filename
Thursday, February 4, 2010
Subscribe to:
Posts (Atom)