Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a command to show how much space on the disk your current directory and

ID: 3578319 • Letter: 1

Question

1. Write a command to show how much space on the disk your current directory and its subdirectories are using. The output should also include stats for files in addition to directories, and the file and directory sizes should be shown in a format that’s easier to understand at a glance.

2. Research the dump command. Write a command to initiate a backup using dump with the following parameters:

* The partition being backed up is /dev/sda9

* The tape drive being used for backup is /dev/rmt/0

* Perform backup on all files

3. Consider this script file named 6hw, the information shown about it, and its contents. There are five reasons why this script will either refuse to run or will throw errors. Name each of the five things wrong, and what you would do, specifically to correct each one (if there's a command you would use to correct it, show the full command; if there's a change that needs making in the script, just say what is wrong and what you would change it to). Assume that you are the file's owner and the group shown is your group.

-rw-r--r-- 1 yourname yourgroup 203 Jan 27 20:36 6hw

The contents of the file:

!/bin/bash

echo "Please state your name."

read name

if [ "$moniker" = "Horatio" ]

then

echo Welcome to the Internet, $name!

else

echo "You are not Horatio, $name, but there's room enough for us all."

4. Write a command to display information about the used and free space on the file system, showing only local file systems, and then send the output of the command to the screen and to three files named status1, status2, and status3. Do this all in one command line.

Explanation / Answer

1. ### du comannd to check disk usage. Below command : (-hc for human readable format and total) and . for current directory
du -hc .

2. Dump command:
Dump examines files on an ext2/3 filesystem and determines which files need to be backed up. These files are copied to the given disk, tape or other storage medium for safe keeping (see the -f option below for doing remote backups). A dump that is larger than the output medium is broken into multiple volumes. On most media the size is determined by writing until an end-of-media indication is returned.
On media that cannot reliably return an end-of-media indication (such as some cartridge tape drives), each volume is of a fixed size; the actual size is determined by specifying cartridge media, or via the tape size, density and/or block count options below. By default, the same output file name is used for each volume after prompting the operator to change media.

files-to-dump is either a mountpoint of a filesystem or a list of files and directories to be backed up as a subset of a filesystem. In the former case, either the path to a mounted filesystem or the device of an unmounted filesystem can be used. In the latter case, certain restrictions are placed on the backup: -u is not allowed, the only dump level that is supported is 0 and all the files and directories must reside on the same filesystem.

For question:
dump -0u /dev/rmt/0 /dev/sda9


3.

!/bin/bash
#!/bin/bash

echo "Please state your name."
read name

###if [ "$moniker" = "Horatio" ]
if [ "$name" = "Horatio" ]

then
echo Welcome to the Internet, $name!
else
echo "You are not Horatio, $name, but there's room enough for us all."
fi

Currently the script not executable, therefore set the executable permission for script for user and group :

chmod ug+x 6hw

4. df -h 0>status1 2>status2|tee status2

df = disk free command
-h = human readable format
0> = stdin output file
2> = stderr output file
tee = command to store the screen output to log file.