pwd
commandcd
commandls
command
In Windows the file manager, Explorer, graphically displays the file system as a tree which can be navigated with the mouse. The path to the "hds" directory is shown in each image. Note that Unix does not use letters to designate the drive but just references its locations from the root directory, "/". So for the Unix command-line the "hds" directory would be referenced by the path /mnt/data/gempak/hds, this is the "path". As show above, under windows it would referenced as K:\gempak\hds. Note that DOS/Windows uses the back-slash character, "\", to separate directory entries where Unix uses the forward slash character, "/".
Another significant difference is the use of drive letters. With windows each additional storage device is assigned a "drive letter". The system disk is usually C:, floppy disks are typically A: and B:. CDROM drives, network drives and other media will be assigned other letters. In Unix additional storage devices are attached to a directory under the root file system as determined by the system administrator. This will be discussed in more detail in the next lab.
pwd
command simply prints the name of the current (or working)
directory to standard output (the terminal).
|
||||
mark@platypus:~> pwd /home/mark mark@platypus:~> |
cd
commandcd
command is used to change the working directory. It takes
only one argument, the path to which the user wishes to change the
working directory to.
|
||||
mark@platypus:~> pwd /home/mark mark@platypus:~> cd /mnt/data/ mark@platypus:/mnt/data> pwd /mnt/data mark@platypus:/mnt/data/wxdata> pwd /mnt/data/wxdata mark@platypus:/mnt/data/wxdata> |
The cd
command issued without arguments will return the user to their
home directory.
|
||||
mark@platypus:/mnt/data/wxdata> cd mark@platypus:~> pwd /home/mark mark@platypus:~> |
cd
command, along with most other unix commands can use absolute
or relative paths in their arguments. An absolute path is the
complete path to a file or directory relative to the root directory.
An absolute path will always start with the root directory, "/".
The path /mnt/homes/tuckerm is the absolute path to the directory tuckerm.
An example of changing directory with an absolute path:
|
||||
mark@platypus:~> pwd /home/mark mark@platypus:~> cd /mnt/homes mark@platypus:/mnt/homes> pwd /mnt/homes mark@platypus:/mnt/homes> |
An example of changing directory with a relative path:
|
||||
mark@platypus:~> pwd /home/mark mark@platypus:~> cd temp mark@platypus:~/temp> pwd /home/mark/temp mark@platypus:~/temp> |
ls
command is used to list files and directories. Without any
options or arguments it will list the contents of the working
directory:
|
||||
mark@platypus:~/temp> pwd /home/mark/temp mark@platypus:~/temp> ls TclTutor WRF_NCL usr mark@platypus:~/temp> |
ls
can also take one or more arguments which will be the absolute or
relative paths to the files or directories to list.
Listing files using an absolute path:
|
||||
mark@platypus:~> pwd /home/mark mark@platypus:~> ls /home/mark/temp TclTutor WRF_NCL usr mark@platypus:~> |
Listing the same files using a relative path:
|
||||
mark@platypus:~> pwd /home/mark mark@platypus:~> ls temp TclTutor WRF_NCL usr mark@platypus:~> |
Some commonly used options for ls
:
-a lists all files (including hidden files or directories) -d List names of directories like other files, rather than listing their contents. -l Write (in single-column format) the file mode, the number of links to the file, the owner name, the group name, the size of the file (in bytes), the timestamp, and the filename. -F Suffix each directory name with `/', each link name with `@', and each name of an executable with `*'. -t Sort by the timestamp shown. -S Sort by filesize. -r Reverse the order of the sort.The -l option provides quite a bit of additional information about the listed files or directories.
An ls
example with the -l option:
|
||||
mark@platypus:~> ls -l temp total 154 drwxr-xr-x 2 mark users 1640 2000-05-09 00:50 TclTutor drwxr-xr-x 2 mark users 952 2004-05-18 17:04 WRF_NCL -rw-r--r-- 1 mark users 153541 2005-01-25 12:53 binlist.data drwxr-xr-x 5 mark users 120 2001-09-05 01:07 usr mark@platypus:~> |
The first character in the listing indicates what type of file the file is. "d" designates directories, "-" designates regular files, "l" will designate symbolic links (more on that later). The string of characters that follow (r,w,x,-) are used to show the access permissions for the file. Those will be explained in detail in future lab. The next column shows the number of links to the file or directory. Following that is the username of the owner of the file. Next is the name of the group for that file. The fifth column shows the size of the file, usually in bytes. The sixth column shows the date that the file was last modified followed by the time. The final column is the name of the file or directory.