uli101_week10_practice
.docx
keyboard_arrow_up
School
Seneca College *
*We aren’t endorsed by this school
Course
101
Subject
Computer Science
Date
Dec 6, 2023
Type
docx
Pages
5
Uploaded by ChancellorDragonfly3067
ULI101 Linux Command Practice (Shell Scripting – Part 1)
_____________________________________________________________________________
Instructions:
PART A: WRITE BASH SHELL SCRIPT CODE
Write the answer to each question below the question in the space provided.
1.
Write a Bash shell script that clears
the screen and displays
the text
Hello World
on the screen.
#!/bin/bash
echo “Hello World”
What
permissions
are required to run this Bash shell script?
chmod u+x pathname
What are the different
methods
to run this Bash shell script from the command line?
bash pathname
2.
Write a Bash shell script that clears
the screen, prompts the user for their
full name
and then
prompts the user for their
age
, then clears the screen again and welcomes the user by their name
and tells them their age.
#!/bin/bash
clear
read -p “Enter your full name: “ fullname
read -p “Enter your age: “ age
clear
echo “Welcome $fullname, your age is $age years old”
What comments would you add
to the above script’s contents to properly document
this Bash shell
script to be understood for those users that would read / edit this Bash shell script’s contents?
1
PAGE
ULI101 Linux Command Practice (Shell Scripting – Part 1)
_____________________________________________________________________________
3.
Write a Bash shell script that will first set
the value of a read-only variable called
dogFactor
to
7
.
The script will then clear
the screen and prompt the user to enter the age of a dog in human years
(which will be stored into a variable called
humanYears
).
The script will store in a variable called
dogYears
the value of
humanYears x dogFactor
The script will then clear the screen a second time and then display the age of the dog
in
“dog years”
.
#!/bin/bash
readonly dogFactor=7
clear
read -p “Enter the age of a dog in human years: “ humanYears
dogYears=$((humanYears*dofFactor))
clear
echo “The age of the dog in dog years is $dogYears”
4.
Write a Bash shell script that will clear the screen and then display all arguments
that were entered
after
your Bash shell script when it was run.
Also, have the Bash shell script display the
number of arguments
that were entered after your Bash shell script.
2
PAGE
ULI101 Linux Command Practice (Shell Scripting – Part 1)
_____________________________________________________________________________
PART B: WALK-THRUS
Write the expected output from running each of the following Bash shell scripts
You can assume that these Bash shell script files have execute permissions.
Show your work.
1.
cat walkthru1.bash
#!/usr/bin/bash
word1=”counter”
word2=”clockwise”
echo “The combined word is: $word2$word1”
WRITE ROUGH WORK AND OUTPUT FROM ISSUING:
./walkthru1.bash
ROUGH WORK:
OUTPUT:
The combined word is: clockwisecounter
2.
cat walkthru2.bash
#!/usr/bin/bash
echo “result1: $1”
echo “result2: $2”
echo “result3: $3”
echo “result 4:”
echo “$*”
WRITE ROUGH WORK AND OUTPUT FROM ISSUING:
./walkthru2.bash apple orange banana
ROUGH WORK:
OUTPUT:
result1: apple
3
PAGE
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
NASM programX86should run successfully in nasm in Linux platform while using the below commands for your clarity...
nasm -f elf question.asmld -melf_i386 question.o -o answer./answer
here question is code file name and answer is what we are giving for output file.
please answer as what I asked .... please don't waste my questions posting wrong answers and irrelevant languages
arrow_forward
xor eax, eaxxor ebx, ebxmov al,39int 0x80The output is as follows:Linux : Error (-1)FreeBSD : A process ID
make Assembly Creation code for given data:
arrow_forward
#Linux Operating System#Powershell#Bash shell scriptHi guys i need bash shell script expert help.
arrow_forward
What are the differences between a microkernel and monolithic kernel? Please type out in text as handwriting is difficult to read.
arrow_forward
Fill in the blanks:
Q. Elastic __________________ Interface is Better known as _______________.
arrow_forward
in linux enviroment
arrow_forward
Explain the role of cgroups and namespaces in Linux resource isolation.
arrow_forward
Shell script 2: (Display.sh)
Display Script (Display.sh) will display important information as shown below:
***********
qustudent is currently logged in the linux system
The Current date and time on the linux system is Mon Feb 13 06:29:57 PM +03 2023
system boot 2023-02-11 12:40
The current working path is /home/qustudent/Desktop/Sp2023/Project1
The current shell is /bin/bash
My Home Directory is /home/qustudent with # of files and Directories in my home = 70
Describe here briefly the purpose of the Script
arrow_forward
In what ways does Linux handle memory swapping?
arrow_forward
The Shell or Command Line Interpreter is the fundamental User interface to an Operating System. Your task is to write a simple shell - myshell - that has the following properties:
Tasks:
The shell must support the following internal commands:
cd <directory> - Change the current default directory to
<directory>. If the <directory> argument is not present, report the current directory. If the directory does not exist an appropriate error should be reported. This command should also change the PWD environment variable.
cls - Clear the screen.
iii. dir <directory> - List the contents of directory <directory> page
by page.
xcopy <source> to <destination> - Copy the <source> folder to <destination>.
print <comment> - Display <comment> on the display followed by a new line (multiple spaces/tabs may be reduced to a single space).
md <directory> - Create the folder <directory>.
vii. rd…
arrow_forward
Access Control List (ACL) and Capability Lists are the most common implementations
for controlling access to objects in a system. Which of the two methods are used in
UNIX/Linux file systems? What simplifications have been made to make the
implementation more efficient?
arrow_forward
im trying to do this homework on code blocks 20.03 and it show me this error
arrow_forward
Please help with the following in Linux help complete the following table
Example of what it should look like
Command
Description
Option/Flags
Log
chmd (ugoa +/- rwx)
chmd – octal system (0-7): 1=execute;2=write;4=read
zip(-r sf)
unzip(-l)
date(-u, + “Year: %Y,Month: %m, Day: %d”,-d 20210105)
ncal(-h-b-j)
head (-n)
arrow_forward
Parallel:-
Implement the parallel utility that has 3 command line arguments. This will execute 4 copies of the sleep process for 10 seconds. Your program should allow an arbitrary number of command line arguments for the process to be run in parallel. The parent process should wait for all child processes to finish before exiting back to the shell. If the format of the command is not recognized (e.g. the first argument is not an integer), an error can be displayed. All your code should be contained in the parallel.c file, and the Makefile.
./parallel<processes><cmd><args>
For example, if you type:
./parallel 4 sleep 10
OUTPUT: SUCCESS in running 4 parallel sleep tasks
arrow_forward
Task 3: Measure the Entropy of Kernel In the virtual world, it is difficult to create randomness, i.e., software alone is hard to create random numbers. Most systems resort to the physical world to gain the randomness. Linux gains the randomness from the following physical resources: void add_keyboard_randomness(unsigned char scancode); void add_mouse_randomness(__u32 mouse_data); void add_interrupt_randomness(int irq); void add_blkdev_randomness(int major); The first two are quite straightforward to understand: the first one uses the timing between key presses; the second one uses mouse movement and interrupt timing; the third one gathers random numbers using the interrupt timing. Of course, not all interrupts are good sources of randomness. For example, the timer interrupt is not a good choice, because it is predictable. However, disk interrupts are a better measure. The last one measures the finishing time of block device requests. The randomness is measured using entropy, which is…
arrow_forward
1. Write a program to implement LRU page replacement algorithm
2. Write a program to implement FIFO page replacement algorithm
Instruction for lab work:
+ Students will be allocated any one / choose anyone question to answer.
+ Kindly use suitable Kali Linux tools to solve these assignment problems.
+ You have to write the step-by-step commands to solve each problem as well as screenshots
at each step.
Students can work in teams
+ Viva will be conducted by course teachers. Students will have to share their screen with
the course teacher and practically demonstrate the lab work as per the report submitted.
Submit assignment on or before the deadline on Blackboard portal.
Late assignment submission will not be allowed.
Students should not copy and paste assignments directly from other students. Assignments
will also be evaluated based on plagiarism and marks will be deducted if plagiarism found.
arrow_forward
How does Linux handle memory allocation for virtual machines?
arrow_forward
I ran the code and still got the same error. Please fix the error in the python file and show screenshots of the fixed code of the python file along with the screenshot of the output as well.
arrow_forward
Why did Linux's founders choose a non-preemptive kernel?Why use a non-preemptible kernel in a single-processor system? Why does a multi-processor computer devalue?
arrow_forward
How do functions pass arguments and return values in the X64 Linux system? Compare and contrast
the use of stacks and registers in passing arguments.
arrow_forward
What are the benefits of using containers as
a virtual machine replacement ?
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
CompTIA Linux+ Guide to Linux Certification (Mind...
Computer Science
ISBN:9781305107168
Author:Jason Eckert
Publisher:Cengage Learning
Related Questions
- NASM programX86should run successfully in nasm in Linux platform while using the below commands for your clarity... nasm -f elf question.asmld -melf_i386 question.o -o answer./answer here question is code file name and answer is what we are giving for output file. please answer as what I asked .... please don't waste my questions posting wrong answers and irrelevant languagesarrow_forwardxor eax, eaxxor ebx, ebxmov al,39int 0x80The output is as follows:Linux : Error (-1)FreeBSD : A process ID make Assembly Creation code for given data:arrow_forward#Linux Operating System#Powershell#Bash shell scriptHi guys i need bash shell script expert help.arrow_forward
- Explain the role of cgroups and namespaces in Linux resource isolation.arrow_forwardShell script 2: (Display.sh) Display Script (Display.sh) will display important information as shown below: *********** qustudent is currently logged in the linux system The Current date and time on the linux system is Mon Feb 13 06:29:57 PM +03 2023 system boot 2023-02-11 12:40 The current working path is /home/qustudent/Desktop/Sp2023/Project1 The current shell is /bin/bash My Home Directory is /home/qustudent with # of files and Directories in my home = 70 Describe here briefly the purpose of the Scriptarrow_forwardIn what ways does Linux handle memory swapping?arrow_forward
- The Shell or Command Line Interpreter is the fundamental User interface to an Operating System. Your task is to write a simple shell - myshell - that has the following properties: Tasks: The shell must support the following internal commands: cd <directory> - Change the current default directory to <directory>. If the <directory> argument is not present, report the current directory. If the directory does not exist an appropriate error should be reported. This command should also change the PWD environment variable. cls - Clear the screen. iii. dir <directory> - List the contents of directory <directory> page by page. xcopy <source> to <destination> - Copy the <source> folder to <destination>. print <comment> - Display <comment> on the display followed by a new line (multiple spaces/tabs may be reduced to a single space). md <directory> - Create the folder <directory>. vii. rd…arrow_forwardAccess Control List (ACL) and Capability Lists are the most common implementations for controlling access to objects in a system. Which of the two methods are used in UNIX/Linux file systems? What simplifications have been made to make the implementation more efficient?arrow_forwardim trying to do this homework on code blocks 20.03 and it show me this errorarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- CompTIA Linux+ Guide to Linux Certification (Mind...Computer ScienceISBN:9781305107168Author:Jason EckertPublisher:Cengage Learning
CompTIA Linux+ Guide to Linux Certification (Mind...
Computer Science
ISBN:9781305107168
Author:Jason Eckert
Publisher:Cengage Learning