http://www.ee.surrey.ac.uk/Teaching/Unix/index.html"
cd
mkdir temp
cd temp
pwd
Notice your full working directory--it will be different from mine.
nano foo
This opens the Nano text editor.
Type in the four lines of
shown below.
Notice the two lines of text at the bottom of the window. Nano uses these to tell you what's happening.
Press Ctrl and tap X.
The message at the bottom changes, as shown below.
Tap Y to save the file, and then press Enter to agree to the unchanged filename.
cp foo foo2
cp foo foo3
mkdir a
cp foo a
cd a
pwd
ls -l
You end up in a subdirectory
named a containing only
one file,
as shown below.
.. is the path that goes Up, one directory above your current working directory.
. is the name of your current working directory.
Execute these commands, as shown below.
pwd
ls
ls ..
mv ../foo2 .
ls
You end up in a subdirectory
named two files,
as shown below.
A file is missing from that directory.
Put it back with one command from your current working directory.
cd
cd temp
ls
You should see three items, as shown above.
Execute these commands, as shown below.
grep cat foo
grep e foo
The first grep shows lines containing "cat", and the second shows lines containing "e".
ls
ls -l
The first command shows the names of files and directories in the current working directory.
The second command shows a list in long form, showing the permissions at the start of each line.
"d" means the item is a directory, and "-" means it is a file.
The next nine characters show the permissions for the owner, group, and others.
ls
ls > bar
cat bar
echo 1
echo 1 > bar2
cat bar2
See how output that was going to the screen, stdout, is redirected to a file with >.
> empties a file before inserting new text.
>> is used to append to a file.
Execute these commands, as shown below.
cat bar
cat bar > bar3
cat bar >> bar3
cat bar3
You ended up with two copies of the contents of bar in bar3. Execute these commands, as shown below.
echo 1 > bar3
cat bar3
Now bar3 contains only one line again, because we used > instead of >>
ps -ax
A long list of running processes scrolls past.
To stop it from scrolling out of sight, use this command:
ps -ax | less
Now the list appears one page at a time. To go to the next page, press the SPACEBAR.
Execute this command:
ps -ax | grep apple
You see the processes containing "apple", as shown above.
Execute this command:
ps -ax | wc -l
You see a count of the running processes, as shown above.