Cs Linux
Cs Linux
CLASS: FYCS
PRACTICAL NO. 1
Step 7: Select the devices that we required for our Linux operating system.
Step 14: Provide mount point & file system type and click on next.
Step 21: Set the date and time for the System.
PRACTICAL NO. 2
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
PRACTICAL NO. 3
Aim: Documentations
info grep
man grep
man ls
man zip
PRACTICAL NO. 4
Aim : Basic Linunx Commands such as file and directory manipulation ,redirection
and piping.
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:
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)
2^6
64
viii)
12*12;12/6
144
2.00
ix)ibase=2
11001010
202
x)obase=2
14
1110
Hello everyone !
How are you ?
I am fine .
Whats going on ?
Hows your life ?
Is everthing fine ?
Hello everyone !
How are you ?
I am fine .
Whats going on ?
Hows your life ?
Is everthing fine ?
No Papa !
open your mouth ..
Ha Ha Ha !
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
[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
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
Hello everyone !
How are you ?
I am fine .
Whats going on ?
Hows your life ?
Is everthing fine ?
[tybsc1@localhost dir3]$ ls
Demo
[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)
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
8)[tybsc1@localhost ~]$ ls -t
dir1 dd1 testfile c3 newb2 newa1 h8 g7 f6 d4 e5
10)[tybsc1@localhost ~]$ ls -X
c3 d4 dd1 dir1 e5 f6 g7 h8 newa1 newb2 testfile
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
dd1:
a1 b2
[root@localhost tybsc1]#
20)[root@localhost tybsc1]# ls a*
abc abhishek
21)[root@localhost tybsc1]# ls A*
Abcd Alpha
dd1:
a1 b2
dir1:
dir2
mAn: empty
mu8we: empty
newa1: ASCII text
newb2: ASCII text
testfile: ASCII English text
x86: empty
OR
[root@localhost tybsc1]# cat demo|wc -l
4
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
PRACTICAL NO. 5
TAC COMMAND
REV COMMAND
Paste command
PRACTICAL NO. 6
who command
whoami command
whereis command
pwd command
history command
alias command
PRACTICAL NO. 7
Aim: Vi editor
Vi is the standard file editor for Unix and Vim is the standard file editor for Linux
1. command mode
2. insert mode
3. save and Exit 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 :
2. Insert Mode
i : insert mode start at the point where cursor is. Same is used with
insert option
:qQuiet
PARCTICAL NO. 8
PRACTICAL NO. 9
Aim: Network
Ping command
ifconfig command
traceroute command
route command
PRACTICAL NO. 10
#!/bin/sh
Q.2 Write a shell script to find given file exists or not exists
#!/bin/sh
#!/bin/sh
read a
fact=1
while [ $a -gt 1 ]
do
fact=$(($fact * $a))
a=$(($a-1))
done
echo $fact
#!/bin/sh
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
n=$(( $n % 2 ))
if [ $n -eq 0 ]
then
echo "Even Number"
else
echo "Odd Number"
fi
command
[root@localhost tybsc1]# vi prog1
echo "The Calender of month and year."
cal
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
command
O/P:
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
b) #!/bin/sh
c) #!/bin/sh
d) #!/bin/sh
Q.9 Write a shell script to read a number from user and check whether it is greater
than 10 or not .
command
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
o/p