Linux and Bash for Data Engineering Week2
.docx
keyboard_arrow_up
School
Grand Rapids Community College *
*We aren’t endorsed by this school
Course
MISC
Subject
Computer Science
Date
Dec 6, 2023
Type
docx
Pages
3
Uploaded by ConstableWildcatMaster401
Congratulations! You passed!
Grade received 90%
Latest Submission Grade 90%
To pass 80% or higher
Go to next item
1.
Question 1
Explain the purpose of the
~/.bashrc
file.
1 / 1 point
It is a Bash shell script that runs whenever Bash is started interactively.
It is a Bash login shell that only runs at the start of a new login shell.
It is a Bash logout shell that only runs when a shell exits.
Correct
You got it! This script is used to configure your shell environment for interactive use.
2.
Question 2
What is the purpose of the
~/.zshrc
file?
1 / 1 point
It is a ZSH shell script that runs whenever Bash is started interactively.
It is a ZSH login shell that only runs at the start of a new login shell.
It is a ZSH logout shell that only runs when a shell exits.
Correct
You got it! This script is used to configure your shell environment for interactive use.
3.
Question 3
What shell example creates a shell variable to the current shell only.
1 / 1 point
echo $FRUIT
FRUIT="cherry"
export FRUIT="cherry"
Correct
You got it! Setting a variable makes the
4.
Question 4
What would be the output of this command?
FRUIT="Cherries"; echo $FRUIT are tasty
1 / 1 point
echo Cherries are tasty
Cherries are tasty
$FRUIT are tasty
Correct
You got it! The shell variable value prints out as part of the echo command.
5.
Question 5
When you run the command
alias
from a terminal what will you see?
1 / 1 point
It will display the help menu for a command.
It will print the name of the shell currently in use.
You will see output like the following:
alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias
grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l
--color=auto' alias ls='ls --color=auto' alias which='alias | /usr/bin/which
--tty-only --read-alias --show-dot --show-tilde'
Correct
You got it! The output of the
alias
command shows the currently set aliases for the shell
environment.
6.
Question 6
What is a good example of what appears in standard out?
0 / 1 point
The content of a file.
It is always blank.
Errors from the improper execution of a shell command.
Incorrect
Not quite. Errors get sent to stderr.
7.
Question 7
What is the output of this command?
ls fakefile.txt &>/dev/null
1 / 1 point
There is no output.
It will display the following error.
ls: cannot access fakefile: No such file or directory
It will create the file since it doesn't exist.
Correct
You got it!
8.
Question 8
What would the following command do?
ls fakefile 2>error.txt
1 / 1 point
Write stdout to
error.txt
It deletes the output of stderr
Write stderr to
error.txt
Correct
You got it! The error from this command would write out to
error.txt
. Here is what would happen if
you used the
less
command to read it.
less error.txt ls: cannot access fakefile: No such file or directory
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
please comment all code
Using a Bash environment, write a script to do the following:
- declare and initialize an array to a few numbers.- in a loop, validate the numbers so they are greater than 0, if so:- get the total of them then the average.- print the average value.
arrow_forward
Write a bash script that will run the command getData1.sh and getData2.sh to read values from two sensors.
*Use Random to simulate the readings.
*Store the values every 2 minutes along with data and time in four columns in a file 'sensorReadings.csv'.
The columns will appear like below:
Data1 Data2 Date Time
arrow_forward
Write two scripts called encryption and decryption. Test both scripts by encrypting a file called file1 and save the result in file2. Then use file2 as the input to the decryption script and check if the output is the same as file1.
May I get help with this in bash shell please?
arrow_forward
Write a script to check if the current user has any processes that have been running for more than one hour. If the process has ran for more than one hour, the script should kill the process. However, the script should not kill the bash shell (that the script is run from (or any others). Commands that you may need to use might include ps, tr, tail, cat, cut, paste, echo, expr, date and kill.
Note: Your script must avoid killing all bash shells. Bash is most frequently listed in the results of ps as just bash, but can be listed as /bin/bash, or as part of a running script as /bin/bash script1.sh. It’s also possible that it is being run out of some nonstandard directory (like ~/bin/bash for a custom version).
Note: This program will kill your graphical environment if you are using one. If you really want to see if it works, run it from console mode.
arrow_forward
Help with Python coding issue
The Linux operating system is a very popular server OS. A network administrator has to protect the login/password files stored on the servers. In Linux there are two important files:
/etc/passwd
And it contains rows that look like this:
root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin user1:x:15:51:User One:/home/user1:nologin user2:x:15:51:User One:/home/user1:nologin user3:x:15:51:User One:/home/user1:nologin
This file contains login information. It's a list of the server's accounts that has userID, groupID, home directory, shell and more info.
And the second file /etc/shadow, contains rows that look like this:
root:$1$TDQFedzX$.kv51AjM.FInu0lrH1dY30:15045:0:99999:7::: bin:*:14195:0:99999:7::: daemon:*:14195:0:99999:7::: adm:*:14195:0:99999:7::: ftp:*:14195:0:99999:7:::…
arrow_forward
Is switching from bash to another shell something that would be beneficial?
arrow_forward
Using Unix Write a Bash script that checks for all executable files in your home directory and renames them by adding the .bash suffix to each of these executables.
arrow_forward
Write a bash script for a Daily Task management utility. This is a simple utility that has the function to manage task for a user for a single day. The utility should have the following properties:
The utility must be password protected
User must be able to add a task
User must be able to delete the completed task
User must be able to search tasks
Display all the task.
arrow_forward
Scenario:
You have been tasked with building a URL file validator for a web crawler. A web crawler is an application that fetches a web page, extracts the URLs present in that page, and then recursively fetches new pages using the extracted URLs. The end goal of a web crawler is to collect text data, images, or other resources present in order to validate resource URLs or hyperlinks on a page. URL validators can be useful to validate if the extracted URL is a valid resource to fetch. In this scenario, you will build a URL validator that checks for supported protocols and file types.
arrow_forward
May I get help with this in bash shell.
arrow_forward
Write a complete bash script that takes a filename as input using the readcommand. The script first checks if the file exists. If the file exists thencontinue with rest of the script. If the file does not exist output that itdoesn’t exist and end the script. If the file exists then check if the file isexecutable. If the file is executable, output a message indicating it isexecutable else if the file is not executable then make the file executableusing the chmod command and output a message indicating that the file isnow executable. Also run a ls -l on the file to verify to the user that the filehas been made executable. Use If statements and test file operators. (Usage: executableFile.sh)
arrow_forward
Write down the commands you would use for the following tasks
Bob has a vital document named `sources.list` on his computer, but he doesn’t remember theexact location. So Bob asks you to help him find the file on his computer, and also, once it hasbeen found, please change the file’s permission, so only Bob can access it.Tasks:1. Find the file (sources. list).2. Change the file owner to yourself (Bob).3. Set access authority so that only you (Bob) can write/read this file.Note: since you are working on Bob’s computer, you are working under Bob’s name and have his privileges
arrow_forward
21.7 LAB: Login name
Write a program that creates a login name for a user, given the user's first name, last name, and a four-digit integer as input. Output the login
name, which is made up of the first five letters of the last name, followed by the first letter of the first name, and then the last two digits of
the number (use the % operator). If the last name has less than five letters, then use all letters of the last name.
Ex: If the input is:
Michael Jordan 1991
the output is:
Your login name: JordaM91
Ex: If the input is:
Kanye West 2024
the output is:
Your login name: WestK24
arrow_forward
how to create a bash script that unzip several zipped files in a folder and sort them alphabetical and remove white spaces from their names ?
arrow_forward
Make sure to do the proper exception handling in your code.
Write shell script for a simple calculator which can perform basic arithmetic operations like addition, subtraction, multiplication or division depending upon the user input in Bash.Make sure to do the proper exception handling in your code.
arrow_forward
Using the following data file (delimited by a space or tab) November 400January 200June 400March 200April 200May 300July 400August 300September 400February 300October 300December 200Write a bash script that will use a loop structure to process the data file line by line. Do not use the command awk. The script will send the output to a file in the following format:Month Sales-------- -------January 200February 300March 200April 200May 300June 400July 400August 300September 400October 300November 400December 200======Total show the totalAverage show the average
arrow_forward
Bash shell/Linux
arrow_forward
Write a bash script for a Daily Task management utility. This is a simple utility that has the function to manage task for a user for a single day. The utility should have the following:
The utility must be password protected
User must be able to add a task
User must be able to delete the completed task
User must be able to search tasks
Display all the task.
arrow_forward
Subject: opearating system
Write a bash script to take a year as input from user and check whether the input year is a LEAP YEAR OR NOT. HINT: Any year which is exactly divisible by 4 is a leap year.
Solve as soon as possible
arrow_forward
Write a BASH script that will use a for loop that will loop through the tscripts folder and delete each file. (rm) (be careful that you only delete files in the tscripts folder)
arrow_forward
Can you plaese do these questions for me
Our users do not want to have to re-enter the price levels each time the app starts.
Therefor, we need to save the price levels to a file on disk – called levelsFile - and populate the levelsList with the file’s items when the app starts.
Also, every time the user manipulates the values in levelsList, levelsFile needs to be updated accordingly. The easiest way is not to update the file, but to simply override it (create a new file) with the new values in levelsList (each time the user manipulates items in the list).
Two new methods need to be created in the PriceChecker class. They are readLevelsFromFile() and writeLevelsToFile(). And then the Main Code Section must also be updated to use these methods in the object.
Note: The changes required to the Main Code Section are supplied on the next slide, but you need to complete the skeleton code of the two newly mentioned methods (supplied on subsequent slides).
Add the purple code to your…
arrow_forward
Which of the following does git add do?
For example:
git add MyClass.java
A. Stages MyClass.java so that it's changes are committed to the local repository on
the next commit
B. Adds a new file, MyClass.java to the git repository. This is adds only purpose, and
so we only do it the first time we add MyClass to the repository, and not when we make
changes.
C. Sends the current state of MyClass.java directly to the remote repository
D. Creates a new branch that contains only the file MyClass.java
Reset Selection
arrow_forward
The Linux operating system is a very popular server OS. A network administrator has to protect the login/password files stored on the servers. In Linux there are two important files:
/etc/passwd
And it contains rows that look like this:
root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin user1:x:15:51:User One:/home/user1:nologin user2:x:15:51:User One:/home/user1:nologin user3:x:15:51:User One:/home/user1:nologin
This file contains login information. It's a list of the server's accounts that has userID, groupID, home directory, shell and more info.
And the second file /etc/shadow, contains rows that look like this:
root:$1$TDQFedzX$.kv51AjM.FInu0lrH1dY30:15045:0:99999:7::: bin:*:14195:0:99999:7::: daemon:*:14195:0:99999:7::: adm:*:14195:0:99999:7::: ftp:*:14195:0:99999:7::: user1:$1$ssTPXdzX$.kv51AjM.FInu0lrH1dY30:15045:0:99999:7:::…
arrow_forward
Write differences between the BASH and DOS commands.
arrow_forward
In BASH, how do you make it so your script can deal with both absolute and relative paths?
arrow_forward
Write a BASH script that will:
Ask the user to input a number.
Use if/elif/else to
If number is < 10 display “Very Low”
If number is between 10 and 50 display “That’s the stuff”
If number is between 50 and 100 display “It’s getting warm”
If number is greater than 100 display “Danger! Danger! Danger!”
arrow_forward
Write a Bash script that uses a for loop to loop over all the files stored in the usr/bin directory and display the name of all the files that has the string “fork” inside it.
arrow_forward
In Django, what's the difference between a project and an application?
Write the command to create a project. Name some of the major files / directory structure that are created as a result.
Write the command to create an application. Name some of the major files / directory structure that are created as a result.
How to register an application to a Django project?
For a model class, name any 4 of the common fields.
You should add a get_absolute_url() and __str__() method to each model you write. Briefly explain what each of these 2 methods do.
After writing models.py, what are the two commands that are needed in order to apply the changes to the database? What is the difference between those 2 commands?
Assuming you have a Django model named ‘User’, how do you define a foreign key field for this model in another model?
arrow_forward
You will develop a client side and a Servlet program that will work with a database.
1. The client (front end) should have a title "NJIT Credit Union", centered.
2. The client should have a background color.
3. The client should have a text field with label 'UserID' where user will enter userID
(integer) and a Submit button with text "Submit".
4. An unsuccessful authentication should have a message printed on the screen, in red,
stating that "Your authentication has failed, please try again.” (no pop up message).
At this point the text field should get cleared and ready to accept a new input. Your
program should not exit.
5. A successful authentication should be followed by a message on the screen, in green,
stating that "Your authentication is successful" (no pop up message).
6. There should be two other text boxes with label "Deposit" and "Withdraw" where
user will enter an amount (you should accommodate for decimals). These two text
boxes should only be enabled after successful…
arrow_forward
write a bash shell script to display the grade of a student according to his marks entered
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
LINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.
Computer Science
ISBN:9781337569798
Author:ECKERT
Publisher:CENGAGE L
Related Questions
- please comment all code Using a Bash environment, write a script to do the following: - declare and initialize an array to a few numbers.- in a loop, validate the numbers so they are greater than 0, if so:- get the total of them then the average.- print the average value.arrow_forwardWrite a bash script that will run the command getData1.sh and getData2.sh to read values from two sensors. *Use Random to simulate the readings. *Store the values every 2 minutes along with data and time in four columns in a file 'sensorReadings.csv'. The columns will appear like below: Data1 Data2 Date Timearrow_forwardWrite two scripts called encryption and decryption. Test both scripts by encrypting a file called file1 and save the result in file2. Then use file2 as the input to the decryption script and check if the output is the same as file1. May I get help with this in bash shell please?arrow_forward
- Write a script to check if the current user has any processes that have been running for more than one hour. If the process has ran for more than one hour, the script should kill the process. However, the script should not kill the bash shell (that the script is run from (or any others). Commands that you may need to use might include ps, tr, tail, cat, cut, paste, echo, expr, date and kill. Note: Your script must avoid killing all bash shells. Bash is most frequently listed in the results of ps as just bash, but can be listed as /bin/bash, or as part of a running script as /bin/bash script1.sh. It’s also possible that it is being run out of some nonstandard directory (like ~/bin/bash for a custom version). Note: This program will kill your graphical environment if you are using one. If you really want to see if it works, run it from console mode.arrow_forwardHelp with Python coding issue The Linux operating system is a very popular server OS. A network administrator has to protect the login/password files stored on the servers. In Linux there are two important files: /etc/passwd And it contains rows that look like this: root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin user1:x:15:51:User One:/home/user1:nologin user2:x:15:51:User One:/home/user1:nologin user3:x:15:51:User One:/home/user1:nologin This file contains login information. It's a list of the server's accounts that has userID, groupID, home directory, shell and more info. And the second file /etc/shadow, contains rows that look like this: root:$1$TDQFedzX$.kv51AjM.FInu0lrH1dY30:15045:0:99999:7::: bin:*:14195:0:99999:7::: daemon:*:14195:0:99999:7::: adm:*:14195:0:99999:7::: ftp:*:14195:0:99999:7:::…arrow_forwardIs switching from bash to another shell something that would be beneficial?arrow_forward
- Using Unix Write a Bash script that checks for all executable files in your home directory and renames them by adding the .bash suffix to each of these executables.arrow_forwardWrite a bash script for a Daily Task management utility. This is a simple utility that has the function to manage task for a user for a single day. The utility should have the following properties: The utility must be password protected User must be able to add a task User must be able to delete the completed task User must be able to search tasks Display all the task.arrow_forwardScenario: You have been tasked with building a URL file validator for a web crawler. A web crawler is an application that fetches a web page, extracts the URLs present in that page, and then recursively fetches new pages using the extracted URLs. The end goal of a web crawler is to collect text data, images, or other resources present in order to validate resource URLs or hyperlinks on a page. URL validators can be useful to validate if the extracted URL is a valid resource to fetch. In this scenario, you will build a URL validator that checks for supported protocols and file types.arrow_forward
- May I get help with this in bash shell.arrow_forwardWrite a complete bash script that takes a filename as input using the readcommand. The script first checks if the file exists. If the file exists thencontinue with rest of the script. If the file does not exist output that itdoesn’t exist and end the script. If the file exists then check if the file isexecutable. If the file is executable, output a message indicating it isexecutable else if the file is not executable then make the file executableusing the chmod command and output a message indicating that the file isnow executable. Also run a ls -l on the file to verify to the user that the filehas been made executable. Use If statements and test file operators. (Usage: executableFile.sh)arrow_forwardWrite down the commands you would use for the following tasks Bob has a vital document named `sources.list` on his computer, but he doesn’t remember theexact location. So Bob asks you to help him find the file on his computer, and also, once it hasbeen found, please change the file’s permission, so only Bob can access it.Tasks:1. Find the file (sources. list).2. Change the file owner to yourself (Bob).3. Set access authority so that only you (Bob) can write/read this file.Note: since you are working on Bob’s computer, you are working under Bob’s name and have his privilegesarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- LINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.Computer ScienceISBN:9781337569798Author:ECKERTPublisher:CENGAGE L
LINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.
Computer Science
ISBN:9781337569798
Author:ECKERT
Publisher:CENGAGE L