Exercises

Download the files required for these execrises.

Self Exercises (Not to be submitted)

  1. Login to your machine from the CLI prompt, by pressing Ctrl+Alt+F1.

  2. Logout and re-login.

  3. What is your present working directory, once you login?

  4. List all the files present in your current working directory.

  5. Navigate to the Desktop directory. If such a directory is not present create one.

  6. Navigate back to the home directory.

  7. Create a directory called ult inside another directory called sees. Create both the directories in a single command.

  8. What would be your present working directory after doing the following?

    cd ~/sees/./../
  9. Use the touch command to create a file with your name in the ult folder.

  10. Remove the file you created in the previous step.

  11. Navigate to your home directory and remove the directory sees. Use rm command.

  12. Re-create the directories sees and ult again. Now, remove them using the rmdir command. Use man or --help, if required.

  13. Create a file with your first-name in your home directory and copy it to sees/ult.

  14. Copy the file again, but this time, ensure that cp checks if such a file doesn’t already exist.

  15. Copy the directory sees to the directory sttp.

  16. Rename directory sttp with your name.

  17. Create a file test and modify its permission for user and group to execute.

  18. For the same test file, change mode to r,w,x for all(user,group,others).

  19. Change ownership of the file test to some other user (if exists).

  20. Count the number of files (files, sub-directories, etc.) in a directory.

  21. Create a new file alice.txt by concatenating the first 30 lines and the last 40 lines of wonderland.txt.

  22. Show the lines from 10 to 20 of primes.txt

  23. Concatenate the content of foo.txt and bar.txt in a single foobar.txt but with the source:wikipedia line appearing only once, at the end of the file.

For Assessment (assignment to be submitted before Monday, 8th Aug, 8am)

  1. Read through the section REGULAR EXPRESSIONS in man grep

  2. Read through in man expr

  3. grep the marks of the students who scored above 75 in atleast one subject.

  4. grep the marks of all the students whose names begin with an ‘s’

  5. grep the marks of all the students whose names begin with consonants.

  6. change the results.sh script to accept the input files also as arguments.

  7. Write a shell script that will take a filename as input and check if it is executable.

  8. Modify the script in the previous step, to remove the execute permissions, if the file is executable.

  9. Write a shell script to remove all executable files from a directory, when a directory is given as argument.

  10. List all the years between 2001 and 2099 which have 5 Fridays, Saturdays and Sundays in the month of July. Hint: man cal

  11. Generate frequency list of all the commands you have used, and show the top 5 commands along with their count. (Hint: history command will give you a list of all commands used.)

  12. generate a word frequency list for wonderland.txt. Hint: use grep, tr, sort, uniq (or anything else that you want)

  13. Print the middle line of the file wonderland.txt.

  14. Write a code that lists the last word of the string in one file and remaining string in another file. E.g.-In “Who is Homer Simpson”,’Simpson’ should be written in one file and ‘Who is Homer’ should be written in another file.

  15. Write a bash script that takes 2 or more arguments,

    • All arguments are filenames
    • If fewer than two arguments are given, print an error message
    • If the files do not exist, print error message
    • Otherwise concatenate files
  16. Write a script that takes exactly one argument, a directory name. If the number of arguments is more or less than one, print a usage message. If the argument is not a directory, print another message. For the given directory, print the five biggest files and the five files that were most recently modified.

Table Of Contents

Previous topic

Introducing Linux

Next topic

Using LaTex

This Page