Академический Документы
Профессиональный Документы
Культура Документы
Que 1:-Write a script to give the cube (power raised to 3) of a number user inputs
Ans:--
#! /bin/bash
# Cube of user input
clear
echo -e "Enter No for cube:\c"
read numb
echo "Cube of $numb : `expr $numb \* $numb \* $numb`"
---------------------------------------------------------------------------
Ans:--
nested if then fi
#! /bin/bash
# Convertnested if then fi to multilevel if then fi
if [ $choice -eq 1 ]
then
echo "Square:`expr $num \* $num`"
else
if [ $choice -eq 2 ]
then
echo "Cube:`expr $num \* $num \* $num`"
else
echo "Thank you. Try again."
fi
fi
=======================
multilevel if then fi
#! /bin/bash
# Convert any script using nested if then fi to multilevel if then fi
if [ $choice -eq 1 ]
then
echo "Square:`expr $num \* $num`"
elif [ $choice -eq 2 ]
then
echo "Cube:`expr $num \* $num \* $num`"
else
echo "Thank you. Try again."
fi
-------------------------------------------------------------------------------------------------------
Que 3:-Write the program studied in while to give output of multiplier and multiplicand in
ascending order
Ans:--
#! /bin/bash
# while to give output of multiplier and multiplicand in ascending order
---------------------------------------------------------------------------------------------------
Que 4:--
Write any script to use loop and if then fi within one another (eg loop within if then fi
or vice versa)
Ans:--
loop within if
#! /bin/bash
# factorial
echo -e "Enter number for factorial:\c";read fact
ans=1
if [ $fact -eq 0 ]
then
echo "Ans:1"
elif [ $fact -gt 0 ]
then
for i in $(seq 1 $fact)
do
ans=$[ ans * i ]
done
echo Ans:$ans
else
echo "factorial not exist."
fi
=======================
if within loop
#! /bin/bash
# count down time bomb
echo -e "Enter second:\c"
read asd
clear
echo count down start
while [ $asd -gt -1 ]
do
if [ $asd -gt 0 ]
then
echo "$asd"
sleep 1
else
echo -e "blast off\c"
sleep 1;echo -e ".\c"
sleep 1;echo -e ".\c"
sleep 1;echo -e ".\c"
fi
asd=$[ asd - 1 ]
done
-------------------------------------------------------------------------------------------------------
Que 5:-In any multiplication example, also give the square of the answer (eg 5 * 4 = 20 400)
Ans:--
#! /bin/bash
# multiplication and its square
echo -e "Enter any two number(use space)\c";read as df
ans=`expr $as \* $df`
echo -e "Multiplication:$ans \nSquare of ans:`expr $ans \* $ans`"
------------------------------------------------------------------------------------------------------
Que 6:-Write any script with breakpoints, that is to stop and show you intermediate results
Ans:--
Ans:-ps aux
USER
root
root
2 0.0 0.0
0?
root
3 0.0 0.0
0?
root
4 0.0 0.0
0?
root
6 0.0 0.0
0?
root
7 0.0 0.0
0?
root
8 0.0 0.0
0?
root
10 0.0 0.0
0?
root
11 0.0 0.0
0?
root
12 0.0 0.0
0?
root
13 0.0 0.0
0?
root
14 0.0 0.0
0?
root
15 0.0 0.0
0?
root
16 0.0 0.0
0?
root
17 0.0 0.0
0?
root
18 0.0 0.0
0?
root
19 0.0 0.0
0?
root
20 0.0 0.0
0?
root
21 0.0 0.0
0?
root
22 0.0 0.0
0?
root
23 0.0 0.0
0?
root
25 0.0 0.0
0?
root
26 0.0 0.0
0?
root
27 0.0 0.0
0?
root
28 0.0 0.0
0?
root
29 0.0 0.0
0?
root
30 0.0 0.0
0?
root
31 0.0 0.0
0?
root
34 0.0 0.0
0?
root
35 0.0 0.0
0?
root
36 0.0 0.0
0?
root
37 0.0 0.0
0?
root
38 0.0 0.0
0?
root
39 0.0 0.0
0?
root
40 0.0 0.0
0?
root
49 0.0 0.0
0?
root
53 0.0 0.0
0?
root
54 0.0 0.0
0?
root
55 0.0 0.0
0?
root
56 0.0 0.0
0?
root
57 0.0 0.0
0?
root
58 0.0 0.0
0?
root
59 0.0 0.0
0?
root
62 0.0 0.0
0?
root
63 0.0 0.0
0?
root
65 0.0 0.0
0?
root
85 0.0 0.0
0?
root
86 0.0 0.0
0?
root
87 0.0 0.0
0?
root
88 0.0 0.0
0?
root
0?
root
0?
root
0?
root
root
root
root
0?
root
0?
root
0?
root
0?
root
0?
root
0?
root
0?
root
0?
syslog
root
0?
102
861 0.0 0.0 4244 1980 ?
--activation=upstart
root
root
avahi
880 0.0 0.0 3456 1480 ?
[ubuntu1204.local]
avahi
root
0?
root
root
root
908 0.0 0.1 26944 4304 ?
debug
root
914 0.0 0.0 5960 2040 ?
Ss 21:11 0:00 /sbin/wpa_supplicant -B -P
/run/sendsigs.omit.d/wpasupplicant.pid -u -s -O /var/run/wpa_supplicant
root
root
root
root
root
root
1023 0.0 0.0 2176 716 ?
/var/run/acpid.socket
root
root
root
1046 1.4 0.4 47532 18572 tty7 Ss+ 21:11 0:15 /usr/bin/X :0 -auth
/var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch -background none
root
daemon
root
1199 0.0 0.1 17244 4064 ?
daemon
root
root
1245 0.0 0.0 34212 3336 ?
daemon
root
root
rtkit
root
1571 0.0 0.0 2928 1300 ?
S 21:11 0:00 /sbin/dhclient -d -4 -sf
/usr/lib/NetworkManager/nm-dhcp-client.action -pf /var/run/sendsigs.omit.d/networkmanager.dhclient-eth1.pid -lf /var/lib/dhcp/dhclient-63a92590-d60f-48ba-ac95a413baeb7773-eth1.lease -cf /var/run/nm-dhclient-eth1.conf eth1
nobody 1576 0.0 0.0 5404 1156 ?
S 21:11 0:00 /usr/sbin/dnsmasq --no-resolv
--keep-in-foreground --no-hosts --bind-interfaces --pidfile=/var/run/sendsigs.omit.d/network-manager.dnsmasq.pid --listen-address=127.0.0.1
--conf-file=/var/run/nm-dns-dnsmasq.conf --cache-size=0 --proxy-dnssec
root
0?
sagar
sagar
sagar
sagar
root
root
1808 0.0 0.0 6556 732 ?
devices
sagar
sagar
sagar
sagar
sagar
sagar
5
sagar
sagar
sagar
sagar
sagar
sagar
root
2044 0.0 0.2 17980 9112 ?
service/system-service-d
root
root
root
0?
sagar
sagar
sagar
root
sagar
sagar
0?
root
0?
--------------------------------------------------------------------------------------------------
Que 2:-List all the processes running under root in your system
Ans:-ps -u root
PID TTY
TIME CMD
1?
00:00:00 init
2?
00:00:00 kthreadd
3?
00:00:00 ksoftirqd/0
4?
00:00:00 kworker/0:0
6?
00:00:00 migration/0
7?
00:00:00 watchdog/0
8?
00:00:00 migration/1
10 ?
00:00:00 ksoftirqd/1
11 ?
00:00:00 watchdog/1
12 ?
00:00:00 migration/2
13 ?
00:00:00 kworker/2:0
14 ?
00:00:00 ksoftirqd/2
15 ?
00:00:00 watchdog/2
16 ?
00:00:00 migration/3
17 ?
00:00:00 kworker/3:0
18 ?
00:00:00 ksoftirqd/3
19 ?
00:00:00 watchdog/3
20 ?
00:00:00 cpuset
21 ?
00:00:00 khelper
22 ?
00:00:00 kdevtmpfs
23 ?
00:00:00 netns
25 ?
00:00:00 sync_supers
26 ?
00:00:00 bdi-default
27 ?
00:00:00 kintegrityd
28 ?
00:00:00 kblockd
29 ?
00:00:00 ata_sff
30 ?
00:00:00 khubd
31 ?
00:00:00 md
34 ?
00:00:00 khungtaskd
35 ?
00:00:00 kswapd0
36 ?
00:00:00 ksmd
37 ?
00:00:00 khugepaged
38 ?
00:00:00 fsnotify_mark
39 ?
00:00:00 ecryptfs-kthrea
40 ?
00:00:00 crypto
49 ?
00:00:00 kthrotld
53 ?
00:00:00 kworker/1:1
54 ?
00:00:00 scsi_eh_0
55 ?
00:00:00 scsi_eh_1
56 ?
00:00:00 scsi_eh_2
57 ?
00:00:00 scsi_eh_3
58 ?
00:00:00 scsi_eh_4
59 ?
00:00:00 scsi_eh_5
62 ?
00:00:00 kworker/u:5
63 ?
00:00:00 kworker/u:6
65 ?
00:00:00 binder
85 ?
00:00:00 deferwq
86 ?
00:00:00 charger_manager
87 ?
00:00:00 devfreq_wq
88 ?
00:00:00 kworker/1:2
271 ?
00:00:00 jbd2/sda5-8
272 ?
00:00:00 ext4-dio-unwrit
290 ?
00:00:00 flush-8:0
356 ?
00:00:00 upstart-udev-br
387 ?
00:00:00 udevd
667 ?
00:00:00 upstart-socket-
668 ?
00:00:00 irq/45-mei
672 ?
00:00:00 kpsmoused
673 ?
00:00:00 ips-adjust
675 ?
00:00:00 ips-monitor
677 ?
00:00:00 cfg80211
709 ?
00:00:00 kvm-irqfd-clean
749 ?
00:00:00 hci0
750 ?
00:00:00 wl_event_handle
818 ?
00:00:00 hd-audio0
873 ?
00:00:00 modem-manager
875 ?
00:00:00 bluetoothd
884 ?
00:00:00 krfcommd
897 ?
00:00:00 NetworkManager
903 ?
00:00:00 cupsd
908 ?
00:00:00 polkitd
914 ?
00:00:00 wpa_supplicant
975 tty4
00:00:00 getty
984 tty5
00:00:00 getty
999 tty2
00:00:00 getty
1003 tty3
00:00:00 getty
1005 tty6
00:00:00 getty
1023 ?
00:00:00 acpid
1024 ?
00:00:00 lightdm
1025 ?
00:00:00 irqbalance
1046 tty7
00:00:17 Xorg
1048 ?
00:00:00 cron
1199 ?
00:00:00 accounts-daemon
1221 tty1
00:00:00 getty
1245 ?
00:00:00 console-kit-dae
1358 ?
00:00:00 upowerd
1527 ?
00:00:00 lightdm
1571 ?
00:00:00 dhclient
1631 ?
00:00:00 kworker/3:2
1807 ?
00:00:00 udisks-daemon
1808 ?
00:00:00 udisks-daemon
2044 ?
00:00:00 system-service-
2140 ?
00:00:00 udevd
2141 ?
00:00:00 udevd
2142 ?
00:00:00 kworker/2:2
2308 ?
00:00:00 kworker/0:1
2503 ?
00:00:00 kworker/0:2
------------------------------------------------------------------------------------------------------
Que 3:-Run the sleep command and place it in the background Then kill it in the background
Ans:-sleep 300
^Z
[1]+ Stopped
sleep 300
ps
PID TTY
2428 pts/2
TIME CMD
00:00:00 bash
2517 pts/2
00:00:00 sleep
2518 pts/2
00:00:00 ps
bg %1
[1]+ sleep 300 &
kill -9 %1
[1]+ Killed
sleep 300
------------------------------------------------------------------------------------------------------
Que 4:-Run the vim editor (on any file) and place it in the background. Bring it to the foreground and
kill it. Was it successful?
Ans:-vim abc.txt
^z
[1]+ Stopped
vim abc.txt
bg %1
[1]+ vim asd.txt &
[1]+ Stopped
vim abc.txt
so, we cann't put vim in backgroung. if we put it in background then it automaticaly stopped.
fg %1
then it display vim editor and so we can execute kill command when it is in foreground.
so we cannt kill in fg.
----------------------------------------------------------------------------------------------
Que 5:-Run the command $ sudo apt-get update. Put it in the background. What are the problems you
face. Try to find the cause yourself.
jobs
[1]+ Running
problem:-- by writting '&' putting into background. but when you press enter key after
writting command.
process will continue to display in terminal but cursur doesn't work in terminal.
CVS
Que 1:-List the importance of versioning software developments.
Ans:-Version Control System is a software tool, which helps in keeping track of all revisions and
releases of a project's source code.
Able to track changes made by different users and their contribution towards collabrative
development of project.
Allows multiple people to work simultaneously.
Enables retrieval of old systems.
Helps to manage different versions, releases.
Works well over LAN, WAN (server/client).
Works fine for any ASCII file.
------------------------------------------------------------------------------------------------
Que 2:-Install the CVS server and prove to yourself the creation and existence of CVSROOT.
Ans:--
--------------------------------------------------------------------------------------------------
Que 3:-What is the symbolic meaning meaning of CVSROOT. (Why is the repository not just
another linux folder)
Ans:--
---------------------------------------------------------------------------------------------
Que 4:-Is there any other similar software you are aware of?
Ans:--
Subversion
-----------------------------------------------------------------------------------------------