Linux Exercise
Linux Exercise
The following steps will guide you through the most common Linux com-
mands. If you are using windows (Library and any Windows lab on cam-
pus), then start with step 1. If you are using a linux machine (Olin 170,
Dana 213, Brki 164), then start with step 3. (For access to Linux on your
own computer, please note the links on our webpage for windows and Mac
OS X.)
pwd
answer:
We call this directory (into which you get when you log in) your “home
directory”.
7. Check the contents of your current directory (list) with
ls
answer:
8. Change the current directory. Get into Capstone s2011
cd Capstone s2011
and redo 6.
9. Create a file with filename “linux logfile” by typing
nedit linux logfile &
or for larger font
nedit -font 10x20 linux logfile &
A new window will open up. NEdit is an editor, that means that you can
edit files with it (so like Word on windows). For a quick introduction to
NEdit click on the “Help,” located on the right of the menue bar on the
top. For more information see also the link on our webpage. In case you
are used to vi or any other editor, feel free to use it instead.
Write into the linux logfile:
Linux commands:
===============
mkdir create directory
pwd print current directory
ls list contents of current directory
Save the contents of the file with File → Save (or shorter Ctrl+S) and
quit the editor with File → Exit. You might want to use this file in
the future as a reference for linux commands. Add to it new commands
whenever you learn them.
10. In this course we will often want to share each others programs (files).
Since usually all your files are protected from being read by anyone else
but you, you will need to change this permission whenever you would like
other people (your classmates and me) to be able to read your file (see also
22. of this Intro). You do this in this example with:
hello
good bye
and redo 7.
13. Look at the contents of the tryfile with
cat tryfile
rm -i tryfile
You will be asked if you like to remove tryfile. Type y for yes. Check again
the contents of your current directory. rm is a dangerous command. It has
together with the wild card ’*’ the power of removing all your files in a
single command! Think always twice before you remove a file!
16. Create a directory with name “trydir”
mkdir trydir
and get into it with
cd trydir
17. Get back out of trydir (one step higher in the tree of directories) with
cd ..
Check in which directory you are.
18. Remove trydir with
rmdir trydir
cd
or with
cd ~
or with
cd ~yourusername
(e.g. for me cd ~kvollmay). This gets you to anyone’s home directory.
20. Look at the contents of your linux logfile with