Lab 01 - The command line
Pedagogical objectives
-
Get familiar with the command line
-
Understand basic Unix/Linux commands
Task 1: What do these commands do?
Execute the following commands in the given order. In a sentence or two, precisely describe what each does (English or French).
To get documentation look up the commands using the man
command. When using man
, be careful that you are seeing the correct
section (1), as the same term may be a command, a system call or
something else. Some of the commands are shell built-ins (cd
, pwd
,
...) which don't have manual entries, for these you can use the
shell's help
command. If the built-in help of the operating system
is too confusing, try Google.
If you get stuck, ask the assistant or professor for help!
-
nano newfile
-
ls
ls -l
-
cat newfile
-
cat /etc/hosts /etc/motd
-
pwd
cd ..
pwd
-
pwd
cd .
pwd
-
cd /home
ls -l
ls albert.einstein
(replacealbert.einstein
with your user id)
ls -a albert.einstein
ls -d albert.einstein
-
cd /tmp
mkdir -p albert.einstein/bar/baz
cd albert.einstein
rmdir bar
rmdir bar/baz
Hint:rmdir
's behavior is not immediately obvious. Be careful. -
less /usr/share/doc/bash/copyright
less /usr/share/doc/bash/INTRO.gz
-
echo "Hello, world!"
echo ~
-
find ~ -name '.*' 2>/dev/null
Hint: Break down each part of the command first. -
cd
mkdir bar
touch qux
cp qux bar
Hint: Pay attention tobar
.
mv qux bar/newfile
-
uname -a
What kind of information does this command print out? -
history
-
bash
exit
-
sudo apt-get install tcsh
tcsh
exit
sudo apt-get install zsh
zsh
exit
What do each of these commands do? -
apropos download
-
What happens when you type a command that does not exist, like
aaaaaa
? -
What happens when you type a command that is not installed, like
pdftotext
?
Extra task for pros: Editing in the command line
The shell supports some useful keyboard shortcuts. It is worth learning them as they speed up typing tremendously. Here are the most important, try to memorize them.
-
Ctrl-R - Interactively search and retrieve previous commands (see lecture slides)
-
Ctrl-A - Jump to the start of the line
-
Ctrl-E - Jump to the end of the line
-
Ctrl-L - Clear the display
-
Ctrl-K - Delete all text from the cursor to the end of the line
Lab deliverables
Write your lab report in plain text/Markdown or PDF.