3.7
How does the command mv bar1 bar2 behave, here both bar1 and bar2 are directories, When (i) bar2 exists, (ii) bar2 doesn’t exist?
3.8
explain the difference between the commands cd ~charlie and cd~/Charlie is it possible for both commands to work?
3.9
Charlie uses /usr/Charlie as his home directory, and many of his scripts refer to the pahname /usr/Charlie/html. Later, the home directory is changed to /home/Charlie. Thus breaking all his scripts. How could charile have avoided this problem?
3.14
Explain what the following commands do: (i) cd, (ii) cd $HOME, (iii) cd~.
3.18
what is the significance of these commands? (i) mv $HOME/include (ii) cp –r bar1 bar2, (ii) mv * ../bin.
3.22
how do DOS and UNIX test files differ? Name the utilities that convert files between these two formats.
3.26
Name three advantages zip has over gzip.
4.1
a file in a file system with a block size of 1024 bytes contains 1026 bytes. How many bytes of disk space does it occupy?
4.4
create a file foo. How do you assign all permissions to the owner and remove all permissions from others using (i) relative assignment and (ii) absolute assignment? Do you need to make any assumptions about foo’s default permissions?
4.9
you tried to copy a file foo from another user’s directory, but you got the error message cannot create file foo. You have write permission in your own directory. What could be the reason, and how do you copy the file?
4.10
what do you do to ensure that no one is able see the names of the files you have?
4.13
if the owner doesn’t have write permission on a file but her group has, can she (i) edit it, (ii) delete it?
5.2
how will you add /* at the beginning of a line and */ at the end?
5.6
in the midst of your work, how can you see the list of users logged in? if you have a number of UNIX commands to execute, which course of action will you take?
5.13
how will you search for a pattern printf and then repeat the search in the opposite direction from that in which the original search was made?
5.16
if the power to the machine is cut off while a vi session is active, how does it affect your work? What salvage operation will you try?
5.18
you made some changes to a read-only file and then found that you can’t save the buffer. What course of action will you take without quitting the editor?
|
<[Spring 2018]8 |
IFT 250: Shell & Script Programming with Unix |
|
Lab Activity 2A: The File System |
Learnings
· How to implement a simple file structure
· The difference between relative and absolute pathname
· Basic commands to manipulate files and directories
Part I: Growing your knowledge
Using the UNIX commands you have learned so far, create the following directory tree, shown in blue. Once the directory tree has been created, you will populate the directories with the appropriate files, shown in black. Once you are done, change your working directory to the IFT250 directory and run the find command to display the files you just created. Capture and attach a screenshot of the output and attach to the lab document.
Screenshot is the output of the tree command showing the required directory structure
Part II: Absolute Power and Relative Force
Use the commands you’ve learned to create the following files with the appropriate contents provided below.
~/IFT250/Unit2/Labs/this.txt
This is a file for learning relative paths, absolute paths, and directory structure
this.txt belongs in the ~/IFT250/Unit2/Labs directory
This file is in a directory which is a subdirectory of ~/IFT250
/Unit2
The directory name is Labs, and the full pathname is ~/IFT250/
Unit2/Labs
~/IFT250/Unit2/Labs/this.txt
This is a file for learning relative paths, absolute paths, and directory structure
this.txt belongs in the ~/IFT250/Unit2/Labs directory
This file is in a directory which is a subdirectory of ~/IFT250/Unit2
The directory name is Labs, and the full pathname is ~/IFT250/Unit2/Labs
~/IFT250/Unit2/Homework/this.txt
This is a file for learning relative paths, absolute paths, and directory structure
this.txt belongs in the ~/IFT250/Unit2/Homework directory
This file is in a directory which is a subdirectory of ~/IFT250/Unit2
The directory name is Homework, and the full pathname is ~/IFT250/Unit2/Homework
~/IFT250/Unit2/Lectures/this.txt
This is a file for learning relative paths, absolute paths, and directory structure
this.txt belongs in the ~/IFT250/Unit2/Lectures directory
This file is in a directory which is a subdirectory of ~/IFT250/Unit2
The directory name is Lectures, and the full pathname is ~/IFT250/Unit2/Lectures
~/IFT250/Unit2/this.txt
This is a file for learning relative paths, absolute paths, and directory structure
this.txt belongs in the ~/IFT250/Unit2 directory
This file is in a directory which is a subdirectory of ~/IFT250
The directory name is Unit2, and the full pathname is ~/IFT250/Unit2
~/IFT250/this.txt
This is a file for learning relative paths, absolute paths, and directory structure
this.txt belongs in the ~/IFT250 directory
This file is in a directory which is a subdirectory of your home directory
The directory name is Labs, and the full pathname is ~/IFT250/
~/IFT250/Unit1/Labs/this.txt
This is a file for learning relative paths, absolute paths, and directory structure
this.txt belongs in the ~/IFT250/Unit1/Labs directory
This file is in a directory which is a subdirectory of ~/IFT250
The directory name is Labs, and the full pathname is ~/IFT250/Unit1/Labs
After you’ve created the above files run the following commands and answer the questions below.
The semi-colon (;) is used to execute more than one command at a time.
1. cd ~/IFT250/Unit2/Labs; pwd
a. What is the output?
2. cat ../Homework/this.txt
a. What is the output?
b. What is the full path name of the file accessed?
3. cd ~/IFT250/Unit2/Lectures; pwd; cat ./this.txt
a. What is the output?
4. cat ../../this.txt
a. What is the output?
b. What is the full path name of the file accessed?
5. pwd; cat ~/IFT250/this.txt; cat ~/IFT250/Unit2/Labs/this.txt
a. What is the output?
6. cd ~/IFT250/Unit1/Labs; pwd
a. What is the output?
7. cat ../../this.txt
a. What is the output?
b. Provide the full pathname of the file displayed or sought
8. cat ././this.txt
a. What is the output?
b. What is the full path name of the file accessed?
Page | 5
<[Spring2018]>
IFT 250: Shell & Script Programming with Unix
|
Lab Activity 2B: Shell Commands |
Learnings
· Basic UNIX commands
· Advanced UNIX commands
· Useful applications of UNIX commands
Part I: Basic Commands
List the commands that you would use to complete the following tasks:
1. List the contents of your current directory
1. List the contents of a directory inside your current directory
2. List the contents of the directory above your current directory
3. List the contents of your current directory tree
4. View the contents of the lab2.1 file
5. Combined the files lab2.1, lab2.2, and lab2.3 into the file lab2.sub
6. create an empty file named lab2.4
7. Print your current working directory
8. Change your current directory to a grand-parent directory
9. Print your current working directory
10. Return to your previous directory
Part II: Advanced Commands
List the commands that you would use to complete the following tasks:
1. Locate the file lab2.2 starting from your home directory.
1. Locate all the files with “lab2” in the filename using find starting from the root directory
2. Create a directory named lab2.dir
3. Move the file lab2.1 into the directory lab2.dir with the name lab2.1.r
4. Make a copy of the file lab2.2 named lab2.2.c
5. Duplicate the directory Lab2.dir named Lab2.bak
6. Create a tar file archive called lab2.tar containing the files lab2.1, lab2.2, and lab2.3
7. Create a zip file archive called lab1.zip from compressed lab2.1, lab2.2, and lab2.3
8. Create a zip file archive of your home directory called home.zip
Page | 4