Share to: share facebook share twitter share wa share telegram print page

Ln (Unix)

ln
Original author(s)AT&T Bell Laboratories
Developer(s)Various open-source and commercial developers
Initial releaseNovember 3, 1971; 52 years ago (1971-11-03)
Operating systemUnix, Unix-like, IBM i
PlatformCross-platform
TypeCommand
Licensecoreutils: GPLv3+

The ln command is a standard Unix command utility used to create a hard link or a symbolic link (symlink) to an existing file or directory.[1] The use of a hard link allows multiple filenames to be associated with the same file since a hard link points to the inode of a given file, the data of which is stored on disk. On the other hand, symbolic links are special files that refer to other files by name.[2]

The ln command by default creates hard links, and when called with the command line parameter ln -s creates symbolic links.[3] Most operating systems prevent hard links to directories from being created since such a capability could disrupt the structure of a file system and interfere with the operation of other utilities.[4] The ln command can however be used to create symbolic links to non-existent files.[2]

Versions

ln appeared in Issue 2 of the X/Open Portability Guidelines.[5] The version of ln bundled in GNU coreutils was written by Mike Parker and David MacKenzie.[6] The command is available as a separate package for Microsoft Windows as part of the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities.[7] The ln command has also been ported to the IBM i operating system.[8]

Links allow more than one filename to refer to the same file as in the case of a hard link or act as pointers to a filename as in the case of a soft link. Both hard links and soft links can be created by the ln command. Specifically,

  1. Hard links, also known simply as links, are objects that associate the filename with the inode, and therefore the file contents itself.[1] A given file on disk could have multiple links scattered through the directory hierarchy, with all of the links being equivalent since they all associate with the same inode.[9] Creating a link therefore does not copy the contents of the file but merely causes another name to be associated with the same contents. Each time a hard link is created, a link counter that is a part of the inode structure gets incremented; a file is not deleted until its reference count reaches zero.[1][10] However, hard links can only be created on the same file system; this can prove to be a disadvantage.[11]
  2. Symbolic links are special files which, when encountered during pathname resolution, modify the pathname resolution to be taken to the location which the symbolic link contains. The content of the symbolic link is therefore the destination path string, which can also be examined using the readlink command line utility.[12] The symbolic link may contain an arbitrary string which does not refer to the location of an existing file. Such a symbolic link will fail until a file is created at the location which is contained by the symbolic link. By contrast, a symbolic link to an existing file will fail if the existing file is moved to a different location (or renamed).[9]

Specification

The ln utility on systems compliant with the Single Unix Specification is specified in the Shell and Utilities (XCU) document, which forms a part of the Single Unix Specification.[13] A mostly identical document is part of POSIX.[5]

The specification describes two ways of invoking the ln utility. Specifically,

In the "single file" invocation the ln utility creates a new hard link (directory entry) for the source file specified by the source_file operand at the destination path specified by the target_file operand. However, if the -s option is specified, a symbolic link is created.
ln [-fs] [-L|-P] source_file target_file
In the "multiple file" invocation the ln utility creates a new hard link (directory entry), or if the -s option is specified, a symbolic link, for each file specified by the source_file operand, at a destination path in an existing directory named by operand target_dir.
ln [-fs] [-L|-P] source_file_1 source_file_2 ... target_dir

The specification also specifies the command line options that must be supported:

-f Force existing destination pathnames to be removed to allow the link.
-L For each source_file operand that names a file that is a symbolic link, create a hard link to the file referenced by the symbolic link.
-P For each source_file operand that names a file that is a symbolic link, create a (hard) link to the symbolic link itself.
-s Create symbolic links instead of hard links. If the -s option is specified, the -L and -P options are silently ignored.
If more than one of the mutually-exclusive options -L and -P is specified the last option specified determines the behavior of the utility.
If the -s option is not specified and neither a -L nor a -P option is specified, the implementation defines which of the -L and -P options will be used as the default.

If neither target file nor target directory are specified, links will be created in the current working directory.

See also

