1. Explain the following unexpected result: $ whereis date date: /bin/date ... $ echo $PATH .:/usr/local/bin:/usr/bin:/bin $ cat > date echo "This is my own version of date." $ ./date Sunday April 14 10:00:49 PDT 2020

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

1. Explain the following unexpected result:
$ whereis date
date: /bin/date ...
$ echo $PATH
.:/usr/local/bin:/usr/bin:/bin
$ cat > date
echo "This is my own version of date."
$ ./date
Sunday April 14 10:00:49 PDT 2020

2. What are two ways you can execute a shell script when you do not have execute
permission for the file containing the script? Can you execute a shell
script if you do not have read permission for the file containing the script?


3. What is the purpose of the PATH variable?
a. Set the PATH variable so that it causes the shell to search the following
directories in order:
• /usr/local/bin
• /usr/bin
• /bin
• /usr/kerberos/bin
• The bin directory in your home directory
• The working directory
b. If there is a file named doit in /usr/bin and another file with the same
name in your ~/bin directory, which one will be executed? (Assume that
you have execute permission for both files.)
c. If your PATH variable is not set to search the working directory, how
can you execute a program located there?
d. Which command can you use to add the directory /usr/games to the end
of the list of directories in PATH?

4. Assume you have made the following assignment:
$ person=zach
Give the output of each of the following commands:
a. echo $person
b. echo '$person'
c. echo "$person"

5. The following shell script adds entries to a file named journal-file in your
home directory. This script helps you keep track of phone conversations
and meetings.
$ cat journal
# journal: add journal entries to the file
# $HOME/journal-file
file=$HOME/journal-file
date >> $file
echo -n "Enter name of person or group: "
read name
echo "$name" >> $file
echo >> $file
cat >> $file
echo "----------------------------------------------------" >> $file
echo >> $file
a. What do you have to do to the script to be able to execute it?
b. Why does the script use the read builtin the first time it accepts input
from the terminal and the cat utility the second time?

6. Assume the /home/zach/grants/biblios and /home/zach/biblios directories
exist. Give Zach’s working directory after he executes each sequence of
commands given. Explain what happens in each case.
a.
$ pwd
/home/zach/grants
$ CDPATH=$(pwd)
$ cd
$ cd biblios
b.
$ pwd
/home/zach/grants
$ CDPATH=$(pwd)
$ cd $HOME/biblios

7. Name two ways you can identify the PID number of the login shell.

8. Give the following command:
$ sleep 30 | cat /etc/inittab
Is there any output from sleep? Where does cat get its input from? What
has to happen before the shell displays another prompt?

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education