Full file at https://fratstock.eu

Similar documents
Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

F 4. Both the directory structure and the files reside on disk Backups of these two structures are kept on tapes

Chapter 6. Linux File System

Embedded System Design

File systems and Filesystem quota

Sharing may be done through a protection scheme. Network File System (NFS) is a common distributed file-sharing method

Unix File System. Class Meeting 2. * Notes adapted by Joy Mukherjee from previous work by other members of the CS faculty at Virginia Tech

CST Algonquin College 2

UNIX File Hierarchy: Structure and Commands

Operating Systems. Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000) alphapeeler.sf.net/pubkeys/pkey.htm

Getting Started with Linux

@ Gelato. Which Filesystem???? Performance and Scalability on Itanium Peter Chubb

Introduction to Unix: Fundamental Commands

Std: XI CHAPTER-3 LINUX

Chapter-3. Introduction to Unix: Fundamental Commands

commandname flags arguments

5/8/2012. Creating and Changing Directories Chapter 7

Hands-on Keyboard: Cyber Experiments for Strategists and Policy Makers

Welcome to getting started with Ubuntu Server. This System Administrator Manual. guide to be simple to follow, with step by step instructions

Unix Filesystem. January 26 th, 2004 Class Meeting 2

Commands are in black

Linux Files and the File System

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

Lecture 2: The file system

CST8207: GNU/Linux Operating Systems I Lab Nine Disks, Partitions, and File Systems Part 2. Disks, Partitions, and File Systems - Part 2 of 2

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

The UNIX Operating System. HORT Lecture 2 Instructor: Kranthi Varala

Manage Directories and Files in Linux. Objectives. Understand the Filesystem Hierarchy Standard (FHS)

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

SECTION -C. Getting Started with UNIX

Introduction to UNIX command-line

Working with Basic Linux. Daniel Balagué

CSCI 2132 Software Development. Lecture 4: Files and Directories

Linux Command Line Primer. By: Scott Marshall

Introduction to Linux Basics

Linux Shell Script. J. K. Mandal

This is Worksheet and Assignment 12. Disks, Partitions, and File Systems

Linux & Shell Programming 2014

Introduction to Linux

Unix Tutorial Haverford Astronomy 2014/2015

ECE 598 Advanced Operating Systems Lecture 14

CS Fundamentals of Programming II Fall Very Basic UNIX

Introduction to Linux

LAB #7 Linux Tutorial

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

CS Unix Tools. Lecture 2 Fall Hussam Abu-Libdeh based on slides by David Slater. September 10, 2010

Mills HPC Tutorial Series. Linux Basics I

Introduction of Linux

Overview LEARN. History of Linux Linux Architecture Linux File System Linux Access Linux Commands File Permission Editors Conclusion and Questions

Operating Systems: Lecture 12. File-System Interface and Implementation

UNIX System Programming Lecture 3: BASH Programming

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

Lab 1: Introduction to Linux Networking

Introduction to the UNIX command line

Lab #9: Configuring A Linux File Server

Introduction to Linux

INTRODUCTION TO LINUX

Unix System Architecture, File System, and Shell Commands

Essential Unix and Linux! Perl for Bioinformatics, ! F. Pineda

Student Remote Login Procedure (see picture below): 1. Start SSH Secure Shell 2. Click the computer icon (4 th on the toolbar) 3.

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12)

V Workstation Imaging

Filesystem Hierarchy and Permissions

CSC209. Software Tools and Systems Programming.

Kubuntu Installation:

HOW TO CLONE A LARGE NUMBER OF PCs

Unix File System. Learning command-line navigation of the file system is essential for efficient system usage

*nix Crash Course. Presented by: Virginia Tech Linux / Unix Users Group VTLUUG

Chapter 10: File-System Interface

CS197U: A Hands on Introduction to Unix

Week 2 Lecture 3. Unix

CS246 Spring14 Programming Paradigm Notes on Linux

Introduction to Linux. Fundamentals of Computer Science

CISC 220 fall 2011, set 1: Linux basics

Week 2. Exp 2 (a) (b): Introduction to LINUX OS, Installation of LINUX OS, Basic DOS commands

Files and Directories

Chapter 10: File System. Operating System Concepts 9 th Edition

Introduction to Linux (Part I) BUPT/QMUL 2018/03/14

Chapter 10: File-System Interface

Week Overview. Unix file system File types and file naming Basic file system commands: pwd,cd,ls,mkdir,rmdir,mv,cp,rm man pages

GNU/Linux 101. Casey McLaughlin. Research Computing Center Spring Workshop Series 2018

