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!
- 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.
- 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.
- 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)
- 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.
- How many processes are you currently running?
- How many invisible files are in your home directory?
- Use locate to find documentation about the kernel.
- Find out which file contains the following entry:
-
root:x:0:0:root:/root:/bin/bash
- And this one:
- See what happens upon issuing this command:
-
> time; date >> time; cat < time
- 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.
Welcome to LinuxBasics.org - The online community that helps people to get Linux installed and running.
During this tour, we will guide you through our website, which has many facets which wait to be explored
The biggest project we are running is our Linux course, based on the LBook.
The book is stored in wiki-format, which enables us to update and correct it as we go.
Discussion for the course is on our Forum
Our Forum is used for discussion of Linux and for questions and answers.
Search the mailing-list that was used prior to the Forum.
The questions and answers from the list are stored in the list's archives in order to help others with the same problems.
Every weekend, we meet to chat in IRC. These meetings are NOT mandatory, but are a nice chance to get to know each other better.
IRC is also a great tool to solve many problems, since it is very quick and easy to ask for more details if you need them.
The tutorials are one of the oldest sections on the LBo-website.
Here you find explanations on how to do specific tasks in Linux. Many of the tutorials were created after a certain problem
has been discussed (and usually solved :) on the mailing-list.
The tutorials are categorized in
In the links section, you find outbound links to other valuable resources.
One of our later additions to the site. We maintain a mirror of the Linux Documentation Project. This is our contribution to the "home of the HOWTOs"
Another later addition is the LBlog which focuses on how to do stuff on the Linux Desktop. It begins with the basics on installing Ubuntu.
Using the integrated site-search, you can search the tutorials, the LBook and all other wiki-pages
Simply type the search term into the box in the upper-right corner of our webpages
As a community, we depend on your feedback and collaboration. So, if you have something to share with others, please contact us. If you have a suggestion for a topic you would like to see covered here, please add it on the Wishlist.
There are many ways to contribute: You can answer questions on the Forum, you can write a complete tutorial or just a step-by-step documentation on how you completed a specific task using linux. Ask questions if the information on this site is not clear, tell us if we got something wrong, spell-check our writings, whatever.
We are looking forward to meeting you at LinuxBasics.org
Anita, Jisao, Sam and Stefan