Chapter 5 Answers to Exercises in Section 5.5
-
$ ls -la | cut -f 1 -d " " | sort -u | wc -l
-
$ date > listing; ls >>listing; mail ajlewis2 < listing
- Note: this will not work unless the mail program and an MTA like exim4 are installed and configured.
-
$ lsof -u myusername |grep /dev |less
or
$ lsof -u myUID |grep /dev |less
-
-
$ cat nonexistentfile 1> /var/tmp/output 2> /var/tmp/error
$ less /var/tmp/output
/var/tmp/output (END)
$ less /var/tmp/error
cat: nonexistentfile: No such file or directory
- Note that “/var/tmp/output (END)” is simply the end of the empty file.
-
$ file /sbin/ifconfig 1> /var/tmp/output 2> /var/tmp/error
$ less /var/tmp/output
/sbin/ifconfig: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GN
U/Linux 2.6.0, dynamically linked (uses shared libs), for GNU/Linux 2.6.0, strip
ped
$ less /var/tmp/error
/var/tmp/error (END)
grep root /etc/passwd /etc/nofiles > grepresults
output: /etc/passwd:root:x:0:0:root:/root:/bin/bash
error: grep: /etc/nofiles: No such file or directory
/etc/init.d/sshd start 1> /var/tmp/output 2> /var/tmp/error
output: empty
error:bash: /etc/init.d/sshd: No such file or directory
-
$ /etc/init.d/crond start > /var/tmp/output 2>&1
$ less /var/tmp/output
bash: /etc/init.d/crond: No such file or directory
$ /etc/init.d/crond start 1> /var/tmp/output 2> /var/tmp/error
$ less /var/tmp/output
/var/tmp/output (END)
$ less /var/tmp/error
bash: /etc/init.d/crond: No such file or directory
-
$ ps aux|grep myusername |wc -l
42
-
ls -adF .* |grep -v / |wc -l
- List all, with directory entries, but not their contents and with the symbols. Do a reverse grep eliminating those with the directory symbol (/). Count the lines.
-
locate kernel | grep doc
-
grep -r "root:x:0:0:root:/root:/bin/bash" /*
- Do this in a separate xterm–it will take a long time. Try it using only
/etc/* for faster results. (We know where this is.
)
- Add “
2> /dev/null” on the end to avoid all the errors for lack of permission’'
- I don’t find this one.
-
> time; (creates empty file named "time". semicolon allows that more than one command per line.)
date >> time; (runs command "date" and appends output to the empty "time" file)
cat < time (looks at the "time" file which now has the date and time in it.
-
grep "script-name-in-quotes" /etc/init.d/*
Home
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