LinuxBasics.org

The community that helps people to run Linux

rss

5.5. Exercises

These exercises give more examples on how to combine commands. The main goal is to try and use the Enter key as little as possible.

All exercises are done using a normal user ID, so as to generate some errors. While you’re at it, don’t forget to read those man pages!

  1. Use the cut command on the output of a long directory listing in order to display only the file permissions. Then pipe this output to sort and uniq to filter out any double lines. Then use the wc to count the different permission types in this directory.
  2. Put the output of date in a file. Append the output of ls to this file. Send this file to your local mailbox (don’t specify anything <@domain>, just the user name will do). When using Bash, you will see a new mail notice upon success.
  3. List the devices in /dev which are currently used by your username or UID. Pipe through less to view them properly.
    (Hints: man lsof and man id)
  4. Issue the following commands as a non-privileged user. Determine standard input, output and error for each command.
    • cat nonexistentfile
    • file /sbin/ifconfig
    • grep root /etc/passwd /etc/nofiles > grepresults
    • /etc/init.d/sshd start > /var/tmp/output
    • /etc/init.d/crond start > /var/tmp/output 2>&1
    • Now check your results by issuing the commands again, now redirecting standardoutput to the file /var/tmp/output and standard error to the file /var/tmp/error.
  5. How many processes are you currently running?
  6. How many invisible files are in your home directory?
  7. Use locate to find documentation about the kernel.
  8. Find out which file contains the following entry:
    • root:x:0:0:root:/root:/bin/bash
        

  9. And this one:
    •   
      system:		root
        

  10. See what happens upon issuing this command:
    •   
        > time; date >> time; cat < time
      

  11. What command would you use to check which script in /etc/init.d starts a given process?

Answer Key
Prev: Summary
Home
Next: Text editors


Copyright (c) by the authors.
This section of the wiki is licensed under the terms of the GNU Free Documentation License.
See the LBook-licensing page for details.


Linux® is a registered trademark of Linus Torvalds.


 
  course/book/sect_05_05.txt · Last modified: 2008/07/20 21:08

LinuxBasics.org

Start Linux-Course Tutorials Linux Links Security Blog Forum E-mail List Search Online Chat

Site-Info

Help Get in Touch Making of LBo

Wiki-Control

Powered by

Linux Apache DokuWiki Mailman RUTE ht://Dig