29 Questions
What command line puts the date in a file in your HOME directory?
date >../../../date.txt
If my current working directory is /home, and my HOME directory is /home/me, which command copies the password file into my HOME directory under the name foo?
cp me/../../etc/passwd me/foo
If foo is a sub-directory that contains only the file bar, what happens after this command: mv foo/./bar foo/././me?
the directory foo now contains only a file named me
In the output of the command ls -a, the one-character name . signifies what?
The current directory.
What is the result of this exact command line: ls /foo bar?
the names of the pathnames /foo and bar will be displayed
What can you do to get back (redo) the last command you typed?
Use the 'UpArrow' key.
Which command line does not show any lines from inside the file bat?
ls bat
If my current directory is /etc, which of these pathnames is equivalent to the file name /etc/passwd?
../passwd
What does quoting mean on a shell command line?
turning off the special meaning of shell meta-characters
How many arguments does the shell pass to this echo command: echo one two three >four five?
4
Which of the following pathnames almost always leads to the same file named: /bin/ls
././bin/./ls
In which section of the manual do you find super-user and admin commands?
Section 8
What is the correct interpretation of the command: wc -wc wc
Two command line arguments, one of which contains two bundled options.
What Linux command displays the contents of a file?
cat
What is true after the command line: touch new ; mv ./mt/../new ../me/old
The parent directory of mt now has a file named old in it
What is an operating system?
A computer program that manages the hardware.
Which pathname almost always leads to the same file named: /etc/shadow
././../etc/./shadow
What option to ls shows inode (index) numbers?
-i
If my current working directory is /var, which command copies the password file into directory /var/ian under the name bar?
cp ./ian/../../etc/passwd ian/bar
In which section of the manual do you find standard commands?
1
If my current directory is /etc, which of these pathnames is equivalent to the pathname /etc/x/y?
/etc/x/y
What is the correct syntax to redirect both standard output and standard error into the same output file?
date 2>&1 >out
What command can you use to delete an empty directory?
rmdir
What is the simplified pathname for /../../var/./a/../../var/b/../../etc/./bar/../foo?
./etc/foo
The option to ls that shows which names are directories is:
-l
How do I search for the string foo in the text display output from the man command?
/foo
Which pathname almost always leads to the same file named /etc/passwd?
./etc/../etc/./passwd
What Linux command copies an entire directory?
cp -r d1 d2
What happens after this command: mv ./foo/bar foo/../me?
the directory foo is now empty
Study Notes
###UNIX Commands and Pathnames
- The section of the manual to find standard commands is 1.
- The pathname
/etc/x/y
is equivalent to./etc/x/y
when the current directory is/etc
. - To redirect both standard output and standard error into the same output file, use the syntax
date 2>&1 >out
. - The command to delete an empty directory is
rmdir
. - The pathname
/../../var/./a/../../var/b/../../etc/./bar/../foo
simplifies to./etc/foo
. - The option to
ls
that shows which names are directories is-l
. - To search for the string "foo" in the text display output from the
man
command, use./foo
. - The pathname
/etc/./etc/../passwd
almost always leads to the same file named/etc/passwd
. - The Linux command that copies an entire directory is
cp -r d1 d2
. - The pathname
/usr/./bin/../lib/../../etc/../usr/./lib/../bin/..
simplifies to./usr/lib
. - If
foo
is a sub-directory that contains only the filebar
, the commandmv ./foo/bar foo/../me
will leave the directoryfoo
empty. - To copy the password file into the HOME directory under the name
foo
, usecp ../../etc/passwd ../../../home/me/foo
. - The pathname
./etc/../passwd
almost always leads to the same file named/etc/passwd
.
###More Pathnames and Commands
- If the current working directory is
/home
, the commandcp ../../etc/passwd ../../../home/me/foo
copies the password file into the HOME directory. - The command
ls /foo bar
displays the names of the pathnames/foo
andbar
. - To redo the last command typed, use the "UpArrow" key.
- The command
ls bat
does not show any lines from inside the filebat
. - If the current directory is
/etc
, the pathname../passwd
is equivalent to the file name/etc/passwd
.
###Quoting, Searching, and More Commands
- Quoting on a shell command line means turning off the special meaning of shell meta-characters.
- To search for the word "nongraphic" in the man page for
ls
, typeman ls
at the shell, then/nongraphic
. - The bash shell expands a leading tilde (
~
) in a pathname to be the HOME directory. - To make the bash shell complete commands or file names, type the first part of the command or file name and then press
[TAB]
. - The command
cd /home/dir ; mkdir one ; mkdir two ; pwd
outputs/home/dir
.
###More Commands, Pathnames, and File Manipulation
- The option to
ls
that shows hidden names is-a
. - The command
echo one two three >four five
passes 4 arguments to theecho
command. - The command
mv ./ian/./foo ./ian/../bar
will leave the directoryian
empty. - The operating system is a computer program that manages the hardware.
Test your knowledge of Unix commands and pathnames with these questions. Learn how to navigate and use standard commands in Unix.
Make Your Own Quizzes and Flashcards
Convert your notes into interactive study material.
Get started for free