L. J. Jaeckel ◄ Home
CMPSC 210 -- Linux Administration
February 8, 2011 22:30
Discovery Exercises as assigned: Chapter 4, page 178-179:
2. To change directory
FROM: /usr/local
TO: using: Type this command:
--------------------- ------------- ------------------------
a. /usr absolute path cd /usr
b. /usr relative path cd ..
c. /usr/local/share/info absolute path cd /usr/local/share/info
d. /usr/local/share/info relative path cd share/info
e. /etc absolute path cd /etc
f. /etc relative path cd ../../etc
3. Use wildcard metacharacters and options to the ls command to view:
Note: I am interpreting the words "under" or "underneath" a
directory to mean just in that directory, NOT recursively
in all sub-directories under that.
a. Files in /etc ending with .cfg
ls /etc/*.cfg
b. Hidden files in /home/user1
ls -d /home/user1/.*
c. Sub-directories in /var
This one is trickier -- I don't see any ls option to list only
directories (not regular or other files), and I assume (for
purposes of this question) that the whole point of this
question is to find a way to list just the directories.
Two solutions:
ls -al /var | grep ^d
find /var -maxdepth 1 -type d -exec ls -ald {} \;
The first of these solutions is not only simpler, but
produces cleaner output too.
d. Files in /bin beginning with "a"
ls /bin/a*
e. Files in /bin with exactly three-letter names.
ls /bin/???
f. Files in /bin with exactly three-letter names, the third
letter of which is "t" or "h"
ls /bin/??[th]