Overview of the UNIX File System. Navigating and Viewing Directories

Introduction to Linux Part I: The Filesystem Luca Heltai

Chapter 02 Linux Installation and Usage

Linux File System Study Guide

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

RocketRAID 2522 SATA Controller Ubuntu Linux Installation Guide

Embedded Linux Systems. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

A Brief Introduction to Unix

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

CST8207: GNU/Linux Operating Systems I Lab Six Linux File System Permissions. Linux File System Permissions (modes) - Part 1

INSE Lab 1 Introduction to UNIX Fall 2017

Unix tutorial. Thanks to Michael Wood-Vasey (UPitt) and Beth Willman (Haverford) for providing Unix tutorials on which this is based.

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

Filesystem and common commands

Chapter 4. Unix Tutorial. Unix Shell

Frequently asked questions from the previous class survey

Overview of the UNIX File System

Operating Systems. Copyleft 2005, Binnur Kurt

Filesystem Hierarchy Operating systems I800 Edmund Laugasson

Transcription:

Guide to UNIX Using Linux Fourth Edition Chapter 2 Solutions Answers to the Chapter 2 Review Questions 1. Your company is discussing plans to migrate desktop and laptop users to Linux. One concern raised by the users is whether Linux supports the use of CDs and DVDs for both work files and for listening to music. Which of the following is an appropriate answer? Answer: c. Linux supports both the UDF and iso9660 file systems for CD and DVD use. 2. You receive a message that you ve successfully backed up hda2 on your Linux system. What is hda2? Answer: b. the second partition on your main hard disk 3. You have purchased a special monitor for your computer and the instructions tell you to make a minor modification to the inittab file. Where would you locate this file on a typical Linux system? Answer: d. /etc 4. You re frantically trying to get ready for a meeting and want to access a file in your home directory, but you are currently working in a public directory open to all users. What command can you enter to instantly go to your home directory? Answer: a. cd 5. Your new colleague asks which partitions vendors recommend setting up on a Linux system. Which of the following partitions do you include in your response? (Choose all that apply.) Answer: b. root, c. swap, and d. /boot 6. You have mounted a remote network drive and now you want to unmount that drive. Which of the following commands do you use? (Choose all that apply.) Answer: b. umount 7. When you connect a printer via a USB port on your Linux computer, which type of device special file is used to handle streams of data sent to and from the printer? Answer: a. character special file 8. Some of the users in your company create and delete so many files that they have problems with fragmented disks. Which of the following new features in the ext4 file system help to reduce fragmentation problems? Answer: d. extents 9. In UNIX and Linux systems, what source of extra memory space is used when working on tasks and files that exceed the RAM capacity on chips in the computer? Answer: b. swap partition 10. You are always scheduled for two or three meetings each day and need to keep an eye on the time. What PS1 variable parameter can you set in order to have your command prompt display the current time? Answer: a. \t 11. You have been working in several directories for the past hour and right now you don t remember which directory you re in currently. What command can you use to show your current working directory? Answer: c. pwd 1

12. A member of your department has given you permissions to view the contents of the accounting directory under his home directory. The name of his home directory is bramirez. Which of the following commands should you use to display the contents of the accounting directory? Answer: c. ls /home/bramirez/accounting 13. It s late and you have been working all day to finish a report. Before you go home you want to copy several files including your report file. What copy command should you use to ensure that you don t inadvertently copy an older report file over the newer report file you ve been working on for the last four hours? Answer: a. cp -u 14. Which of the following are file systems supported by UNIX and Linux operating systems? (Choose all that apply.) Answer: a. NTFS, b. vfat, d. ufs, and e. ext 15. You are helping a friend who is new to Linux. You want to determine which entries under her home directory are directories instead of files. When you perform a long listing of the home directory s contents, what do you use to distinguish a directory from a file? Answer: d. The very first character in the line for an entry will be d for directory or - for an ordinary file. 16. Your boss is planning to do some house cleaning by deleting several old files. However, she mentions that she doesn t want to delete an important file inadvertently. What command can she use so that she is prompted to make sure she wants to delete a particular file? Answer: d. rm -i 17. You are curious about the error and system logs kept by your operating system. In what main directory under the root (/) would you most likely find these logs? Answer: a. /var 18. A friend of yours is trying to make more space on his hard disk drive and is considering deleting the /lib directory because he has heard it mostly contains games that he doesn t use. What is your recommendation? Answer: d. Keep the /lib directory because it holds security information, shared library images, kernel modules and other important files. 19. Which of the following are permissions that can be granted to a file? (Choose all that apply.) Answer: b. write, c. execute, and e. read 20. Which of the following commands enable(s) you to set permissions on a directory after you create it? (Choose all that apply.) Answer: c. chmod 21. You have created many notes to yourself that end in.txt. Which of the following commands enables you to list all of the.txt files in your home directory while you are in the Bash shell? Answer: b. ls *.txt 22. Short answer: Where is virtual memory located? Answer: Virtual memory is located on disk, such as in swap space. 23. Short answer: When you see the permissions rwx--x--x associated with a file, what permissions are granted? Answer: The permissions that are granted are: owner has read, write, and execute; group has execute; and others have execute. 2

