LN(1,C) AIX Commands Reference LN(1,C) ------------------------------------------------------------------------------- ln PURPOSE Links files. SYNTAX +-- file --- directory --+ ln ----------| ^ | |---| +- -s -+ | +-------+ | +--- file --- newname ---+ DESCRIPTION The ln command links file to newname (in the current directory), or to the same name (file) in another existing directory. There are two types of links supported by the ln command: hard links and symbolic links. If you are linking a file to a new name, you can list only one file. If you are linking to a directory, you can list more than one file. If file is a symbolic link, ln creates a second symbolic link called newname that points to the same file or directory as file. Notes: 1. You cannot create hard links between files across file systems. 2. When creating a symbolic link, file need not exist. 3. When creating a symbolic link, file may name a directory. The ln command does not link a file to a hidden directory. Hidden directory components must be named explicitly. For example, the following is a correct specification: ln hidden.file@/i386 new.file FLAG -s Creates a symbolic link rather than a hard link. Symbolic links with relative path names may not resolve correctly if the symbolic link is moved, or if a hard link is created to a soft link. Processed March 8, 1991 LN(1,C) 1 LN(1,C) AIX Commands Reference LN(1,C) EXAMPLES 1. To create another name (also called an alias) for a file: ln chap1 intro This command links "chap1" to the new name "intro". If "intro" does not already exist, the file name is created. If "intro" does exist, the file is replaced by a link to "chap1". Now "chap1" and "intro" are two file names that refer to the same file. Any changes made to one also appear in the other. If one name is deleted with the del or rm command, the file is not actually deleted, but remains under the other name. 2. To link a file to the same name in another directory: ln index manual This command links "index" to the new name "manual/index". Note that "intro" in the example above, (creating an alias) "Chap 1" is the name of a file, while in this example "manual" is a directory that already exists. 3. To link several files to names in another directory: ln chap2 tom/chap3 /u/manual This command links "chap2" to the new name "/u/manual/chap2" and "tom/chap3" to "/u/manual/chap3". 4. To use pattern-matching characters: ln manual/* . This command links all files in the directory "manual" into the current directory (.), giving them the same names they have in "manual". You must type a space between the asterisk and the period. 5. To create a symbolic link: ln -s /bin/who who This command creates a symbolic link in the current directory who that points to the file directory /bin/who. 6. To create a symbolic link into the filesystem: ln -s "/utmp" /etc/utmp This command creates a symbolic link /etc/utmp, which points at a different file utmp, on each site in a TCF cluster. The use of quotes is required because < and > have special meanings to the shells. Processed March 8, 1991 LN(1,C) 2 LN(1,C) AIX Commands Reference LN(1,C) RELATED INFORMATION See the following commands: "rm, delete," "mv, move," and "cp, copy." See the chmod and link system calls in AIX Operating System Technical Reference. Processed March 8, 1991 LN(1,C) 3