LNEXT
ONELCLEAN
UTERMINAL
TERMINAL
NEXT
$V1$
HILINE
PAUSE
MVSYNTAX
COMMAND SYNTAX: unlink filename
SYSTREE
/
|
--------------------------------------
| | | |
usr bin lib ac
| |
------------------------- md1
| | | |
| | | |
bin lib md1<---------------------|
SYS2TREE
/
|
--------------------------------------
| | | |
usr bin lib ac
| |
------------ md1
| |
| |
bin lib
GO
The command /etc/unlink is used to remove a filename that points
to another file. Its function is opposite to that of the /etc/link
command. The most common use of the unlink command is in the
device files! Links are removed by the /etc/unlink command!
The unlink syntax is shown above.
By using /etc/unlink, it is possible to remove the links
to the linked directories as well. Such an action will
simplify the file system, as long as you are sure that no
programs are referencing the files in the directories that
you intend to unlink!
To understand how to use unlink,
let us focus on the figure above.
We want to unlink the directory
/usr/md1; but before doing that
get a long listing of the /usr
directory.
$PROMPT$
That is correct!
You've got it on the 2nd try.
Good, you understand the concept.
Please use the ls command.
Please type ls -l /usr
You will be helped this time!
$PROMPT$
FORGET3
ls -l /usr
Please observe the result above!
$PROMPT$
total 36
drwxr-xr-x 16 root root 432 Jul 9 10:49 CTI
drwxr-xr-x 3 adm uucp 128 Jul 20 10:15 adm
drwxr-xr-x 2 bin bin 2336 Jul 1 10:19 bin
drwxr-xr-x 2 bin bin 48 Oct 15 1985 dict
drwxr-xrwx 2 ac devel 128 Jul 28 11:30 md1
drwxrwxrwx 4 bin bin 272 Apr 23 09:13 games
drwxr-xr-x 8 bin bin 144 Mar 1 09:15 spool
drwxr-xr-x 7 bin bin 112 Oct 15 1985 sys
Note that the number of links for
the md1 directory (file) is 2!
Now please enter the appropriate
command to unlink the /usr/md1
directory (file).
$PROMPT$
That is correct!
You've got it on the 2nd try.
Good, you understand the concept.
Please type unlink /usr/md1
Please type unlink /usr/md1
You will be helped this time!
$PROMPT$
FORGET2
unlink /usr/md1
$PROMPT$
If no diagnostic messages appear,
the unlink was successful!
Now please verify that indeed the
/usr/md1 was unlinked by
getting a long listing of the
/ac directory.
$PROMPT$
That is correct!
You've got it on the 2nd try.
Good, you understand the concept.
Please type ls -l /ac
Please type ls -l /ac
You will be helped this time!
$PROMPT$
FORGET1
ls -s /ac
Please observe a typical result
above, and note the highlighted
link counter for the file (directory)
md1!
drwxr-xrwx 1 ac devel 256 July 27 CTI
-rw-r--rw- 1 ac devel 4239 Jan 16 admin
-rw-r--rw- 1 ac devel 11433 April 4 advuser
drwxr-xrwx 1 ac devel 128 July 28 md1
-rw-r--rw- 1 ac devel 5734 Jan 16 unixuser
Note that the number of links on
the md1 directory has decreased
to 1, which implies that there
are no other links to md1!
unlink is a very powerful command and should be used with caution.
By executing an inappropriate unlink command, it is possible to
trash a file system. Therefore, it is recommended that the /bin/rm
and /bin/rmdir commands be used to remove files and directories
when possible!