Knowledge (XXG)

Shell builtin

Source 📝

2028: 854: 876: 39:
Shell builtins work significantly faster than external programs, because there is no program loading overhead. However, their code is inherently present in the shell, and thus modifying or updating them requires modifications to the shell. Therefore, shell builtins are usually used for simple, almost
2069: 1849: 914: 1593: 242: 1939: 2062: 1547: 191: 164: 116: 2098: 867: 862: 2055: 1844: 1567: 907: 133: 181: 152: 1673: 1984: 1588: 1170: 235: 210: 95: 44:, some functions of the systems must necessarily be implemented as shell builtins. The most notable example is the 2088: 1713: 1708: 1648: 900: 839: 809: 824: 2093: 1562: 1301: 1019: 926: 880: 585: 254: 228: 220: 2007: 1512: 1134: 1129: 1124: 1119: 2002: 1997: 1895: 1663: 1413: 1403: 1306: 755: 703: 76: 1794: 1572: 1517: 1024: 892: 55: 21: 1499: 1489: 1240: 428: 418: 1764: 1165: 1082: 1071: 923: 187: 160: 112: 51: 29: 2039: 2035: 2027: 1969: 1507: 1352: 1347: 1337: 1210: 956: 655: 560: 555: 41: 33: 62:
as an external program would not affect the working directory of the shell that loaded it.
1929: 1903: 1658: 1557: 1484: 1433: 1423: 1398: 1311: 1296: 1220: 1144: 834: 778: 683: 484: 387: 1959: 1739: 1552: 1527: 1474: 1454: 1418: 1393: 1383: 1373: 1281: 1276: 1061: 1029: 993: 988: 983: 773: 708: 693: 630: 590: 469: 433: 327: 2082: 1934: 1623: 1459: 1428: 1250: 1245: 1139: 1076: 1034: 978: 814: 610: 382: 357: 215: 1954: 1949: 1749: 1744: 1469: 1271: 972: 788: 688: 605: 600: 504: 413: 377: 332: 46: 32:, that is executed directly in the shell itself, instead of an external executable 1774: 1603: 1255: 1195: 941: 724: 698: 635: 625: 615: 580: 570: 565: 448: 438: 392: 1804: 1703: 1693: 951: 540: 499: 302: 272: 25: 1979: 1688: 1225: 1066: 829: 783: 763: 660: 640: 595: 443: 367: 352: 337: 322: 317: 312: 307: 1875: 1834: 1814: 1809: 1799: 1784: 1769: 1734: 1729: 1643: 1638: 1613: 1608: 1537: 1532: 1388: 1357: 1321: 1316: 1286: 1230: 1200: 1190: 1185: 1180: 1175: 1093: 745: 525: 1974: 1908: 1880: 1870: 1865: 1839: 1829: 1824: 1779: 1759: 1698: 1683: 1678: 1653: 1633: 1618: 1479: 1098: 1040: 946: 550: 474: 71: 40:
trivial, functions, such as text output. Because of the nature of some
1964: 1913: 1885: 1754: 1668: 1522: 1438: 1408: 1378: 1215: 1160: 1056: 1009: 535: 277: 1944: 1819: 1789: 1628: 1464: 1342: 1291: 1235: 1205: 1103: 1087: 1050: 1045: 1014: 768: 665: 645: 575: 494: 397: 372: 347: 297: 292: 287: 282: 1598: 1542: 819: 793: 729: 650: 545: 530: 489: 479: 423: 251: 58:, and working directories are specific to each process, loading 896: 224: 54:
of the shell. Since each executable program runs in a separate
620: 520: 464: 362: 342: 153:"1.7. Using or Replacing Built-ins and External Commands" 2043: 107:
Tansley, David (2000). "24. Shell built-in commands".
1922: 1894: 1858: 1722: 1581: 1498: 1447: 1366: 1330: 1264: 1153: 1112: 1002: 965: 802: 754: 738: 717: 674: 513: 457: 406: 265: 186:(2nd ed.). Berkeley, CA: Apress. p. 47. 180:Kuhn, Darl; Kim, Charles; Lopuz, Bernard (2015). 2063: 908: 236: 8: 151:Albing, Carl; Vossen, JP; Newham, Cameron. 2070: 2056: 915: 901: 893: 875: 243: 229: 221: 183:Linux and Solaris Recipes for Oracle DBAs 36:which the shell would load and execute. 88: 211:List of special shell builtin commands 7: 2024: 2022: 138:A Practical Guide to Red Hat Linux 8 2042:. You can help Knowledge (XXG) by 159:. O'Reilly Media. pp. 13–15. 14: 2026: 874: 853: 852: 216:List of MS-DOS internal commands 109:Linux and Unix shell programming 96:POSIX standard: Shell Commands 1: 50:command, which changes the 2115: 2021: 111:. Harlow: Addison-Wesley. 1993: 937: 848: 132:Sobell, Mark G. (2003). 2099:Operating system stubs 2038:-related article is a 966:File system navigation 868:Unix SUS2008 utilities 863:Standard Unix programs 255:command-line interface 2008:Windows Support Tools 2003:Environment variables 1998:List of DOS commands 1896:Software development 1723:Maintenance and care 756:Software development 77:Internal DOS command 140:. pp. 161–162. 952:Windows PowerShell 2051: 2050: 2016: 2015: 890: 889: 52:working directory 42:operating systems 2106: 2089:Windows commands 2072: 2065: 2058: 2036:operating-system 2030: 2023: 1367:User environment 957:Recovery Console 917: 910: 903: 894: 878: 877: 856: 855: 458:User environment 245: 238: 231: 222: 198: 197: 177: 171: 170: 148: 142: 141: 129: 123: 122: 104: 98: 93: 61: 49: 28:, called from a 16:In computing, a 2114: 2113: 2109: 2108: 2107: 2105: 2104: 2103: 2079: 2078: 2077: 2076: 2019: 2017: 2012: 1989: 1918: 1890: 1859:Boot management 1854: 1718: 1577: 1494: 1443: 1362: 1326: 1260: 1154:Disk management 1149: 1108: 1003:File management 998: 961: 933: 921: 891: 886: 844: 798: 750: 734: 713: 670: 514:Text processing 509: 453: 402: 261: 249: 207: 202: 201: 194: 179: 178: 174: 167: 150: 149: 145: 131: 130: 126: 119: 106: 105: 101: 94: 90: 85: 68: 59: 45: 12: 11: 5: 2112: 2110: 2102: 2101: 2096: 2094:Command shells 2091: 2081: 2080: 2075: 2074: 2067: 2060: 2052: 2049: 2048: 2031: 2014: 2013: 2011: 2010: 2005: 2000: 1994: 1991: 1990: 1988: 1987: 1982: 1977: 1972: 1967: 1962: 1957: 1952: 1947: 1942: 1937: 1932: 1926: 1924: 1920: 1919: 1917: 1916: 1911: 1906: 1900: 1898: 1892: 1891: 1889: 1888: 1883: 1878: 1873: 1868: 1862: 1860: 1856: 1855: 1853: 1852: 1847: 1842: 1837: 1832: 1827: 1822: 1817: 1812: 1807: 1802: 1797: 1792: 1787: 1782: 1777: 1772: 1767: 1762: 1757: 1752: 1747: 1742: 1737: 1732: 1726: 1724: 1720: 1719: 1717: 1716: 1711: 1706: 1701: 1696: 1691: 1686: 1681: 1676: 1671: 1666: 1661: 1656: 1651: 1646: 1641: 1636: 1631: 1626: 1621: 1616: 1611: 1606: 1601: 1596: 1591: 1585: 1583: 1579: 1578: 1576: 1575: 1570: 1565: 1560: 1555: 1550: 1545: 1540: 1535: 1530: 1525: 1520: 1515: 1510: 1504: 1502: 1496: 1495: 1493: 1492: 1487: 1482: 1477: 1472: 1467: 1462: 1457: 1451: 1449: 1445: 1444: 1442: 1441: 1436: 1431: 1426: 1421: 1416: 1411: 1406: 1401: 1396: 1391: 1386: 1381: 1376: 1370: 1368: 1364: 1363: 1361: 1360: 1355: 1350: 1345: 1340: 1334: 1332: 1328: 1327: 1325: 1324: 1319: 1314: 1309: 1304: 1299: 1294: 1289: 1284: 1279: 1274: 1268: 1266: 1262: 1261: 1259: 1258: 1253: 1248: 1243: 1238: 1233: 1228: 1223: 1218: 1213: 1208: 1203: 1198: 1193: 1188: 1183: 1178: 1173: 1168: 1163: 1157: 1155: 1151: 1150: 1148: 1147: 1142: 1137: 1132: 1127: 1122: 1116: 1114: 1110: 1109: 1107: 1106: 1101: 1096: 1091: 1085: 1080: 1074: 1069: 1064: 1059: 1054: 1048: 1043: 1038: 1032: 1027: 1022: 1017: 1012: 1006: 1004: 1000: 999: 997: 996: 991: 986: 981: 976: 969: 967: 963: 962: 960: 959: 954: 949: 947:Command Prompt 944: 938: 935: 934: 931:shell builtins 922: 920: 919: 912: 905: 897: 888: 887: 885: 884: 872: 871: 870: 865: 849: 846: 845: 843: 842: 840:true and false 837: 832: 827: 822: 817: 812: 806: 804: 800: 799: 797: 796: 791: 786: 781: 776: 771: 766: 760: 758: 752: 751: 749: 748: 742: 740: 736: 735: 733: 732: 727: 721: 719: 715: 714: 712: 711: 706: 701: 696: 691: 686: 680: 678: 676:Shell builtins 672: 671: 669: 668: 663: 658: 653: 648: 643: 638: 633: 628: 623: 618: 613: 608: 603: 598: 593: 588: 583: 578: 573: 568: 563: 558: 553: 548: 543: 538: 533: 528: 523: 517: 515: 511: 510: 508: 507: 502: 497: 492: 487: 482: 477: 472: 467: 461: 459: 455: 454: 452: 451: 446: 441: 436: 431: 426: 421: 416: 410: 408: 404: 403: 401: 400: 395: 390: 385: 380: 375: 370: 365: 360: 355: 350: 345: 340: 335: 330: 325: 320: 315: 310: 305: 300: 295: 290: 285: 280: 275: 269: 267: 263: 262: 259:shell builtins 250: 248: 247: 240: 233: 225: 219: 218: 213: 206: 205:External links 203: 200: 199: 192: 172: 165: 143: 124: 117: 99: 87: 86: 84: 81: 80: 79: 74: 67: 64: 13: 10: 9: 6: 4: 3: 2: 2111: 2100: 2097: 2095: 2092: 2090: 2087: 2086: 2084: 2073: 2068: 2066: 2061: 2059: 2054: 2053: 2047: 2045: 2041: 2037: 2032: 2029: 2025: 2020: 2009: 2006: 2004: 2001: 1999: 1996: 1995: 1992: 1986: 1983: 1981: 1978: 1976: 1973: 1971: 1968: 1966: 1963: 1961: 1958: 1956: 1953: 1951: 1948: 1946: 1943: 1941: 1938: 1936: 1933: 1931: 1928: 1927: 1925: 1923:Miscellaneous 1921: 1915: 1912: 1910: 1907: 1905: 1902: 1901: 1899: 1897: 1893: 1887: 1884: 1882: 1879: 1877: 1874: 1872: 1869: 1867: 1864: 1863: 1861: 1857: 1851: 1848: 1846: 1843: 1841: 1838: 1836: 1833: 1831: 1828: 1826: 1823: 1821: 1818: 1816: 1813: 1811: 1808: 1806: 1803: 1801: 1798: 1796: 1793: 1791: 1788: 1786: 1783: 1781: 1778: 1776: 1773: 1771: 1768: 1766: 1763: 1761: 1758: 1756: 1753: 1751: 1750:eventtriggers 1748: 1746: 1743: 1741: 1738: 1736: 1733: 1731: 1728: 1727: 1725: 1721: 1715: 1712: 1710: 1707: 1705: 1702: 1700: 1697: 1695: 1692: 1690: 1687: 1685: 1682: 1680: 1677: 1675: 1672: 1670: 1667: 1665: 1662: 1660: 1657: 1655: 1652: 1650: 1647: 1645: 1642: 1640: 1637: 1635: 1632: 1630: 1627: 1625: 1622: 1620: 1617: 1615: 1612: 1610: 1607: 1605: 1602: 1600: 1597: 1595: 1592: 1590: 1587: 1586: 1584: 1580: 1574: 1571: 1569: 1566: 1564: 1561: 1559: 1556: 1554: 1551: 1549: 1546: 1544: 1541: 1539: 1536: 1534: 1531: 1529: 1526: 1524: 1521: 1519: 1516: 1514: 1511: 1509: 1506: 1505: 1503: 1501: 1497: 1491: 1488: 1486: 1483: 1481: 1478: 1476: 1473: 1471: 1468: 1466: 1463: 1461: 1458: 1456: 1453: 1452: 1450: 1448:File contents 1446: 1440: 1437: 1435: 1432: 1430: 1427: 1425: 1422: 1420: 1417: 1415: 1412: 1410: 1407: 1405: 1402: 1400: 1397: 1395: 1392: 1390: 1387: 1385: 1382: 1380: 1377: 1375: 1372: 1371: 1369: 1365: 1359: 1356: 1354: 1351: 1349: 1346: 1344: 1341: 1339: 1336: 1335: 1333: 1329: 1323: 1320: 1318: 1315: 1313: 1310: 1308: 1305: 1303: 1300: 1298: 1295: 1293: 1290: 1288: 1285: 1283: 1280: 1278: 1275: 1273: 1270: 1269: 1267: 1263: 1257: 1254: 1252: 1249: 1247: 1244: 1242: 1239: 1237: 1234: 1232: 1229: 1227: 1224: 1222: 1219: 1217: 1214: 1212: 1209: 1207: 1204: 1202: 1199: 1197: 1194: 1192: 1189: 1187: 1184: 1182: 1179: 1177: 1174: 1172: 1169: 1167: 1164: 1162: 1159: 1158: 1156: 1152: 1146: 1143: 1141: 1138: 1136: 1133: 1131: 1128: 1126: 1123: 1121: 1118: 1117: 1115: 1111: 1105: 1102: 1100: 1097: 1095: 1092: 1089: 1086: 1084: 1081: 1078: 1075: 1073: 1070: 1068: 1065: 1063: 1060: 1058: 1055: 1052: 1049: 1047: 1044: 1042: 1039: 1036: 1033: 1031: 1028: 1026: 1023: 1021: 1018: 1016: 1013: 1011: 1008: 1007: 1005: 1001: 995: 992: 990: 987: 985: 982: 980: 977: 974: 971: 970: 968: 964: 958: 955: 953: 950: 948: 945: 943: 940: 939: 936: 932: 929:programs and 928: 925: 918: 913: 911: 906: 904: 899: 898: 895: 883: 882: 873: 869: 866: 864: 861: 860: 859: 851: 850: 847: 841: 838: 836: 833: 831: 828: 826: 823: 821: 818: 816: 813: 811: 808: 807: 805: 803:Miscellaneous 801: 795: 792: 790: 787: 785: 782: 780: 777: 775: 772: 770: 767: 765: 762: 761: 759: 757: 753: 747: 744: 743: 741: 739:Documentation 737: 731: 728: 726: 723: 722: 720: 716: 710: 707: 705: 702: 700: 697: 695: 692: 690: 687: 685: 682: 681: 679: 677: 673: 667: 664: 662: 659: 657: 654: 652: 649: 647: 644: 642: 639: 637: 634: 632: 629: 627: 624: 622: 619: 617: 614: 612: 609: 607: 604: 602: 599: 597: 594: 592: 589: 587: 584: 582: 579: 577: 574: 572: 569: 567: 564: 562: 559: 557: 554: 552: 549: 547: 544: 542: 539: 537: 534: 532: 529: 527: 524: 522: 519: 518: 516: 512: 506: 503: 501: 498: 496: 493: 491: 488: 486: 483: 481: 478: 476: 473: 471: 468: 466: 463: 462: 460: 456: 450: 447: 445: 442: 440: 437: 435: 432: 430: 427: 425: 422: 420: 417: 415: 412: 411: 409: 405: 399: 396: 394: 391: 389: 386: 384: 381: 379: 376: 374: 371: 369: 366: 364: 361: 359: 356: 354: 351: 349: 346: 344: 341: 339: 336: 334: 331: 329: 326: 324: 321: 319: 316: 314: 311: 309: 306: 304: 301: 299: 296: 294: 291: 289: 286: 284: 281: 279: 276: 274: 271: 270: 268: 264: 260: 257:programs and 256: 253: 246: 241: 239: 234: 232: 227: 226: 223: 217: 214: 212: 209: 208: 204: 195: 193:9781484212547 189: 185: 184: 176: 173: 168: 166:9780596554705 162: 158: 157:Bash Cookbook 154: 147: 144: 139: 135: 128: 125: 120: 118:9780201674729 114: 110: 103: 100: 97: 92: 89: 82: 78: 75: 73: 70: 69: 65: 63: 57: 53: 48: 43: 37: 35: 31: 27: 23: 19: 18:shell builtin 2044:expanding it 2033: 2018: 930: 927:command-line 879: 857: 675: 258: 182: 175: 156: 146: 137: 127: 108: 102: 91: 38: 17: 15: 1775:pnpunattend 1745:eventcreate 1740:driverquery 1699:ssh-keyscan 942:COMMAND.COM 266:File system 134:"Built-ins" 2083:Categories 1805:systeminfo 1694:ssh-keygen 1582:Networking 1226:manage-bde 1196:diskshadow 858:Categories 83:References 1980:tpmvscmgr 1689:ssh-agent 1594:bitsadmin 1500:Scripting 1265:Processes 1113:Archiving 1067:openfiles 718:Searching 407:Processes 1955:gpupdate 1950:gpresult 1876:bootsect 1835:wevtutil 1815:typeperf 1810:tracerpt 1800:sxstrace 1785:REAgentC 1770:ntbackup 1735:dispdiag 1730:auditpol 1644:PathPing 1639:nslookup 1614:ipconfig 1609:hostname 1538:forfiles 1389:graftabl 1358:regsvr32 1331:Registry 1322:tasklist 1317:taskkill 1307:shutdown 1302:schtasks 1287:powercfg 1256:vssadmin 1241:scandisk 1231:refsutil 1201:drvspace 1191:diskraid 1186:diskpart 1181:diskcopy 1176:diskcomp 1125:extrac32 1094:robocopy 1079:(rename) 526:basename 66:See also 26:function 1975:tpmtool 1909:exe2bin 1881:fixboot 1871:bootcfg 1866:bcdedit 1840:winmgmt 1830:wecutil 1825:WBAdmin 1780:pnputil 1765:msiexec 1760:mofcomp 1704:tracert 1684:ssh-add 1654:rpcping 1634:netstat 1619:nbtstat 1573:timeout 1518:cscript 1480:findstr 1166:convert 1135:makecab 1130:extract 1099:takeown 1083:replace 1072:recover 1041:deltree 1037:(erase) 1025:compact 975:(chdir) 924:Windows 631:strings 551:dirname 475:logname 424:crontab 72:BusyBox 56:process 34:program 22:command 1970:pentnt 1965:MSCDEX 1914:QBasic 1886:fixmbr 1845:winsat 1755:logman 1669:setspn 1604:getmac 1563:prompt 1523:doskey 1508:choice 1439:whoami 1409:setver 1379:cmdkey 1353:regini 1216:fsutil 1211:format 1171:defrag 1161:chkdsk 1120:expand 1057:mklink 1046:icacls 1020:cipher 1010:attrib 611:printf 536:csplit 278:chattr 190:  163:  115:  2034:This 1945:dpath 1930:break 1904:debug 1820:w32tm 1790:relog 1714:winrs 1709:winrm 1659:route 1629:netsh 1558:pause 1485:print 1465:edlin 1434:where 1424:title 1343:ftype 1338:assoc 1312:start 1292:runas 1236:subst 1221:label 1206:fdisk 1104:xcopy 1088:rmdir 1051:mkdir 1015:cacls 989:pushd 835:sleep 789:strip 769:ctags 704:unset 684:alias 666:xargs 646:troff 606:patch 601:paste 576:iconv 505:write 495:uname 398:umask 388:touch 378:split 373:rmdir 348:mkdir 333:fuser 298:cksum 293:chgrp 288:chown 283:chmod 30:shell 24:or a 20:is a 2040:stub 1960:help 1940:dism 1850:wmic 1674:sftp 1649:ping 1599:curl 1553:more 1543:goto 1528:echo 1513:clip 1490:type 1475:find 1460:edit 1455:comp 1419:time 1414:setx 1399:path 1394:mode 1384:date 1374:chcp 1282:kill 1277:exit 1090:(rd) 1062:move 1053:(md) 1030:copy 994:tree 984:popd 881:List 820:expr 794:yacc 779:make 730:grep 725:find 709:wait 699:test 694:echo 651:uniq 636:tail 626:sort 616:read 591:more 581:join 571:head 566:fold 546:diff 531:comm 490:tput 485:talk 480:mesg 470:exit 449:time 439:nice 434:kill 393:type 328:file 252:Unix 188:ISBN 161:ISBN 113:ISBN 1985:wsl 1935:cls 1795:sfc 1679:ssh 1664:scp 1624:net 1589:arp 1568:rem 1533:for 1429:ver 1404:set 1348:reg 1251:vol 1246:sys 1145:tar 1140:pax 1077:ren 1035:del 979:dir 815:cal 774:lex 746:man 621:sed 541:cut 521:awk 500:who 465:env 383:tee 363:pwd 358:pax 303:cmp 273:cat 2085:: 1548:if 1470:fc 1297:sc 1272:at 973:cd 830:od 825:lp 810:bc 784:nm 764:ar 689:cd 661:wc 656:vi 641:tr 596:nl 586:m4 561:ex 556:ed 444:ps 429:fg 419:bg 414:at 368:rm 353:mv 343:ls 338:ln 323:df 318:du 313:dd 308:cp 155:. 136:. 60:cd 47:cd 2071:e 2064:t 2057:v 2046:. 916:e 909:t 902:v 244:e 237:t 230:v 196:. 169:. 121:.

Index

command
function
shell
program
operating systems
cd
working directory
process
BusyBox
Internal DOS command
POSIX standard: Shell Commands
ISBN
9780201674729
"Built-ins"
"1.7. Using or Replacing Built-ins and External Commands"
ISBN
9780596554705
Linux and Solaris Recipes for Oracle DBAs
ISBN
9781484212547
List of special shell builtin commands
List of MS-DOS internal commands
v
t
e
Unix
command-line interface
shell builtins
cat
chattr

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.