ASSIGNMENT -- 1

  1. Create a file and check what the permissions on this file are as given by default by Linux. Then, change permissions as follows:

    other-r(read), group-rw(read,write), user-rwx(read, write, execute)

  2. Print the lines 11-15 of a given file. Create a file with 20 lines of text and use it as your input file. (Hint: You need to combine head and tail through a pipe to do this)
  3. In the file you created for the exercise above, extract the characters in positions 3,5,10 from each line in given file and save them to extract.txt.
  4. Take the sample file and print the 3rd column and 5th column to end. Note that the delimiter in this file is ":". See manual page of cut to determine how to specify from a column to the end of line and use it. DO NOT use 5-n where n is the number of the last column.
  5. Find all the files which start with "y" in the directory /usr/include directory and also count the number of such files. (Hint: pipe it to wc)
  6. Create a directory "a1" in your "courses/itw" directory and two sub-directories under it. Create files in both the sub-dirs. Copy all directories and files of a1 to the directory "courses/itw/a2".
  7. Instead of copying the sub-dirs of "a1", move all of them to "a2".
  8. Create a directory "temp" and create files under it. Then rename the directory to "test". Then remove the directory with both "rm" and "rmdir" commands. What is the difference between using these two commands for deleting a directory?
  9. Create a directory and create files under it. Then remove the write permission for the directory. Remove the directory. What error do you get? Why? How do you overcome it?
  10. List all the files in the /etc directory that have the string "host" as part of the file name. Specify two different ways of doing this.
  11. Download the Sample Data. Extract the first and last columns and sort the result in descending order of the last column. (Hint: use cut and pipe it through to sort)