References

  1. ^ a b c Kernighan, Brian W.; Pike, Rob (1984). The Unix programming environment. Englewood Cliffs, N.J.: Prentice-Hall. p. 59. ISBN 013937681X.
  2. ^ a b "GNU Coreutils: ln invocation". gnu.org. Free Software Foundation, Inc. Retrieved 7 August 2015.
  3. ^ "ln - The Open Group Base Specifications Issue 7". pubs.opengroup.org. The IEEE and The Open Group. Retrieved 7 August 2015.
  4. ^ "Why are hard links not allowed to directories in UNIX/Linux?". unix.stackexchange.com. Retrieved 7 August 2015.
  5. ^ a b ln – Shell and Utilities Reference, The Single UNIX Specification, Version 4 from The Open Group
  6. ^ ln(1) – Linux General Commands Manual
  7. ^ "Native Win32 ports of some GNU utilities". unxutils.sourceforge.net.
  8. ^ IBM. "IBM System i Version 7.2 Programming Qshell" (PDF). IBM. Retrieved 2020-09-05.
  9. ^ a b Loosemore, Sandra; Stallman, Richard M.; McGrath, Roland; Oram, Andrew; Drepper, Ulrich. The GNU C Library Reference Manual (PDF). Free Software Foundation, Inc. p. 392. Retrieved 7 August 2015.
  10. ^ "Speaking UNIX: It is all about the inode". ibm.com. IBM developerWorks. Retrieved 7 August 2015.
  11. ^ Bovet, Daniel P.; Cesati, Marco (2005). Understanding the Linux Kernel (3rd ed.). Boston, MA: Safari Tech Books Online. p. 14. ISBN 0596005652.
  12. ^ "readlink(1) - Linux man page". linux.die.net. Retrieved 7 August 2015.
  13. ^ "The Single UNIX Specification, Version 4 - Overview". unix.org. unix.org. Retrieved 7 August 2015.

Read other articles:

نتفليكسNetflix, Inc. (بالإنجليزية) الشعارمعلومات عامةالجنسية الولايات المتحدة التأسيس 29 أغسطس 1997 النوع  القائمة ... شركة توزيع أفلام — web broadcaster (en) — شركة إنتاج تلفزيوني — شركة عمومية محدودة — تطبيق محمول — خدمة بث الفيديو الشكل القانوني شركة ديلاوير — شركة عمومية محدودة المق

SyamsiInformasi pribadiLahir0 Agustus 1965 (umur 58)IndonesiaAlma materAkademi Kepolisian (1990)Karier militerPihak IndonesiaDinas/cabang Kepolisian Negara Republik IndonesiaMasa dinas1990—2023Pangkat Komisaris Besar PolisiNRP65080830SatuanPendidikan PolriSunting kotak info • L • B Kombes. Pol. (Purn.) Syamsi, S.H. (lahir Agustus 1965) adalah seorang Purnawirawan Polri yang jabatan terakhirnya adalah Analis Kebijakan Madya Bidang STIK Lemdiklat Polri. Syamsi, lu...

هذه المقالة يتيمة إذ تصل إليها مقالات أخرى قليلة جدًا. فضلًا، ساعد بإضافة وصلة إليها في مقالات متعلقة بها. (يونيو 2018) كورت سينيت معلومات شخصية الميلاد 9 مايو 1974 (49 سنة)  الطول 185 سنتيمتر[1]  الجنسية ترينيداد وتوباغو  الوزن 71 كيلوغرام[1]  الحياة العملية المهنة مل

Blandford Forum Koordinaten 50° 51′ N, 2° 10′ W50.853326-2.171865Koordinaten: 50° 51′ N, 2° 10′ W Blandford Forum (England) Blandford Forum Traditionelle Grafschaft Dorset Einwohner 10.325 (Stand: 2011) Verwaltung Landesteil England Region South West Zeremonielle Grafschaft Dorset Unitary authority Dorset Civil Parish Blandford Forum Blandford Forum ist ein Ort und ein Civil parish in der Grafschaft Dorset in England. Blandford Forum liegt 2...

