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

UNIX Shell Utilities 5. Cron is a job scheduling utility provided by Linux/Unix

ID: 3709112 • Letter: U

Question

UNIX Shell Utilities

5. Cron is a job scheduling utility provided by Linux/Unix systems, and it allows for periodical execution of predefined commands. Cron jobs are defined using crontab files (You can read more about crontab files here http://www.adminschoice.com/crontab-quick-reference). Write a crontab line that creates an empty file named update.txt under the home directory at 6:32PM of every 7th, 14th, 21st and 28th days of every month. [4 pts] 6. i) Create an A4tmp directory in your home directory. ii) Read the man page for the find command. Find out all files (only files) within or below the /var/log directory that have a file size greater than 2000 bytes, while directing all stderr messages to a file called logerror.txt in the A4tmp directory in your home directory. [4 pts] 7. i) How many entries with .gz extension are there in the /usr/share/man/manl directory? ii) Within them, how many are not symbolic links? Note that in the output of ls -1, a symbolic link has letter 1 at the start of its line, it also has a" -> " sign in its line. [4 pts 8. i) How many words, lines and characters are there in /usr/share/dict/words respectively? ii) Based on the result in i), how many words are there on each line of the file? iii) Save the words between 100-200 and 400-600 (both inclusive) in this file to files named 100-200.txt and 400-600.txt in your /A4tmp directory, respectively. [4 pts

Explanation / Answer

Answer 5

32 18 7,14,21,28 * * touch /tmp/file1.txt

Explanation

32 is the minute

18 is for 6pm

7,14,21,28 is for every 7,14,21,28 days

Answer 6

mkdir A4tmp

find /var/log -type f -size +2000c 2>/home/student/A4tmp/logerror.txt

Explanation

command name is find

-f ----> for files only

+2000c ---->great than 2000 bytes

2> -----> only the errors are redirected to the file /home/student/A4tmp/logerror.txt

Answer 7

| sign is used for one command output as a input of other command

i)
ls -l /usr/share/man/man1/*.gz|wc -l

Here wc -l is used to count the lines of all the files with .gz extension

ii)
ls -l /usr/share/man/man1/*.gz|grep -v "^l"|wc -l

Here grep -v "^l" is used to search the lines not containing 'l' as a first character of every lines in ls -l output and then they are counted by wc -l

Answer 8)

i)
wc -w -l -c /usr/share/dict/words

ii) From the output we can see that number of lines and words are same, it means each line has only one word.

iii)

head -200 a1.txt|tail -101 > /home/student/A4tmp/100-200.txt

head -600 a1.txt|tail -401 > /home/student/A4tmp/400-600.txt

Explanation

Here in head first 200 lines are taken then last 101 are displayed, 101 means inclusive line no 100.

Any doubt you can write in comments