ASSIGNMENT -- 1

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

    other-(none), group-x(read,write), user-rwx(read, write, execute). Now, change to the directory and list the contents of the directory. After this, change the permissions of the user to only rw(read, write). Change and list the contents of the directory. What happens? Add x permission back to the directory and remove the rw permissions to the directory. Change and list the contents of the directory again. What is your observation now? Change the permission to r-x (read and execute only, no write). What operations are possible and not possible in this directory?

  2. Create a file with 100 lines. You can just write one line and copy it 99 times. It is very easy to do with vi but not so easy I guess(?) with other editors. Print the lines 25-35 of a given file. (Hint: You need to combine head and tail through a pipe to do this)
  3. Take the sample file and print the 1st-4th columns and last column. Note that the delimiter in this file is ":".
  4. Count the number of files with the extension .conf in the directory /etc.
  5. 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".
  6. How do you move a directory from one location to another location? For e.g., create two directories called d1 and d2 and create a sub-dir called test under d1. Create some files using touch under test. Move the directory test from d1 to d2.
  7. List all the files in the /etc directory that have the string "login" as part of the file name. This should list files which are present in all the sub-directories of etc and not just from etc. Specify two different ways of doing this.Redirect the output to a file called login.out and all errors to login.err when running the command.
  8. Download the Sample Data. This file consists of the country name, the gold, silver and bronze medals won at Athens Olympics. Sort the file in descending order of gold medals. If possible, study how to sort first by gold and within that by silver and then by bronze, i.e., if there is a tie in gold, the country with higher silver medals should be first and so on.
  9. In the directory /usr/include/ how many files have the substring "li" in their name?
  10. Create a file with some text in a test directory. Create a soft link to that file from some other directory. Delete the soft link. Does the original file still exist? Are you able to see the contents of the file? Repeat the experiment but delete the original file now. Does the soft link still exist? Are you able to see the contents of the file? Delete both directories now using rmdir. Do you get any errors?