Introduction to Unix Exercises: Part 1 - Directories and Files. 1.1 Which command or command sequence will display your home directory? 1.2 What command would you use to list the contents of /etc? 1.3 What command would you use show all files in /bin directory starting with "k"? 1.4 Create a directory in your home directory called mydir. 1.5 Run the command "touch ~/mydir/myfile". This will create an empty file in mydir called myfile. Now remove the directory. (Hint: Remember the rmdir command only works on empty directories) 1.6 What command would you use to get documentation on the "wc" command? 1.7 From the documentation for the "wc" command, determine the option which will display the number of words in a file. 1.8 What command will show you the permissions on the file /etc/group? Part 2 - Process Interaction 2.1 What command would you use to start the script loop.sh in the exercises directory in the background? 2.2 Run the command for 2.1 if you haven't already. Now find the process id for the loop process. 2.3 Now kill the process using the process id you found in question 2.2. Which command did you use? 2.4 Verify that the loop command is no longer running. 2.5 Now try running bad-loop.sh. This executable won't respond to default kill signal so you will have to use something stronger. Use "./bad-loop.sh" to start it. 2.6 Now suspend the process with "CTRL+Z". Which command would you use to put this in the background? 2.7 Find the process id for bad-loop.sh 2.8 Send it the "-KILL" signal. 2.9 Verify that the bad-loop.sh process is no longer running. Part 3 - Permissions 3.1 The script some-script.sh doesn't have the correct permissions for it to be executed. Check the permissions of the script. 3.2 Add execute permissions and verify they are set. 3.3 Verify that you can execute some-script.sh 3.4 Check to see which groups you are in. 3.5 Set permissions on some-script.sh so that another person in your group can read and execute it, but not change it. Don't worry about parent directory permissions. 3.6 Verify that the permissions are set using the ls command. Part 4 - Environment variables 4.1 Which command would you use to display the current environment variables for the shell. 4.2 Display the value of only the PATH environment variable. 4.3 Set an environment variable MYVAR to "value". Use the correct syntax for your shell. Part 5 - I/O Redirection and pipes 5.1 The grep command returns lines from an input file or stdin which match a pattern. The following command will find line in the file /etc/passwd which have the string root in it somewhere. grep root /etc/passwd Use a pipe to send the output of grep into the wc command. What does the final output look like? 5.2 Save a directory listing of /usr/local/bin to a file called "ls.output". 5.3. Now append a directory list of /usr/bin to the same file. 5.4 The readit.sh script in this directory expects a file to be sent to stdin. Direct /etc/passwd to readit.sh.