Linghu Defen (令狐德棻) (582–666), formally Duke Xian of Pengyang (彭陽憲公), was an official of the Chinese dynasties Sui Dynasty and Tang Dynasty. During Tang, he was a major proponent for the compilation of the histories of Sui and its predecessor Northern Zhou and was eventually put in charge of compiling Northern Zhou's official history Book of Zhou, which was completed in 636.
Linghu Defen was born in 582, during the reign of Emperor Wen of Sui. His ancestors had been from a prominent clan of Dunhuang, but had later relocated to Yi Province (宜州, roughly modern Tongchuan, Shaanxi). His father Linghu Xi (令狐熙) served as an official during Emperor Wen's reign but died in anger after being imprisoned due to false accusations of corruption. Late in the reign of Emperor Wen's son Emperor Yang, Linghu Defen was made the magistrate of Yaocheng County (藥城, in modern Bozhou, Anhui), but as by that time the Sui realm was had been thrown into a state of confusion due to agrarian rebellions, Linghu never took office. In 617, after the general Li Yuan the Duke of Tang rose in rebellion against Emperor Yang's rule, Li Yuan's cousin Li Shentong (李神通) rose as well and made Linghu a member of his staff. In late 617, after Li Yuan captured the capital Chang'an and declared Emperor Yang's grandson Yang You the Prince of Dai emperor (as Emperor Gong), retaining power as regent, he invited Linghu to serve as a secretary on his staff.
 During Emperor Gaozu's reign
In 618, after Li Yuan received news that Emperor Yang had been killed in a coup at Jiangdu (江都, in modern Yangzhou, Jiangsu), he had Emperor Gong yield the throne to him, establishing Tang Dynasty as its Emperor Gaozu. He made Linghu Defen an imperial attendant. In 622, Emperor Gaozu made Linghu Mishu Cheng (秘書丞), the secretary general of the archival bureau of government (秘書省, Mishu Sheng), and had him participate on the compilation of the Yiwen Leiju, with the chancellor Chen Shuda.
At that time, after the great disturbance at the end of Sui, much of old book collections had been lost. Linghu advocated, and Emperor Gaozu agreed, to seek out books and purchase them and, once they were bought, to have them copied as well. After several years, the imperial collections were more comprehensive. Linghu also pointed out that while the Southern Dynasties' histories were largely written, little have been formally compiled of Northern Zhou and Sui Dynasty's histories—and that the deeds of the great people of those two dynasties, including those of Emperor Gaozu's ancestors, would be lost. Emperor Gaozu therefore issued an edict commissioning Xiao Yu, Wang Jingye (王敬業), and Yin Wenli (殷聞禮) to compile the history of Northern Wei; Chen, Linghu, and Yu Jian (庾儉) to compile the history of Northern Zhou; Feng Deyi and Yan Shigu to compile the history of Sui; Cui Shanwei (崔善為), Kong Shao'an (孔紹安), and Xiao Deyan (蕭德言) to compile the history of Liang Dynasty; Pei Ju, Zu Xiaosun (祖孝孫), and Wei Zheng to compile the history of Southern Qi; and Dou Jin (竇璡), Ouyang Xun, and Yao Silian to compile the history of Chen Dynasty. However, after the issuance of Emperor Gaozu's edict, not much actual historical compilation was carried out, and the projects stalled.
 During Emperor Taizong's reign
In 629, during the reign of Emperor Gaozu's son Emperor Taizong, Emperor Taizong was interested in the compilation of the histories, and he therefore issued an edict commissioning Linghu Defen and Cen Wenben to compile the history of Northern Zhou (Book of Zhou); Li Baiyao to compile the history of Northern Qi (Book of Northern Qi); Yao Silian to compile the histories of Liang (Book of Liang) and Chen (Book of Chen); and Wei Zheng to compile the history of Sui (Book of Sui), and to oversee the overall compilation project with Fang Xuanling. These officials also convened to discuss the issue of the history of Northern Wei, but concluded that as Northern Wei's history has already been compiled in the past by Wei Shou (now known as the Book of Wei) and Wei Dan (魏澹, Wei Shou's cousin, who compiled a separate Book of Wei now no longer extant), it was no longer necessary to have a new compilation. At Linghu's suggestion, the imperial censor Cui Renshi was also invited to join the Northern Zhou project, and Linghu himself also contributed to the compilation of the histories of Liang, Chen, Northern Qi, and Sui. Later historians praised Linghu for spearheading the overall project.
In 632, Linghu was made the deputy minister of rites (禮部侍郎), but continued to serve as an imperial historian. He was also created the Baron of Pengyang.
In 636, the Book of Zhou was completed, and Linghu was awarded silk.
In 637, another work by Linghu, the New Rites (新禮), was completed, and his title was promoted to Viscount of Pengyang. Also that year, another project that Linghu participated in, the Records of Clans (氏族志), was completed as well, and he was awarded silk again.
In 644, Linghu was recalled to civil service and made the prefect of Ya Prefecture (雅州, roughly modern Ya'an, Sichuan), but was later removed from office due to his acts there. Soon, however, when Fang was put in charge of compiling the history of Jin Dynasty (265-420) (Book of Jin), Linghu was made the lead editor on the project, which involved 118 editors, and the other editors largely followed Linghu's lead. After the work was completed in 648, Linghu was made Mishu Jian (秘書監), the head of the archival bureau.
 During Emperor Gaozong's reign
Emperor Taizong died in 639 and was succeeded by his son Li Zhi the Crown Prince (as Emperor Gaozong). In 640, Emperor Gaozong put Linghu Defen in charge of editing the laws, and made him the deputy minister of rites again, as well as an imperial scholar at Hongwen Pavilion (弘文館). He was soon made the minister of worship (太常卿, Taichang Qing) and continued to serve as imperial scholar as well.
In 643, Linghu was made Guozi Jijiu (國子祭酒), the principal of the imperial university. As Linghu had compiled the records of Emperor Taizong's reign after 639, he was awarded silk and made an imperial scholar at Chongxian Pavilion (崇賢館). He was later put in charge of compiling the records of Emperor Gaozong's reign as well, and his title was promoted to Duke of Pengyang. In 662, he requested retirement and was allowed to retire with the honorific title of Jinzi Guanglu Daifu (金紫光祿大夫). He died in 666. It was said that in his late years he was particularly diligent in writing, and whenever there were major compilation projects, he would participate.