Really Simple Linux Questions
1 – • Write a script that takes a file of a list of words as input and orders them alphabetically.
• Amend your script so that it removes duplicate words.
• Extend your script so that it takes two files as input and merges them into
one ordered file of unique entries.
2 – Read about the ln command. Try the following:
• Use an editor to create a file with some arbitrary content. • Create a hard link to the file.
• Create a soft link to the file.
• Explain what happens when you cat the hard and soft links before, and
after, deleting the original file.
• Now replace the original file with a new file. What happens when you cat
the link files now?
3 – grep and awk, describe the use of these commands.
4 – Type in the following command: ps aux | grep “[p]s” | awk ‘{print $1}’
Describe what is happening and why.
5 – Achieve the following using awk and/or grep and xargs:
• Write a script to output the process ID of every instance of a named process you are running. You should be able to give the process name as input to the script. Make sure that only the processes named are listed, and not the script you are running.
• Now modify the script so that it kills each process in the list. You should use xargs to do this
• Create the directory tree /x/y/z using a single command.
• Create the directory /dumpGround, giving the directory read/write
permissions (only) to all when you do it. This should be done via a single
command.
• With the aid of the tar command, copy the directory structure /x/y/z to the
new location of /usr/local.
• Describe a type of file that may not be deleted by the rm command.
• Compare two directories (you should do this using the tar command and
compare the tar files).