село Сокілець Покровська церкваПокровська церква Країна  Україна Область Хмельницька область Район Кам'янець-Подільський район Громада Дунаєвецька міська громада Основні дані Населення 559 (станом на 01.01.2010)) Площа 3,461 км² Густота населення 195,32 осіб/км² Поштовий ...

هذه المقالة يتيمة إذ تصل إليها مقالات أخرى قليلة جدًا. فضلًا، ساعد بإضافة وصلة إليها في مقالات متعلقة بها. (مارس 2019) ويليام جيل بيلي معلومات شخصية الميلاد سنة 1833  الوفاة 23 أبريل 1889 (55–56 سنة)  مواطنة المملكة المتحدة  الحياة العملية المهنة سياسي  اللغات الإنجليزية&...

Cattedrale di Nostra SignoraCathédrale de Notre-DameFacciataStato Francia RegioneGrand Est LocalitàStrasburgo Coordinate48°34′54″N 7°45′03″E / 48.581667°N 7.750833°E48.581667; 7.750833Coordinate: 48°34′54″N 7°45′03″E / 48.581667°N 7.750833°E48.581667; 7.750833 Religionecattolica di rito romano TitolareMaria ArchitettoUlrich Ensinger, Johannes Hültz, Erwin von Steinbach, Gustav-François Klotz e Jacob von Landshut Stile architetto...

ブラッキーを演奏するエリック・クラプトン ブラッキー(エリック・クラプトン・トリビュート・モデル) ブラッキー(エリック・クラプトン・トリビュート・モデル) ブラッキー (Blackie) は、エリック・クラプトンが愛用したフェンダー・ストラトキャスターに名付けられた愛称。および、この個体をもとにフェンダー社のカスタムショップが製造販売したストラト...

