User Tools

Site Tools


opus:fall2012:mp015470:unixpart1

unix Keyword 1

Paths: Absolute and Relative

Definition

Paths specify the unique location of a file or directory by showing the root and the hierarchy of directories in which the file resides. For example, in the Lab46 file system, the path to get to the games directory is from the Lab46 root, to the user directory, followed by the games directory. This path would be written as “lab46:/usr/games”.

Paths may be absolute or relative. An absolute path is a path that points to the same file location in a file system regardless of the current, or working, directory (where the user currently is). A relative path is a path that points to the file location but is dependent on the working directory.

Examples:

/a/b/c/d is an absolute path, as it specifies the full location for the directory/file “d”.

Using the above example, if the user is currently in the /c directory, he/she could use /d as a relative path to get to d. However, if the user is currently in the /a or /b directories, typing /d will not direct him/her to d.

References

  • “Programming Logic and Design” - Joyce Farrell
  • Wikipedia - “Path (computing)”

unix Keyword 1 Phase 2

local host

Definition

Local host is the name given to your computer. Its ip address is 127.0.0.1 to the local network but for the outside network or internet it would have a different ip address. The ip address 127.0.0.1 is used for loopback. If you send out packets and get the same packets back using 127.0.0.1 it is loopback. People use it for setting up servers and finding a database.

References

Demonstration

/*
 * Sample code block
 */
#include <stdio.h>
 
int main()
{
    return(0);
}
lab46:~$ pwd
/home/USERNAME
lab46:~$ /sbin/ifconfig lo
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:85935 errors:0 dropped:0 overruns:0 frame:0
          TX packets:85935 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:17556111 (16.7 MiB)  TX bytes:17556111 (16.7 MiB)

lab46:~$ ping localhost
PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost.localdomain (127.0.0.1): icmp_req=1 ttl=64 time=0.041 ms
64 bytes from localhost.localdomain (127.0.0.1): icmp_req=2 ttl=64 time=0.031 ms
64 bytes from localhost.localdomain (127.0.0.1): icmp_req=3 ttl=64 time=0.034 ms
64 bytes from localhost.localdomain (127.0.0.1): icmp_req=4 ttl=64 time=0.039 ms
^C
--- localhost.localdomain ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2997ms
rtt min/avg/max/mdev = 0.031/0.036/0.041/0.005 ms
lab46:~$
opus/fall2012/mp015470/unixpart1.txt · Last modified: 2012/09/23 22:29 by mp015470