1. Linux Midterm Exam
Your quiz has been submitted successfully.
Question 1
I'm logged into Linux as user 'pc', and I want to move the file '~/Videos/one.mpg' to "/usr/bin". I
try:
mv ~/Videos/one.mpg /usr/bin
but I get an error. Why, and what command would work? (select the best answer)
It should work, using the -p switch.
/usr/bin is owned by root, so you need to run: sudo mv ~/Videos/one.mpg /usr/bin
It didn't work because your command is wrong, it should be:
mv /usr/bin /Videos/one.mpg
It didn't work because your command is wrong, it should be:
mv /Videos/one.mpg /usr/bin
Question 2
I have three files named file1, file2, and file3, and I want to put them into a single file called
'bigfile.txt'. How can I do this?
cat file1 file2 file3 > onebigfile
less < file1 file2 file3
cat file1 file2 file3 < bigfile
cat file1 file2 file3 > bigfile.txt
Question 3
The command line utility clear:
Clears the terminal screen
2. Sends packets to a remote system
Clears your history
Clears a user's password
Question 4
I want to uncompress and unarchive the file:
hello1.tar.bz2
What command would do this?
tar xzf hello1.tar.bz2
tar xjf hello.tar.bz2
gunzip hello1.tar.bz2
tar xjf hello1.tar.bz2
Question 5
I have a file named 'hello.tar.gz.' I want to uncompress and unarchive the file. Which command
would do this?
1) tar xfz hello.tar.gz
2) Tar xjf hello.tar.gz
3) tar xfj hello.tar.gz
4) tar fz hello.tar.gz
Question 6
I run 'history' and see the following:
....
492 ls -al
493 clear
494 sudo cat /etc/passwd
495 ls -al
496 clear
I want to rerun the command:
sudo cat /etc/passwd
Which command would do this?
3. 1) !sudo cat /etc/passwd
2) !!
3) 494$
4) !494
Question 7
I have a file named 'bigfile' in ~. I want to rename the file to 'oldfile', and I want to move it to
~/Downloads. The command that would do this is:
1) mv bigfile oldfile < ~/Documents
2) mv ~/bigfile ~/Documents/oldfile
3) mv ~/bigfile ~/Downloads/oldfile
4) rename bigfile oldfile | ~/Documents
Question 8
The 'who' command ...
1) Displays only power users
2) Doesn't exist
3) Displays who I am (my user ID)
4) Displays everyone who is logged in
Question 9
| (pipe) is used for what?
1) Is used to create little walls between things in Linux
2) Is used to concatenate files
3) Is used to chain commands together
4) Is always used with find or grep.
Question 10
Which of the following commands would find empty files (not directories) under /var/log only?
sudo find /var -type f -empty
sudo find /etc -type d -exec empty {} ;
sudo find /var/log -type f -empty
4. sudo find /etc -type f
Question 11
I want to find files under / that have the characters 'DSC' in their content, case insensitive. Which
command would do this?
sudo grep -iname 'DsC'
sudo find ~ -type f -name 'DSC*'
sudo find / -type f -iname '*dsc*'
sudo grep -r / 'DSC'
Question 12
I'm in ~. I want to create a tar file named "mylargedocs.tar" that contains all files in ~ ending in
.doc. What command would I run?
tar cf mydocs.tar *.doc
tar cf mylargedocs.tar *.doc
sudo tar cvfz mydocs.tar *.doc
tar xvf mydocs.tar *.doc
Question 13
I want to compress the file 'moNster.tar'. Which command would I use?
bzip2 moNster.tar
bunzip moNster.tar
tar -xzvf moNster.tar
bzip2 monster.tar
Question 14
I want to find all files under ~ that were modified less than 10 minutes ago. The command I run
would be:
find ~ -type f -cmin -10
True
False
Question 15
5. I want to search for files under ~ that contain the keyword "Flumox," and to redirect that output
to a new file called "Flumox.txt" under ~/Documents. The command would be:
find -name 'Flumox' > Flumox
grep -R "Flumox" ~ > ~/Flumox.txt
grep -R "Flumox" ~ > ~/Documents/Flumox.txt
grep -R "Flumox" ~ > /Flumox.txt
Question 16
I'm in the following directory:
~/Docs/2015/dsc/linux/spring/night
If issue this command:
cd ../../../..
In what directory would I be?
~/Docs/2015/
~/Docs/2015/dsc/linux/
~/Docs/2015/dsc/
~/Docs/2012/
Question 17
I'm in my home directory and want to create the following directory hierarchy with one
command:
~/calculus/homework/june/2012
Which command would do this?
mkdir -r calculus/homework/june/2012
mkdir -p /calculus/homework/june/2012
mdir -p calculus/homework/june/2012
mkdir -p calculus/homework/june/2012
Question 18
I'm in the directory:
/var/log/mail/map/june/2012/calculus/hard/problems/yikes/do/not/want/to/fail/this/class/again
I 'cd' back to my home directory using 'cd ~'.
6. Now I want to flip BACK to the preceding directory (/var/log/mail, etc.).
What's the fastest way to do that?
cd
/ var/log/mail/map/june/2012/calculus/hard/problems/yikes/do/not/want/to/fail/this/class/agai
n
cd ~
cd -
cd ../../../../../../../../../../../../../../../
Question 19
I want to install the program "ruprecht" under Mint. Easiest way to do that is:
Can't be done in Linux.
sudo atitude install ruprecht
sudo aptitude install ruprecht
aptitude install ruprecht
Question 20
I want a long listing of all files, including hidden files, in all directories residing under
~/POWER, and I want to save it to a file called 'myfiles'. What command would do this?
ls -alR ~/POWER > myfiles
sudo ls ~/POWER < myfiles
ls -alR ~ > myfiles
ls > files > ~/POWER
Question 21
I want to update my system with the most recent packages. I do that with:
su, su, sudio safe-upgrade
aptitude update && atitude safe-upgrade
atitutde update
atitude safe-upgarde
sudo aptitude update && sudo aptitude safe-upgrade
Question 22
7. I can't remember the command to delete a directory. A good way to find commands that have
either the word 'delete' in it, or in the description, would be to run:
delete --help
find / -name delete
apropos delete
man delete
Question 23
I want to know what devices are mounted on my system. The best way to find out is to run:
umount
dmesg | grep -exec sort {} ;
sufo fdisk -l
mount
Question 24
I want to find all regular files in my /var/log/mail directory with a '*.doc' extension that are
empty. What command would do this?
find /var/log/mail -name '*.txt'
sudo find /var/log/mail -type f -name '*.doc' -empty
find / -type f -name '*.txt' -empty
sudo find /var/log/mail -type f -name '*.txt' -empty
Question 25
I can't remember how to create a series of nested directories using one command, but I remember
that 'mkdir' is the command. The BEST way to find is the answer is to use (SELECT THE
BEST ANSWER). :)
'Facebook" Prof Craiger.
Email Prof Craiger at his DSC email address.
Use Twitter to ask Prof Craiger.
man mkdir