|
|
![]() |
(You can see a larger picture by clicking here: click here )
The (white) window in the center of the desktop is a Terminal application
This is a UNIX "shell" program that allow you to interact with the computer through command lines typed from the keyboard
|
Graphically:
![]() |
(You can see a larger picture by clicking here: click here )
![]() |
|
Graphically:
![]() |
|
(There is a need to identify things stored inside a computer uniquely.
Just like using Social Security Numbers to identify people uniquely)
|
|
We will now explain the absolute directory path and discuss the relative path later.
|
Example 1:
![]() |
The directory path for the highlighted directory is:
|
Note:
|
Example 2:
![]() |
The directory path for the highlighted directory is:
|
Example 3:
![]() |
The directory path for the highlighted directory is:
|
|
|
Example:
|
|
|
Now it's time to learn to use some of these applications to become a skillful computer operator
|
|
(That's because Prof. Cheung has developed this course material)
![]() |
This is what you would see when you browse the /home/cheung/cs170 directory:
![]() |
|
Files in a computer systems are stored in some directory
|
ls DIRECTORY-PATH |
(ls is an abbreviation of the word list)
The ls command (application) will list the names of the files and the directories stored in the specified directory in alpha-numerical order
Note:
|
Example 1: " ls /" --- give the list of directory and files stored in the root directory /
Output of the ls command | Browsing the directory with a File Explorer |
---|---|
![]() |
![]() |
Example 2: " ls /etc" --- give the list of directory and files stored in the directory /etc
Output of the ls command | Browsing the directory with a File Explorer |
---|---|
![]() |
![]() |
|
He would execute this command: ls /home/cheung/cs170
Example:
Output of the ls command | Browsing the directory with a File Explorer |
---|---|
![]() |
![]() |
|
Example:
|
Actual execution:
![]() |
cd NEW-Current-DIRECTORY-PATH |
cd is an abbreviation of the words change directory
The New-Current-DIRECTORY-PATH can be an absolute directory path or a relative directory path
![]() |
![]() |
cd /home/cheung/cs170 |
The first word cd is the name of the command (is also the name of the computer application that will be run)
The second "word" /home/cheung/cs170 is the argument of the command
|
|
Command (application) | Default argument |
---|---|
ls | the current directory |
cd | the home directory |
![]() |
When ls is not given any argument, it will list the content of the current directory
![]() |
When cd is not given any argument, it will change the working directory of the home directory
Symbol | Directory represented by the symbol |
---|---|
/ | The root directory |
~ | The home directory of the user |
. | The current (working) directory |
.. | The parent directory of the current directory |
The parent directory is the directory that is immediately above the current directory in the directory tree.
The parent directory of the root directory / is itself (/)
then:
Command | The directory used as argument of the command |
---|---|
ls / | root directory |
ls ~ | /home/cheung (= home directory of the user) |
ls . | /home/cheung/cs170 (= current (working) directory) |
ls .. | /home/cheung (= the parent directory of the /home/cheung/cs170) |
ls ../.. | /home |
ls ../../.. | / |
ls ../../../.. | / (because the parent directory of the root directory / is itself |
|
Type a cd or ls command at the command input space below and hit the ENTER key:
|
Answers:
|
|
Answers:
|
mkdir PATH-of-a-NEW-DIRECTORY |
You can use an absolute or a relative directory path in the mkdir command.
Output of the ls command | Browsing the directory with a File Explorer |
---|---|
![]() |
![]() |
Before the mkdir command, the cs170 directory contains: myFile1 and myFiles2
After the mkdir command, the cs170 directory also contains: hw1
|
command -a -b -c arg1 arg2 arg3 arg4 |
The options of the command
are: "-a -b -c"
(3 options)
The arguments of the command
are: "arg1 arg2 arg3 arg4"
(4 arguments)
Option | Effect of the option |
---|---|
-t | List files ordered by the time of creation (latest first) |
-r | List files in the reverse order |
-l | Long listing - give detailed information on files and directories |
-F | Append "/" to a directory name and "*" to the name of an executable application |
Example:
Output of different ls commands | Browsing the directory with a File Explorer |
---|---|
![]() |
![]() |
You can see that the output format is changed by the various options specified to the ls command
rmdir DIRECTORY-PATH |
You can use an absolute or a relative directory path.
![]() |
(I made a mistake in the first attempt, I tried to remove the directory /home/cheung/hw1 which did not exists. I forgot the cs170 part)
Mistakes are less likely by using a relative path:
![]() |
|
mv Old-Name New-Name |
mv is the acronym for move
|
It is advisable to use a relative directory path to rename a directory (you will know why very soon)
![]() |
(I used the −F option to let you see which names are files and which are directories)
But instead, you created the directory inside /home/cheung/cs170 (inside a wrong folder (directory))
Graphically:
![]() |
Solution:
|
mv X D |
(This has the same effect by using a file browser and do this:
|
![]() |
But it takes a long time go to one place and drag the thing into another folder.
|