|
CS469 - Linux and Unix Administration and Networking
| Displaying exercises/e2/solution/e2.txt
Exercise #2
1) How would you use the "stat" command to just print the file type for the
file "file1"?
stat -c %F file1
2) How would you use the "tail" command to watch the end of the log file
/var/log/httpd/access_log as lines are appended to it in real time?
tail -f /var/log/httpd/access_log
3) How would you use the "du" command to produce only the total usage for
the amount of disk space your home directory is using in human readable
format.
du -s -h ~
4) Wild-card (not regular expressions) patterns that would match the
following:
a) All files starting with 'foo':
foo*
b) All files ending with the extension '.tgz':
*.tgz
c) All files starting with either an R or r and ending in '.txt':
[Rr]*.txt
d) The files starting with 'a' in the user 'foo''s directory:
~foo/a*
e) Any file that does not start with a digit:
[^0-9]*
f) All files that are at least 3 characters in length:
???*
5) Answer the following, consider using 'cat -n' to check your answer:
a) "head" command to output the first 20 lines of the file /etc/passwd'
head -n 20 /etc/passwd
b) "tail" command to output output the entire file '/etc/passwd' except for
the first 20 lines:
tail -n +21 /etc/passwd
6) Answer the following questions about this file:
-rwxr-xr-- 1 root admin 106 Sep 12 22:36 foo.txt
a) File type: regular
b) The owner of this file: root
c) The size of the file in bytes: 106
d) Group permissions: r-x or Read and Execute
|