24. Short answer: Your boss wants to use the command to view hidden files and also wants to know how to find them among other files. What do you tell her? Answer: The command to view hidden files is ls -a. In the resulting list of files, the hidden files are the files that start with a dot (.) in front of the file name.. 25. Short answer: You have many files that begin with the word account and that end with two digits to designate a year, such as account00, account 01, and so on. What is the command that enables you to view all of these files that start with account? Answer: The ls account?? command will display all of the files that start with account. Hands-On Projects Tips and Solutions for Chapter 2 Project 2-1 In this project, students determine the file systems that can be mounted in a Linux system. In Step 2, the file systems are likely to include some or any of the following (note that there are many more than discussed in the text, because the text is intended to cover the basic options and not all possibilities, including those for devices): adfs affs autofs coda coherent cramfs devpts efs ext ext2 ext3 hfs hpfs iso9660 jfs minix msdos ncpfs nfs ntfs proc qnx4 ramfs reiserfs romfs smbsf sysv tmpfs udf ufs umsdos vfat xenix xfs xiafs 3

In Step 3, the file systems that students see will depend on how their system is set up. Typical examples of mounted file systems are: ext3 proc usbdevfs (for usb devices) devpts (for devices) tmpfs (for temporary storage) Project 2-2 This project enables students to mount and unmount a CD. They will need access to the root account and a CD that can be mounted and read. In Step 6 of the first set of steps, to mount a floppy (depending on the floppy device), students would use the following command after inserting the floppy disk: mount -t vfat /dev/fd0 /mnt/floppy (or replace mnt with media) To unmount the floppy they would use: unmount /mnt/floppy (or replace mnt with media) Project 2-3 Students first view the contents of the PS1 variable and then they configure it to show the day of the week, date, and time, then show the current working directory,, and finally to show the full path to their home directory. In Step 6, students should find that the prompt goes back to the default before they started configuring the PS1 variable. Project 2-4. For this project, students practice using the pwd command. In Step 2, students should report their working directory, such as their home directory. Project 2-5 Students begin by changing the prompt to display their working directory. Then they practice using the cd command. Project 2-6 For this project, students use the cd command to compare absolute and relative paths. Project 2-7 In this project, students navigate using the dot and dot dot conventions. Project 2-8 This project enables students to practice using the ls command. 4

In Step 1 of the third set of steps, students display the contents of the /dev file. They should note that a c in the first position of the first column indicates a character special file. Project 2-9 In this project, students practice using the * and? wildcards with the ls command. Project 2-10 Students create two directories and a file in each directory for this project, which enables them to use the mkdir and cat commands. Ensure that the students keep the files they create for use in later projects. Project 2-11 This project has the students create a simple telephone database to practice using multiple commands: cd, mkdir, cp, and cat. Project 2-12 In this project, students practice setting permissions on directories and files to make them available for access by general users. Students use the subdirectory and the file they created in Hands-on Project 2-11. Discovery Exercises 1. Use the ls command to list the contents of the root file system directory (/) on your system. Answer: Students should type ls / to view the contents of the root directory. 2. Use the ls -l command to view the contents of the root file system directory (/). Answer: Students should type ls -l / to view the contents of the root directory. 3. Determine the inode value for the /etc directory. Answer: The command to determine the inode value is ls -i /. 4. Make /etc your current working directory and then go back to your home directory Answer: Students should type cd /etc and then type cd to return to their home directories. 5. Make the root file system directory your current working directory. What command can you use to verify that you are in the root file system directory? Return to your home directory. Answer: Students should first type cd / to go to the root directory and then type pwd to verify that is their current working directory. Last, they use cd to go back to their home directory. 6. The file info.txt is in the help directory, which is a subdirectory of the /dev directory. What is the absolute path to info.txt?. Answer: The full path is: /dev/help/info.txt. 7. Change to the /dev directory. Next, access your home directory using a tilde (~) in the command that you employ. 5

