Starting from:
$30

$24

Pre-lab 1: Linux Primer Solution

Resources for this lab:




http://linux-training.be/index.php?nav=fundamentals​​http://linuxcommand.org/lc3_writing_shell_scripts.php http://www.google.com




Pre-lab Questions:




[5] What command will show you which groups you are a member of?



[5] What does the variable “$?” show?



[5] What command will find all files with suffix ‘.txt’ in the subtree /foo/bar?



[5] With what command (and arguments) can you find out your kernel version and the “nodename”? [The output should not include any other information]



[5] What is the difference between the paths “.”, “..”, and “~”? What does the path “/” refer to when not preceded by anything?



[10] Which command would you use to find the ID (pid) for a running process? which command you will use to kill a running process using its ID?



[10] Write a single command that will return every username in the system in alphabetical order. [You may chain commands using piping and redirects]



[5] What is the difference between “sudo” and “su root”?



[10] How would you make a program or script execute on a schedule or set interval? E.g. Run this program once every 30 minutes or every day at midnight.



[40] Write a shell script that only prints the even numbered lines of each file in the current directory, except for the script itself. The output should be ​filename: line​for each even numbered line. You do not need to print line numbers.



[10] Bonus: write the script in a way that it works no matter the filename given to the script.




For example, let’s say I write a script in a file called test.sh. I then create 3 files, as shown in the screenshot below:

My directory now looks like the following:







When I run the script, the output should look like the following.













Submit your answers for questions 1 through 9 in a PDF file, and the shell script (questions 10 and bonus) in a separate file.

More products