مزرعة كاظم زار مزرعه كاظم زارع  - قرية -  تقسيم إداري البلد  إيران المحافظة فارس المقاطعة مقاطعة أرسنجان الناحية الناحية المركزية القسم الريفي قسم علي أباد ملك الريفي (مقاطعة أرسنجان) السكان معلومات أخرى التوقيت توقيت إيران (+3:30 غرينيتش) توقيت صيفي توقيت إيران (+...

Artikel ini sebatang kara, artinya tidak ada artikel lain yang memiliki pranala balik ke halaman ini.Bantulah menambah pranala ke artikel ini dari artikel yang berhubungan atau coba peralatan pencari pranala.Tag ini diberikan pada Oktober 2022. Parasit Yahudi adalah sebuah stereotipe antisemitik yang telah ada sejak Zaman Pencerahan. Ini berdasarkan pada gagasan bahwa Yahudi diaspora tak mampu membentuk negara mereka sendiri dan sehingga akan secara paratistik menyerang dan mengeksploitasi ne...

Historic church in the Bronx, New York United States historic placeRiverdale Presbyterian Church ComplexU.S. National Register of Historic PlacesNew York City Landmark (June 2013)Show map of New York CityShow map of New YorkShow map of the United StatesLocation4761-4765 Henry Hudson Parkway, The Bronx, New York CityCoordinates40°53′45″N 73°54′32″W / 40.89583°N 73.90889°W / 40.89583; -73.90889Built1863-64[2]ArchitectJames Renwick, Jr.Dwight James Bau...

Archbishop of Rouen from 989 to 1037 Robert IIArchbishop of RouenTenure989–1037PredecessorHugh IIISuccessorMaugerCount of ÉvreuxReignc. 989–1037PredecessorNew creationSuccessorRichardBornbef. 989Died1037SpouseHerleveaIssueRichard, Count of Évreux Ralph de Gacé William d'ÉvreuxHouseHouse of NormandyFatherRichard I, Duke of NormandyMotherGunnorReligionpre-schismatic Chalcedonian christendom Robert II, Archbishop of Rouen (bef. 989–1037),[a] and Count of Évreux was a powerful ...

1938 HelsinkiMalmi airport in 2006, with the round terminal of 1938OverviewBIE-classSpecialized expositionNameSecond International Aeronautical ExhibitionBuilding(s)Malmi AirterminalArea15.2 hectares (38 acres)Visitors15,000,000Participant(s)Countries25LocationCountryFinlandCityHelsinkiVenueHelsinki-Malmi AirportCoordinates60°15′14″N 25°02′39″E / 60.25389°N 25.04417°E / 60.25389; 25.04417TimelineOpening14 May 1938 (1938-05-14)Closure22 M...

Miss Esmeralda is a Victorian burlesque, in two acts, with music by Meyer Lutz and Robert Martin and a libretto by Fred Leslie, under his pseudonym A. C. Torr, and Horace Mills. It is based on Victor Hugo's novel Notre Dame de Paris. The piece premiered in 1887 at the Gaiety Theatre in London, starring Marion Hood in the title role, with Frank Thornton as Quasimodo and featuring E. J. Lonnen and Letty Lind. Background and production John Hollingshead had managed the Gaiety Theatre from 1868 t...

This article is about the song. For the album by Johnny Hodges, see Don't Sleep in the Subway (album). This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Don't Sleep in the Subway – news · newspapers · books · scholar · JSTOR (September 2016) (Learn how and when to remove this template message) 1967 single by P...

Temples in Tamil Nadu, India This article includes a list of general references, but it lacks sufficient corresponding inline citations. Please help to improve this article by introducing more precise citations. (August 2022) (Learn how and when to remove this template message) Thanjavur Palace Devastanam is the name of a group of temples attached to the Palace Devastanams, Thanjavur, Tamil Nadu, India. [1] [2] [3] Temples There are 88 temples and are found in, around ...

William IVWilliam IV, dilukis oleh Sir Martin Archer Shee, 1833Raja Britania Raya dan IrlandiaBerkuasa26 Juni 1830 – 20 Juni 1837Penobatan8 September 1831PendahuluGeorge IVPenerusVictoriaPerdana Menteri Lihat daftar Adipati Wellington Earl Grey Viscount Melbourne Robert Peel Raja HannoverBerkuasa26 Juni 1830 – 20 Juni 1837PendahuluGeorge IVPenerusErnest Augustus IInformasi pribadiKelahiran(1765-08-21)21 Agustus 1765Istana Buckingham, LondonKematian20 Juni 1837(1837-06-20) (umur&...

2006 album by Helena Paparizou Iparhi LogosΥπάρχει ΛόγοςStudio album by Helena PaparizouReleased12 April 2006Recorded2006–2007GenreLaïko, dance-pop, pop folkLength107:24 (Original) 133:33 (Platinum Edition)LanguageGreek, English (Original) French (Platinum Edition)LabelSony BMG Greece/RCAHelena Paparizou chronology Protereotita(2004) Iparhi LogosΥπάρχει Λόγος(2006) The Game of Love(2006) Singles from Iparhi Logos Mambo!Released: November 2005 Just walk awayRelea...

Apparitions of the Blessed Virgin in Argentina (1983) Our Lady of the Rosary of San Nicolás Nuestra Señora del Rosario de San NicolásLocationSan Nicolás de los Arroyos Buenos Aires province,  ArgentinaDate1884, rediscovered 1983TypePlaster statue, crownedApprovalMay 22, 2016[1]Bishop Héctor CardelliDiocese of San Nicolás de los ArroyosShrineSanctuary of Our Lady of Rosary of San Nicolás, Buenos Aires province,  Argentina Our Lady of the Rosary of San Nicolá...

Political party in the Czech Republic Workers' Party Dělnická stranaLeaderTomáš VandasFounded18 January 2003 (as Workers' Party), 21 January 2004 (as a new political party, but with the same agenda and name)Banned17 February 2010[1]Split fromRepublicans ofMiroslav SládekSucceeded byWorkers' Party ofSocial JusticeIdeologyNeo-NazismCzech nationalismRight-wing populismAnti-RomanyismAnti-immigrationAnti-globalismAnti-communismAnti-ZionismPolitical positionFar-right...

Kembali kehalaman sebelumnya