Answer: Students should first enter cd /dev to go to the /dev directory. Next, they should enter cd ~ to return to their home directory. 8. Determine whether there are any hidden files in the /home directory. Answer: Use the command ls a /home. Typically, students will find there are no hidden files in /home. 9. Make a directory under your home directory called documents. Next make a directory under the documents directory called spreadsheets. What is the absolute path for the spreadsheets directory? Answer: First, students should use cd or pwd to make sure they are in their home directory (use cd to change to the home directory). Next, they should enter mkdir documents. Next, they can use cd documents and type mkdir spreadsheets. The absolute path is /home/username/documents/spreadsheets. 10. Make certain you are in your home directory. Use a relative path to make your new documents directory the current working directory. Next, use a relative path to make the spreadsheets directory your current working directory. Now, use a command with dots in it to make the documents directory your current working directory. Answer: First, enter cd documents and then enter cd spreadsheets. Next, enter cd.. to move back to the documents directory. 11. With your home directory as your current directory, use the command to remove read, write, and execute permissions from group and others for the spreadsheets directory. Next, verify that your change has taken place. Answer: The command students can use is: chmod go-rwx ~/documents/spreadsheets. To verify their work, students should enter ls -l ~/documents. 12. Use the cat command to create a two-line file in your home directory called datainfo. On the first line enter 144 and on the second line enter 288. After the file is created, copy it from your home directory to the spreadsheets directory you created. Answer: To create the datainfo file, students can first use the cd command to make sure they are in their home directory. Next, they should type cat > datainfo, enter the two lines and type Ctrl+d. Finally, to copy the file they enter cp datainfo ~/documents/spreadsheets. 13. Determine the default permissions on the datainfo file your created. Next, set the permissions on the datainfo file so that the owner, group, and others can read and execute the file (otherwise leave the default settings as is). Answer: Students can use the ls l command, such as ls l ~/documents/spreadsheets to determine the default permissions (-rw-rw-r--). To set the permissions enter chmod ugo+rx ~/documents/spreadsheets. 14. Append the current month s calendar to the datainfo file that is in your home directory. Next copy your changed datainfo file over the older datainfo file in the spreadsheets directory, but use the copy option that prompts you before you overwrite the file in the spreadsheets directory. Check the contents of the datainfo file in the spreadsheets directory to make certain your copy was successful. Answer: Make sure you are in your home directory. Enter cal >> datainfo. To copy the new file over the old one, with a verification prompt, enter cp -i datainfo ~/documents/spreadsheets. Last, to verify the contents of the file enter, (such as from the home directory) cat ~/documents/spreadsheets/datainfo (or students might use the more or less commands instead of cat). 15. Make the spreadsheets directory your working directory. Make copies of the datainfo file in the spreadsheets directory, so that one copy is named myinfo and one is named datadata. Next, use a wildcard character to list all files that start with data. Use a wildcard character to list all files that 6

end with info. Use a wildcard character combination to list all files that have ata as the second, third, and fourth characters. Answer: One way to change directories is to type cd documents and then cd spreadsheets. Enter cp datainfo myinfo and then cp datainfo datadata. Enter ls data* to list the files starting with data. Enter ls *info to list the files ending with info. Enter ls?ata* to list the files with ata as the second, third, and fourth characters. 16. Make certain you are in your home directory. Change your command prompt so that it shows your current working directory with an exclamation point, such as mydirectory! Change to the spreadsheets and then to the documents directory and notice how the prompt changes Answer: Enter cd to go to the home directory. Enter PS1= \w! to change the command prompt. Use the cd documents and then cd spreadsheets commands to go to the documents directory and then the spreadsheets directory and notice that the command prompt changes to show that directory. Use cd.. to go to the documents directory and verify the prompt. 17. Change to your home directory. Use the rmdir command to delete the spreadsheets directory. What happens? Answer: Students should see an error message that the directory is not empty. 18. Delete the datainfo files in both your home directory and in the spreadsheets directory. Also, delete the myinfo and datadata files in the spreadsheets directory. Answer: Enter rm ~/documents/spreadsheets/datainfo and enter rm datainfo from the home directory, for example, to delete both instances of the file. Enter rm ~/documents/spreadsheets/myinfo and then enter rm ~/documents/spreadsheets/datadata. 19. Change to your home directory. Delete the spreadsheets directory and then delete the documents directory. Answer: Type cd. Enter rmdir ~/documents/spreadsheets and then enter rmdir documents. 20. Create a directory called secure under your home directory. Next, using the octal permission format, set security on the secure directory so that you have all permissions and no one else has any permissions. Answer: Type mkdir secure and press Enter. Next type chmod 700 secure and press Enter. 7