Wednesday, 14 March 2018

Assignment 1 Linux | Linux

Question 1. (10 marks)

Create a subdirectory in your home directory and put a file welcome.txt with a short message, in the subdirectory.
Try to
  • set the permission bits so that the owner has executable access.
  • make the subdirectory the current directory
  • list the subdirectory
  • display the contents of welcome
  • create a copy of welcome.txt in the subdirectory;
Repeat the above experiment steps, but the owner this time just has read access;
Finally answer the following questions.
    • If a directory has 'read' permission bit, what operations are permitted for the owner to perform on the directory and/or files in the directory?
    • If a directory has 'executable' permission bit, what operations are permitted for the owner to perform on the directory and/or files in the directory
Note: You need to give out all the Linux commands used in your experiments in the submission.

Question 2. (15 marks)

Regular expressions(RE) are important tool in computer script languages. You need to contrast the (sub)strings which are matched by the following RE pairs.
  • ab.cd and ab*cd
  • ab.*cd and abb*cd
  • ^abc and ^abc$
  • [abc]d and [^abc]d
  • [A-Z][_a-zA-Z0-9]* and [A-Z_][a-zA-Z0-9]*
Note: You may test them on (sub)strings. You need to present the tested strings in your submission.

                                                                                                      

Question 3. (10 marks)

Linux find utility has a variety of usages, you can use it to
  • search for all SUID and SIGD programs in the directory of /usr/bin
  • list all the subsirectories in the current directory
  • produce a long listing of all files in /usr/bin whose filesize are larger than 750Kb
Note: Give in your submission all the commands/commandlines of performing these actions.

Question 4. (10 marks)

On the Linux system, perform the following activities,
  • Use tar to create an archive(don't use the z or j option) of all the files in the current directory.
  • Compress the archive with gzip
  • View the contents of the archive with gunzip and tar.
  • View the contents of the archive without using gunzip but using tar instead.
  • Create a subdirectory of the current directory
  • Use tar to unpack the archived file into the subdirectory.
Note you need to list all the Linux commands/commandlines of each activities in submission. 
You may generate a huge textfile by redirecting the long-listing of all files/directories under root ('/').

Question 5. (15 marks)

Assume you have a text file called myfile. Describe what each of the following sed-commands does to the text file.
sed -n '/the/ p' myfile
sed -n 's/[A-Z]/&/gp' myfile
sed '32,45 s/[()]//g' myfile
sed '/^$/d' myfile
sed 's/([0-9])-([0-9])/12/g' myfile

Here is a sample!
Question: what does sed 's/fox/ox/g' myfile do to the file of myfile?
Answer: This sed command substitutes all occurrences of fox with ox, not just the first occurrence in the file of myfile.

No comments:

Post a Comment

Recent Questions

Learn 11 Unique and Creative Writing Examples | AssignmentHelp4Me

Learn 11 Unique and Creative Writing Examples | AssignmentHelp4Me elp4Meelp4Me