Nsa Lab Full
Nsa Lab Full
OF COMPUTER APPLICATIONS
Procedure:
Computer hardware is a hardware part of a computer system. In simple words, only those parts
of the computer system which we can see or touch are called computer hardware.
Hardware is an important part of our computer system without which the computer is
incomplete. You cannot use a computer without hardware and without hardware, there cannot
be a computer system or construction.
1. Mouse
A mouse is a hardware input device that is used to move the cursor or pointer on computer
screens. It can also be used to run computer programs, select items in a graphical user interface,
and manipulate objects in the computer world. Some common examples of how it can be used
are clicking on buttons, scrolling up and down the screen, selecting files, opening folders, and
so on.
2. Keyboard
MLMCE, ETTUMANUR 1
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
A keyboard is an input device that you use to enter data into a computer. It's also called the
input device for your computer. Keyboards are used with PCs, laptops, tablets, and other
devices. There are many different types of keyboards, but the most common one is the
QWERTY keyboard. A QWERTY keyboard has all the letters in alphabetical order on it. This
is different from some other types of keyboards, like Dvorak or Colemak keyboards. For
example, these keyboards have keys arranged differently than what you’re used to seeing on a
QWERTY keyboard. And that means that typing on these keyboards will feel like typing in
another language at first! But don’t worry - once you get accustomed to it, it feels natural!
3. Monitor
Personal computers use a monitor to display data, run the software, and interact with the user.
A monitor is an electronic visual display that connects to your computer or laptop. It is used
for displaying images, text, videos, games, web pages, and more. Monitors are available in
different sizes depending on the needs of the person using them. The most common types of
monitors are CRT (cathode ray tube), LCD (liquid crystal display), and LED (light-emitting
diode).
4. Motherboard
MLMCE, ETTUMANUR 2
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
The motherboard is the backbone of our computer system. It's the central processing unit or
CPU. It connects all the other components, like memory and graphics card, to the power supply.
The motherboard is where all the wires are plugged in and it's also where you place your RAM,
which is your computer's working memory. The motherboard is what makes one machine
different from another.
Motherboards are made up of tiny transistors that control the flow of electricity through copper
tracks on their surface. These transistors are called Integrated Circuits or ICs for short.
A CPU, or central processing unit, is the brain of a computer. The CPU processes information
and runs programs. It functions as a control unit that executes programs according to
instructions in its program memory. The CPU contains elements such as registers, an arithmetic
logic unit (ALU), and control logic for sequencing instructions.
6. RAM Memory
MLMCE, ETTUMANUR 3
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
A computer's RAM is a type of computer memory that stores information so the CPU can
access it directly. Computer systems use main memory to store both data and programs. The
more RAM you have, the more data your system can process at one time. This will lead to
more efficient operations on your computer, which translates into better performance for the
user.
7. ROM Memory
ROM stands for a type of memory chip that can be read from but not written to. In other words,
it's a form of data storage that can't be changed after being programmed. It's sometimes called
"non-volatile" memory because the stored information will remain even when not powered up
or in use. ROM is often used to store a computer's basic start-up instructions and certain types
of data, such as your car's on-board computer system and a calculator's data tables.
A hard disk drive is a piece of hardware inside a computer that stores information.It's used to
store software and data in a safe place, which can be accessed when needed. With magnetic
storage, there are no moving parts - unlike a CD or DVD player in which you need to move a
MLMCE, ETTUMANUR 4
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
disk in order to access data. You can think of it as "a closet" where all your stuff is stored
safely. As long as you have power, you can get to your things when you need them.
9. Optical Drive
Optical Drives are used in PCs to read and write CDs and DVDs. The optical drive reads the
data from the disc, which can then be transformed into a digital file that is readable by the
computer. This makes it easy to backup files, play music or movies, or copy data from one disc
to another. The term "CD" refers to Compact Discs, which are the most common type of optical
drive on modern computers. They are often used for installing software on your computer,
moving data between computers, or writing new programs.
A power supply is an electrical appliance that provides the necessary power to operate a
computer.Computers are powered by electricity, and the power supply converts the alternating
current (AC) from the electric outlet into direct current (DC). The power supply in a computer
can be an internal or external component.
MLMCE, ETTUMANUR 5
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
3. Install Virtualbox
4. Create an Ubuntu VM
MLMCE, ETTUMANUR 6
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
2.24. Now the installation process will start and installation window will appear
2.26. When the system will get restarted the following message will appear. Press “Enter”
2.27. Close the pop-up messages by clicking on the Close (×) button
3.1. Go to “Devices”
MLMCE, ETTUMANUR 7
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Output Screenshot
STEP 1: Installing Virtual Box.
b. Custom setup window to select the features you want and select installation location
MLMCE, ETTUMANUR 8
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
MLMCE, ETTUMANUR 9
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
e. Custom setup window to install the virtual box with the install button.
MLMCE, ETTUMANUR 10
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
MLMCE, ETTUMANUR 11
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
a. After selecting the NEW button to create the Ubuntu instance, the pop-up window
to enter & select the name, type and version of the OS.
MLMCE, ETTUMANUR 12
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
d. Option to choose the type of new virtual hard disk for new instance of OS.
MLMCE, ETTUMANUR 13
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
e. Options to choose the methods of accessing the physical hard disk space for the new
instance from the existing hard disk
f. Panel to select the size of the virtual disk in megabytes and location and name of the
instance and final submit to create the instance of OS.
MLMCE, ETTUMANUR 14
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
h. Settings the configurations of the instance created and adding the ISO image file of the OS
correspondingly and Selecting the ISO image file from the local device.
MLMCE, ETTUMANUR 15
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
MLMCE, ETTUMANUR 16
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
c. Selection of other installation along & within with the installation of ubuntu.
d. Selecting the disk partitioning allocation options from the given below.
MLMCE, ETTUMANUR 17
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
f. Entering the name, username & password for the account to sign in to the ubuntu
OS after installation.
g. Installing the ubuntu OS in the instance, extracting the ubuntu ISO file,
setting configurations, setting the various software within, etc.
MLMCE, ETTUMANUR 18
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
i. Signing in and visiting the home screen of the ubuntu OS using the previously registered
username & password.
MLMCE, ETTUMANUR 19
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Output
MLMCE, ETTUMANUR 20
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
3. Study of a terminal based text editor such as Vim or Gedit, Basic Linux commands: -
familiarity with following commands/operations expected
Procedure
Pwd: This command is used to display the location of the current working directory.
Output
Mkdir: This command is used to create a new directory under any directory.
Syntax :-$ mkdir<directory name>
Output
Syntax :-$ ls
Output
Man:This command is used to display the user manual of any command that we can run on
the terminal.
MLMCE, ETTUMANUR 21
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Output
cd.. : This command is used to move to the parent directory of current directory, or the
directory one level up from the current directory.
cat > filename:This command is used to create a file and add contents to that
file.
Output
MLMCE, ETTUMANUR 22
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
cat filename1 > filename2:This command is used to copy the content from one
file to another file.
Output
grep -C1:command used to display line before and after the result.
MLMCE, ETTUMANUR 23
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Syntax :- $ wc -l filename.txt
$ wc -w filename.txt
$ wc -c filename.txt
$ wc -m filename.txt
Output
MLMCE, ETTUMANUR 24
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
MLMCE, ETTUMANUR 25
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
cut -b:This command is used tocut and display the content based on the specified
byte number.
Output
cut --complement -c:This command is used to erase the specified character and
display the remaining content of the file.
Output
Paste:This command is used to paste the contents from the specified file.
Syntax :-$ paste filename
More:This command is used to view the text files in the command prompt,
displaying one screen at a time in case the file is large.
Cp:This command is used to copy the contents from an existing file to a new
file.
MLMCE, ETTUMANUR 26
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Output
Output
Head:This command is used to display the first 10 lines of the file by default.
Syntax :-$ head filename
Output
MLMCE, ETTUMANUR 27
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Output
MLMCE, ETTUMANUR 28
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
chmod +rwx
chmod -wx
chmod -rwx
Output
Output
MLMCE, ETTUMANUR 29
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
MLMCE, ETTUMANUR 30
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
4. Shell scripting: study bash syntax, environment variables, variables, control constructs
such as if, for and while, aliases and functions, accessing command line arguments passed
to shell scripts.
Program 1
Write a Shell program to check the given number is even or odd.
check_odd_even() {
if [ $((number % 2)) -eq 0 ]; then
echo "$number is even"
else
echo "$number is odd"
fi
}
check_odd_even "$number"
Program 2
Write a Shell program to check a leap year.
MLMCE, ETTUMANUR 31
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
fi
else
echo "$year is a leap year"
fi
else
echo "$year is not a leap year"
fi
Program 3
Write a Shell program to find the area and circumference of a circle.
Program 4
Write a Shell program to check the given number and its reverse are same.
read num
reverse=$(echo "$num" | rev)
if [ "$num" -eq "$reverse" ]; then
echo "$num is same when reversed."
else
echo "$num is not same when reversed."
MLMCE, ETTUMANUR 32
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
fi
Program 5
Write a Shell program to check the given string is palindrome or not.
Program 6
Write a Shell program to find the sum of odd and even numbers from a set of numbers.
MLMCE, ETTUMANUR 33
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
then
sum_even=$(($sum_even + $num))
else
sum_odd=$(($sum_odd + $num))
fi
done
echo "Sum of even numbers is: $sum_even"
echo "Sum of odd numbers is: $sum_odd"
Program 7
Write a Shell program to find the roots of a quadratic equation.
echo "Enter the coefficients of the quadratic equation (a, b, c): "
read a b c
discriminant=$((b*b - 4*a*c))
if [ $discriminant -lt 0 ]
then
echo "The quadratic equation has no real roots."
else
echo "The roots of the quadratic equation are: $root1 and $root2"
fi
MLMCE, ETTUMANUR 34
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Program 8
Write a Shell program to check the given integer is Armstrong number or not.
Program 9
Write a Shell program to check the given integer is prime or not.
echo "Enter an integer: "
read number
flag=1
for (( i=2; i<=number/2; i++ ))
do
if [ $((number%i)) -eq 0 ]
then
flag=0
break
fi
MLMCE, ETTUMANUR 35
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
done
if [ $number -eq 1 ]
then
echo "1 is neither prime nor composite."
elif [ $flag -eq 1 ]
then
echo "$number is a prime number."
else
echo "$number is not a prime number."
fi
Program 10
Write a Shell program to generate prime numbers between 1 and 50.
MLMCE, ETTUMANUR 36
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Done
Program 11
Write a Shell program to find the sum of square of individual digits of a number.
Program 12
Write a Shell program to count the number of vowels in a line of text.
MLMCE, ETTUMANUR 37
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
vowel_count=0
for (( i=0; i<${#line}; i++ )); do
char=${line:i:1}
case $char in
[aeiouAEIOU])
vowel_count=$((vowel_count + 1))
;;
esac
done
echo "The number of vowels in the line of text is: $vowel_count"
Program 13
Write a Shell program to display student grades.
INPUT_FILE="grades.txt"
if [[ ! -f "$INPUT_FILE" ]]; then
echo "Input file not found!"
exit 1
fi
declare -A grades
while read line; do
name=$(echo "$line" | cut -d ',' -f 1)
grade=$(echo "$line" | cut -d ',' -f 2)
grades["$name"]=$grade
done < "$INPUT_FILE"
for name in "${!grades[@]}"; do
echo "$name: ${grades[$name]}"
done
MLMCE, ETTUMANUR 38
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Program 14
Write a Shell program to find the smallest and largest numbers from a set of numbers.
NUMBERS=(5 3 8 1 9 4 7 2)
smallest=${NUMBERS[0]}
largest=${NUMBERS[0]}
for number in "${NUMBERS[@]}"; do
if (( number < smallest )); then
smallest=$number
fi
if (( number > largest )); then
largest=$number
fi
done
echo "Smallest number: $smallest"
echo "Largest number: $largest"
Program 15
Write a Shell program to find the smallest digit from a number.
MLMCE, ETTUMANUR 39
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
smallest=$digit
fi
done
echo "Smallest digit: $smallest"
Program 16
Write a Shell program to find the sum of all numbers between 50 and 100, which are
divisible by 3 and not divisible by 5.
sum=0
for (( i=50; i<=100; i++ )); do
if (( i % 3 == 0 )) && (( i % 5 != 0 )); then
sum=$(( sum + i ))
fi
done
echo "Sum of numbers between 50 and 100, which are divisible by 3 and not divisible by 5:
$sum"
Program 17
Write a Shell program to find the second highest number from a set of numbers.
NUMBERS=(5 3 8 1 9 4 7 2)
highest=${NUMBERS[0]}
second_highest=${NUMBERS[0]}
for number in "${NUMBERS[@]}"; do
if (( number > highest )); then
second_highest=$highest
highest=$number
elif (( number != highest )) && (( number > second_highest )); then
MLMCE, ETTUMANUR 40
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
second_highest=$number
fi
done
echo "Second highest number: $second_highest"
Program 18
Write a Shell program to find the sum of digits of a number using function.
function sum_of_digits {
local number=$1
local sum=0
while (( number > 0 )); do
sum=$(( sum + number % 10 ))
number=$(( number / 10 ))
done
echo "$sum"
}
echo "Enter a number:"
read number
result=$(sum_of_digits $number)
echo "Sum of digits of $number: $result"
MLMCE, ETTUMANUR 41
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Program 19
Write a Shell program to print the reverse of a number using function.
function reverse_number {
local number=$1
local reverse=0
while (( number > 0 )); do
reverse=$(( reverse * 10 + number % 10 ))
number=$(( number / 10 ))
done
echo "$reverse"
}
echo "Enter a number:"
read number
result=$(reverse_number $number)
echo "Reverse of $number: $result"
Program 20
Write a Shell program to find the factorial of a number using for loop.
MLMCE, ETTUMANUR 42
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Program 21
Write a Shell program to generate Fibonacci series.
Program 22
Write a shell script, which receives two filenames as arguments. It checks whether the two
files contents are same or not. If they are same then second file is deleted.
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: $0 file1 file2"
exit 1
fi
if cmp -s "$1" "$2"; then
echo "The contents of $1 and $2 are the same. Deleting $2..."
rm "$2"
MLMCE, ETTUMANUR 43
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
else
echo "The contents of $1 and $2 are different."
Fi
Program 23
Write a Menu driven Shell script that Lists current directory, Prints Working Directory,
displays Date and displays Users logged in
#!/bin/bash
while true
do
clear
echo "Menu:"
echo "1. List current directory"
echo "2. Print working directory"
echo "3. Display date"
echo "4. Display users logged in"
echo "5. Exit"
MLMCE, ETTUMANUR 44
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
date
read -p "Press enter to continue"
;;
4)
who
read -p "Press enter to continue"
;;
5)
exit 0
;;
*)
echo "Invalid choice. Press enter to try again"
read
;;
esac
done
Program 24
Shell script to check executable rights for all files in the current directory, if a file does not
have the execute permission then make it executable.
for file in *; do
if [[ ! -x "$file" ]]; then
chmod +x "$file"
echo "Made $file executable"
fi
MLMCE, ETTUMANUR 45
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
done
Program 25
Write a Shell program to generate all combinations of 1, 2, and 3 using loop.
#!/bin/bash
for i in 1 2 3
do
for j in 1 2 3
do
for k in 1 2 3
do
echo "$i $j $k"
done
done
done
MLMCE, ETTUMANUR 46
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Program 26
Write a Shell program to create the number series.
1
23
456
7 8 9 10
#!/bin/bash
num=1
row=1
while [ $row -le 4 ]; do
for (( i=1; i<=$row; i++ )); do
echo -n "$num "
num=$((num+1))
done
MLMCE, ETTUMANUR 47
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
echo ""
row=$((row+1))
done
Program 27
Write a Shell program to create Pascal’s triangle.
#!/bin/bash
function binom {
if [ $2 -eq 0 ] || [ $2 -eq $1 ]; then
echo 1
else
echo $(( $(binom $(($1-1)) $(($2-1))) + $(binom $(($1-1)) $2) ))
fi
}
echo "Enter the number of rows in Pascal's triangle: "
read rows
for (( i=0; i<$rows; i++ )); do
for (( j=0; j<=$i; j++ )); do
val=$(binom $i $j)
echo -n "$val "
done
# Move to next row
echo ""
done
MLMCE, ETTUMANUR 48
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Program 28
Write a Decimal to Binary Conversion Shell Script
#!/bin/bash
# Prompt the user for the decimal number to convert
echo "Enter a decimal number: "
read decimal
# Convert the decimal number to binary
binary=""
while [ $decimal -gt 0 ]; do
remainder=$((decimal % 2))
binary="$remainder$binary"
decimal=$((decimal / 2))
done
# Print the binary number
echo "The binary equivalent is: $binary"
Program 29
Write a Shell Script to Check Whether a String is Palindrome or not
#!/bin/bash
# Prompt the user for the string to check
echo "Enter a string: "
read string
# Reverse the string
reverse=$(echo $string | rev)
# Check if the string is equal to its reverse
if [ "$string" == "$reverse" ]; then
echo "$string is a palindrome."
MLMCE, ETTUMANUR 49
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
else
echo "$string is not a palindrome."
fi
Program 30
Write a shell script to find out the unique words in a file and also count the occurrence of
each of these words.
#!/bin/bash
# Prompt the user for the file name
echo "Enter the file name: "
read file
# Check if the file exists
if [ ! -f "$file" ]; then
echo "File not found."
exit 1
fi
# Convert the contents of the file to lowercase and replace all non-alphanumeric characters
with spaces
contents=$(tr '[:upper:]' '[:lower:]' < $file | sed 's/[^a-z0-9]/ /g')
# Create an array of words from the file contents
words=($contents)
# Loop through the array of words and count their occurrences
declare -A count
for word in "${words[@]}"; do
if [ -n "$word" ]; then
((count[$word]++))
fi
done
# Print the unique words and their counts
echo "Unique words in $file:"
MLMCE, ETTUMANUR 50
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Program 31
Write a shell script to get the total count of the word “Linux” in all the “.txt” files and also
across files present in subdirectories.
#!/bin/bash
# Set the search directory
search_dir="."
# Find all ".txt" files in the search directory and its subdirectories
files=$(find "$search_dir" -type f -name "*.txt")
# Initialize the count
count=0
# Loop through each file and count the occurrences of "Linux"
for file in $files; do
occurrences=$(grep -o "Linux" "$file" | wc -l)
count=$((count + occurrences))
done
Program 32
Write a shell script to validate password strength. Here are a few assumptions for the
password string.
Length – minimum of 8 characters.
MLMCE, ETTUMANUR 51
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Program 33
Write a shell script to print the count of files and subdirectories in the specified directory.
MLMCE, ETTUMANUR 52
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Program 34
Write a shell script to reverse the list of strings and reverse each string further in the list.
#!/bin/bash
my_list=("string1" "string2" "string3" "string4")
# Reverse the order of the list
my_list=($(echo "${my_list[@]}" | tr ' ' '\n' | tac | tr '\n' ' '))
# Reverse each string in the list
for i in "${!my_list[@]}"
do
my_list[$i]=`echo ${my_list[$i]} | rev`
done
# Print the reversed list of strings
echo "${my_list[@]}"
MLMCE, ETTUMANUR 53
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
5. File system hierarchy in a common Linux distribution, file and device permissions,
study of system configuration files in /etc, familiarizing log files for system events, user
activity, network events.
The Linux File Hierarchy Structure or the Filesystem Hierarchy Standard (FHS) defines the
directory structure and directory contents in Unix-like operating systems.It is maintained by
the Linux Foundation.
In the FHS, all files and directories appear under the root directory /, even if they are
stored on different physical or virtual devices.
Some of these directories only exist on a particular system if certain subsystems, such
as the X Window System, are installed.
Most of these directories exist in all UNIX operating systems and are generally used in
much the same way; however, the descriptions here are those used specifically for the
FHS, and are not considered authoritative for platforms other than Linux.
MLMCE, ETTUMANUR 54
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Everything on your Linux system is located under the / directory, known as the root directory.
You can think of the / directory as being similar to the C:\ directory on Windows – but this
isn’t strictly true, as Linux doesn’t have drive letters. While another partition would be located
at D:\ on Windows, this other partition would appear in another folder under / on Linux.
/bin : Essential command binaries that need to be available in single user mode; for all users,
e.g., cat, ls, cp.
The /bin directory contains the essential user binaries (programs) that must be present when the
system is mounted in single-user mode. Applications such as Firefox are stored in /usr/bin,
while important system programs and utilities such as the bash shell are located in /bin. The
/usr directory may be stored on another partition – placing these files in the /bin directory
ensures the system will have these important utilities even if no other file systems are mounted.
The /sbin directory is similar – it contains essential system administration binaries.
/boot – Static Boot File: The /boot directory contains the files needed to boot the system – for
example, the GRUB boot loader’s files and your Linux kernels are stored here. The boot
loader’s configuration files aren’t located here, though – they’re in /etc with the other
configuration files.
The /cdrom directory isn’t part of the FHS standard, but you’ll still find it on Ubuntu and other
operating systems. It’s a temporary location for CD-ROMs inserted in the system. However,
the standard location for temporary media is inside the /media directory.
MLMCE, ETTUMANUR 55
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Linux exposes devices as files, and the /dev directory contains a number of special files that
represent devices. These are not actual files as we know them, but they appear as files – for
example, /dev/sda represents the first SATA drive in the system. If you wanted to partition it,
you could start a partition editor and tell it to edit /dev/sda.
This directory also contains pseudo-devices, which are virtual devices that don’t actually
correspond to hardware. For example, /dev/random produces random numbers. /dev/null is a
special device that produces no output and automatically discards all input – when you pipe the
output of a command to /dev/null, you discard it.
The /etc directory contains configuration files, which can generally be edited by hand in a text
editor. Note that the /etc/ directory contains system-wide configuration files – user-specific
configuration files are located in each user’s home directory.
The /home directory contains a home folder for each user. For example, if your user name is
bob, you have a home folder located at /home/bob. This home folder contains the user’s data
files and user-specific configuration files. Each user only has write access to their own home
folder and must obtain elevated permissions (become the root user) to modify other files on the
system.
The /lib directory contains libraries needed by the essential binaries in the /bin and /sbin folder.
Libraries needed by the binaries in the /usr/bin folder are located in /usr/lib.
MLMCE, ETTUMANUR 56
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Each Linux file system has a lost+found directory. If the file system crashes, a file system
check will be performed at next boot. Any corrupted files found will be placed in the lost+found
directory, so you can attempt to recover as much data as possible.
The /media directory contains subdirectories where removable media devices inserted into the
computer are mounted. For example, when you insert a CD into your Linux system, a directory
will automatically be created inside the /media directory. You can access the contents of the
CD inside this directory.
Historically speaking, the /mnt directory is where system administrators mounted temporary
file systems while using them. For example, if you’re mounting a Windows partition to perform
some file recovery operations, you might mount it at /mnt/windows. However, you can mount
other file systems anywhere on the system.
The /opt directory contains subdirectories for optional software packages. It’s commonly used
by proprietary software that doesn’t obey the standard file system hierarchy – for example, a
proprietary program might dump its files in /opt/application when you install it.
The /proc directory similar to the /dev directory because it doesn’t contain standard files. It
contains special files that represent system and process information.
The /root directory is the home directory of the root user. Instead of being located at /home/root,
it’s located at /root. This is distinct from /, which is the system root directory.
MLMCE, ETTUMANUR 57
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
The /run directory is fairly new, and gives applications a standard place to store transient files
they require like sockets and process IDs. These files can’t be stored in /tmp because files in
/tmp may be deleted.
The /sbin directory is similar to the /bin directory. It contains essential binaries that are
generally intended to be run by the root user for system administration
If your Linux distribution uses SELinux for security (Fedora and Red Hat, for example), the
/selinux directory contains special files used by SELinux. It’s similar to /proc. Ubuntu doesn’t
use SELinux, so the presence of this folder on Ubuntu appears to be a bug.
The /srv directory contains “data for services provided by the system.” If you were using the
Apache HTTP server to serve a website, you’d likely store your website’s files in a directory
inside the /srv directory.
Applications store temporary files in the /tmp directory. These files are generally deleted
whenever your system is restarted and may be deleted at any time by utilities such as tmpwatch.
The /usr directory contains applications and files used by users, as opposed to applications and
files used by the system. For example, non-essential applications are located inside the /usr/bin
directory instead of the /bin directory and non-essential system administration binaries are
located in the /usr/sbin directory instead of the /sbin directory. Libraries for each are located
inside the /usr/lib directory. The /usr directory also contains other directories – for example,
architecture-independent files like graphics are located in /usr/share.The /usr/local directory is
MLMCE, ETTUMANUR 58
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
where locally compiled applications install to by default – this prevents them from mucking up
the rest of the system.
The /var directory is the writable counterpart to the /usr directory, which must be read-only in
normal operation. Log files and everything else that would normally be written to /usr during
normal operation are written to the /var directory. For example, you’ll find log files in /var/log.
MLMCE, ETTUMANUR 59
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Procedure
Install Apache2
Update your system:
If it is not working !
http://127.0.0.1/
MLMCE, ETTUMANUR 60
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
http://localhost/
Install mariadb
sudo apt install mariadb-server mariadb-client
<?php
phpinfo ();
?>
MLMCE, ETTUMANUR 61
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Press CTRL + X to save and close the file. Press y and ENTER to
confirm Open a browser and type in your IP address/phpinfo.php
http://127.0.0.1/phpinfo.php
Install phpmyadmin
nano /etc/apache2/apache2.conf
Include /etc/phpmyadmin/apache.conf
sudo mysql
ALTER USER root@localhost IDENTIFIED BY "yourpassword";
MLMCE, ETTUMANUR 62
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Then move the WordPress files from the extracted folder to the Apache
default root directory, /var/www/html/:
sudo mv wordpress/* /var/www/html/
Next, set the correct permissions on the website directory, that is give
ownership of the WordPress files to the webserver as follows:
sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/
MLMCE, ETTUMANUR 63
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
You will be prompted for the password you set for the MySQL root
accountwhen you installed the software. However, if you have password
authenticationenabled for your root user, you can run the following
command and enter your password information when prompted:
mysql -u root –p
From there, you’ll create a new database that WordPress will control. You
can call this whatever you would like, but we will be using wordpress in
this guideas an example. Create the database for WordPress by writing the
following:
CREATE DATABASE wordpress DEFAULT CHARACTER
SET utf8 COLLATE utf8_unicode_ci;
Next, you’re going to create a separate MySQL user account that you’ll
useexclusively to operate on the new database. Creating one-function
databases andaccounts is a good idea from a management and security
standpoint. We willuse the name wordpressuser as an example in this
guide. Feel free to change thisif you’d like.You can create this account,
set a password for it, and then grant it access to thedatabase you created
all by running the following command. Remember tochoose a strong
password here for your database user:
GRANT ALL ON wordpress.* TO
'wordpressuser'@'localhost'IDENTIFIED BY 'password';
MLMCE, ETTUMANUR 64
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
After creating this user, flush the privileges to ensure that the current
instance ofMySQL knows about the recent changes you’ve made:
FLUSH PRIVILEGES;
Exit out of MySQL:
EXIT
You now have a database and user account in MySQL, each made
specifically for WordPress. Go the /var/www/html/ directory and rename
existing wp-config-sample.php to wpconfig.php. Also, make sure to
remove the default Apache index page.
cd /var/www/html/
sudo mv wp-config-sample.php wp-config.php
sudo rm -rf index.html
Then update it with your database information under the MySQL settings
section (refer to the highlighted boxes in the image below):This setting
can be added after the database connection settings, or anywhere
else in the file: Save and close the file when you are finished.Restart the
web server and mysql service using the commands below:
sudo systemctl restart apache2.service
sudo systemctl restart mysql.service
MLMCE, ETTUMANUR 65
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Once you log in, you will be taken to the WordPress administration
dashboard: From there, you can begin using and customizing your
WordPress site.
MLMCE, ETTUMANUR 66
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
7. Build and install software from source code, familiarity with make and
cmake utilities expected.
Procedure& Output Screenshot
$sudo apt install cmake g++ make: To install cmake , g++ and make using the
apt command.
Create directory
Mkdir cmake: creating a different directory for our project using
the mkdir and cd commands.
MLMCE, ETTUMANUR 67
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Cd cmake
gedit Helloworld.cpp
Now create a C++ source file named Hello_world.cpp and add the
following : gedit CmakeLists.txt Create a CMakeLists.txt
file(with this exact capitalization) which is required by CMake:
Create directory called
Mkdir build:
To run cmake we need to change into the build directory:
Cmake ..
MLMCE, ETTUMANUR 68
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Procedure
2. nslookup : To show the server to which the system is connected by default. If we want to
find the ip address of a particular domain name, we can also use nslookup
MLMCE, ETTUMANUR 69
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
3. ping : The command used to check the availability of a host. The response shows the URL
you are pinging, the ip address associated with the URL and the size of packets being sent on
the first line . The next four lines shows the replies from each individual packets including the
time(in milliseconds) for the response and the time to live(TLL) of the packet, that is the
amount of time that must pass before the packet discarded.
5. netstat : netstat is a command-line utility in Linux and other Unix-like operating systems
that provides information about network connections, routing tables, interface statistics,
masquerade connections, and more. It's used for monitoring network-related information and
diagnosing network issues.
MLMCE, ETTUMANUR 70
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
6. hostname : The hostname command is a command-line utility in Linux and other Unix-like
operating systems that allows you to view or set the hostname of the system. The hostname is
the unique name assigned to a computer within a network.
MLMCE, ETTUMANUR 71
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
7. arp : The arp command is a command-line utility in Linux and other Unix-like operating
systems that allows you to view and manipulate the Address Resolution Protocol (ARP) cache,
which is used to map IP addresses to MAC addresses on a local network. ARP is essential for
communication between devices within the same subnet.
8. uname : The uname command is a command-line utility in Linux and other Unix-like
operating systems that provides information about the system's kernel and operating system.
It's used to retrieve information about the system's architecture, release version, and other
details.
MLMCE, ETTUMANUR 72
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
9. Analyzing network packet stream using tcpdump and wireshark. Perform basic
network service tests using nc.
Procedure
Many Linux distributions already shipped with the tcpdump tool, if in case you
don’t have it on a system, you can install it using the command.
To list the number of available interfaces on the system, run the following command
with -D option.
When you run the tcpdump command it will capture all the packets for the
specified interface, until you hit the cancel button. But using -c option, you can
capture a specified number of packets.
# tcpdump –c 5 –i enp3s0
The following command with option -XX capture the data of each packet,
including its link level header in HEX and ASCII format
MLMCE, ETTUMANUR 73
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
As we said, that tcpdump has a feature to capture and save the file in a .pcap
format, to do this just execute the command with -w option.
Let’s say you want to capture packets for specific port 80, execute the below
command by specifying port number 80
To read and analyze captured packet 0001.pcap file use the command with -r
option
wire shark
The Wireshark utility is available on all major desktop platforms, i.e., Linux, Microsoft
Windows, FreeBSD, MacOS, Solaris, and many more. Follow the steps below to install
Wireshark on Ubuntu 20.04.
First, as always, update and upgrade your APT through the following command.
Syntax:
Now that Wireshark’s latest version has been added to the APT, you can
download and install it with the following command.
syntax
MLMCE, ETTUMANUR 74
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
When Wireshark installs on your system, you will be prompted by the following
window. As Wireshark requires superuser/root privileges to operate, this option
asks to enable or disable permissions for all every user on the system. Press the
“Yes” button to allow other users, or press the “No” button to restrict other users
from using Wireshark.
Step 4:
You must add a username to the Wireshark group so that this user can use
Wireshark. To do this, execute the following command, adding your required
username after “wireshark” in the command.
Syntax:
MLMCE, ETTUMANUR 75
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Procedure
For the Ubuntu system, all packages required to run KVM are available on official upstream
repositories.
Create Virtual Machine • You can create virtual machine using virt-manager utility. Run the
following command to start the virt-manager:
sudo virt-manager
virsh help
virsh help
Virsh start
vm virsh start
MLMCE, ETTUMANUR 76
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Step 4:In the first window, click the computer icon in the upper-left corner,In the dialogue box
that opens, select the option to install the VM using an ISO image. Then click Forward.
Step 6: Enter the amount of RAM and the number of CPUs you wish to allocate to the VM and
proceed to the next step.
Step 7: Allocate hard disk space to the VM. Click Forward to go to the last step.
MLMCE, ETTUMANUR 77
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Step 8: Specify the name for your VM and click Finish to complete the setup.
Step 10: The VM starts automatically, prompting you to start installing the OS that’s on
MLMCE, ETTUMANUR 78
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
Procedure
Step 2 : Remove any Docker files that are running in the system, using the following command
After entering the above command, you will need to enter the password of the root and press
enter.
You’ll then get a prompt asking you to choose between y/n – choose ‘y’
Step 5 : Install all the dependency packages using the following command:
Step 6 : Before testing Docker, check the version installed using the following command:
Step 7 : Pull an image from the Docker hub using the following command:
Step 8 : Check if the docker image has been pulled and is present in your system using the
MLMCE, ETTUMANUR 79
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
following command:
Step 9 : To display all the containers pulled, use the following command:
Step 10 : To check for containers in a running state, use the following command:
MLMCE, ETTUMANUR 80
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
11. Installing and configuring modern frameworks like Laravel typically involves setting
up a web server, PHP, a database, and the framework itself. Below is a general guide to
installing and configuring Laravel on a Linux system. Please note that specific steps may
vary based on your distribution and environment.
Step 1: Prerequisites
Install Required Software: Make sure you have a web server (e.g., Apache or Nginx),
PHP, Composer (dependency manager), and a database server (e.g., MySQL) installed
on your system.
1. Create a New Laravel Project: Open a terminal and navigate to the directory where
you want to create your Laravel project. Run the following command:
1. Apache:
Create a new virtual host configuration for your Laravel project in your Apache
configuration.
Enable the necessary Apache modules (e.g., rewrite) and restart Apache.
2. Nginx:
Create a new server block configuration for your Laravel project in your Nginx
configuration.
Set the root directive to the public directory of your Laravel project.
MLMCE, ETTUMANUR 81
20MCA136 NETWORKING & SYSTEM ADMINISTRATION LAB DEPT. OF COMPUTER APPLICATIONS
1. Environment Configuration:
Set database connection details, application key, and other settings in the .env
file.
2. Generate Application Key: Run the following command in your Laravel project
directory:
3. Run Migrations: If your .env file is configured with database details, run migrations
to create necessary database tables:
1. Access the Application: Open a web browser and visit the URL you configured for
your Laravel project. You should see the Laravel welcome page.
2. Create Routes and Views: Begin building your application by defining routes and
creating views in the resources/views directory.
MLMCE, ETTUMANUR 82