{"id":4575,"date":"2024-03-29T02:20:00","date_gmt":"2024-03-29T06:20:00","guid":{"rendered":"https:\/\/www.both.org\/?p=4575"},"modified":"2024-03-25T14:40:20","modified_gmt":"2024-03-25T18:40:20","slug":"an-introduction-to-the-gnu-core-utilities","status":"publish","type":"post","link":"https:\/\/www.both.org\/?p=4575","title":{"rendered":"An introduction to the GNU Core Utilities"},"content":{"rendered":"<div class=\"pld-like-dislike-wrap pld-template-1\">\r\n    <div class=\"pld-like-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-like-trigger pld-like-dislike-trigger  \" title=\"\" data-post-id=\"4575\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                        <i class=\"fas fa-thumbs-up\"><\/i>\r\n                <\/a>\r\n    <span class=\"pld-like-count-wrap pld-count-wrap\">    <\/span>\r\n<\/div><\/div>\n<p class=\"has-small-font-size\">Image by: Bella67 via Pixabay. CC0.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Most everything a Linux sysadmin needs to do can be found in the GNU coreutils or util-linux.<\/h2>\n\n\n\n<p>Two sets of utilities\u2014the&nbsp;<a href=\"https:\/\/www.gnu.org\/software\/coreutils\/coreutils.html\" target=\"_blank\" rel=\"noreferrer noopener\">GNU Core Utilities<\/a> and&nbsp;<code><a href=\"https:\/\/en.wikipedia.org\/wiki\/Util-linux\" target=\"_blank\" rel=\"noreferrer noopener\">util-linux<\/a><\/code>\u2014comprise many of the Linux system administrator&#8217;s most basic and regularly used tools.&nbsp;Their basic functions allow sysadmins to perform many of the tasks required to administer a Linux computer, including management and manipulation of text files, directories, data streams, storage media, process controls, filesystems, and much more.<\/p>\n\n\n\n<p>These tools are indispensable because, without them, it is impossible to accomplish any useful work on a Unix or Linux computer. Given their importance, let&#8217;s examine them.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">GNU coreutils<\/h2>\n\n\n\n<p>To understand the origins of the GNU Core Utilities, we need to take a short trip in the Wayback machine to the early days of Unix at Bell Labs. <a href=\"https:\/\/en.wikipedia.org\/wiki\/History_of_Unix\" target=\"_blank\" rel=\"noreferrer noopener\">Unix was written<\/a> so Ken Thompson, Dennis Ritchie, Doug McIlroy, and Joe Ossanna could continue with something they had started while working on a large multi-tasking and multi-user computer project called <a href=\"https:\/\/en.wikipedia.org\/wiki\/Multics\" target=\"_blank\" rel=\"noreferrer noopener\">Multics<\/a>. That little something was a game called Space Travel. As remains true today, it always seems to be the gamers who drive forward the technology of computing. This new operating system was much more limited than Multics, as only two users could log in at a time, so it was called Unics. This name was later changed to Unix.<\/p>\n\n\n\n<p>Over time, Unix turned out to be such a success that Bell Labs began essentially giving it away it to universities and later to companies for the cost of the media and shipping. Back in those days, system-level software was shared between organizations and programmers as they worked to achieve common goals within the context of system administration.<\/p>\n\n\n\n<p>Eventually, the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Pointy-haired_Boss\" target=\"_blank\" rel=\"noreferrer noopener\">PHBs<\/a> at AT&amp;T decided they should make money on Unix and started using more restrictive\u2014and expensive\u2014licensing. This was taking place at a time when software was becoming more proprietary, restricted, and closed. It was becoming impossible to share software with other users and organizations.<\/p>\n\n\n\n<p>Some people did not like this and fought it with free software. Richard M. Stallman, aka RMS, led a group of rebels who were trying to write an open and freely available operating system they called the GNU Operating System. This group created the GNU Utilities but didn&#8217;t produce a viable kernel.<\/p>\n\n\n\n<p>When Linus Torvalds first wrote and compiled the Linux kernel, he needed a set of very basic system utilities to even begin to perform marginally useful work. The kernel does not provide commands or any type of command shell such as Bash. It is useless by itself. So, Linus used the freely available GNU Core Utilities and recompiled them for Linux. This gave him a complete, if quite basic, operating system.<\/p>\n\n\n\n<p>You can learn about all the individual programs that comprise the GNU Utilities by entering the command <code>info coreutils<\/code> at a terminal command line. The following list of the core utilities is part of that info page. The utilities are grouped by function to make specific ones easier to find; in the terminal, highlight the group you want more information on and press the Enter key.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>* Output of entire files::       cat tac nl od base32 base64\n* Formatting file contents::     fmt pr fold\n* Output of parts of files::     head tail split csplit\n* Summarizing files::            wc sum cksum b2sum md5sum sha1sum sha2\n* Operating on sorted files::    sort shuf uniq comm ptx tsort\n* Operating on fields::          cut paste join\n* Operating on characters::      tr expand unexpand\n* Directory listing::            ls dir vdir dircolors\n* Basic operations::             cp dd install mv rm shred\n* Special file types::           mkdir rmdir unlink mkfifo mknod ln link readlink\n* Changing file attributes::     chgrp chmod chown touch\n* Disk usage::                   df du stat sync truncate\n* Printing text::                echo printf yes\n* Conditions::                   false true test expr\n* Redirection::                  tee\n* File name manipulation::       dirname basename pathchk mktemp realpath\n* Working context::              pwd stty printenv tty\n* User information::             id logname whoami groups users who\n* System context::               date arch nproc uname hostname hostid uptime\n* SELinux context::              chcon runcon\n* Modified command invocation::  chroot env nice nohup stdbuf timeout\n* Process control::              kill\n* Delaying::                     sleep\n* Numeric operations::           factor numfmt seq<\/code><\/pre>\n\n\n\n<p>There are 102 utilities on this list. It covers many of the functions necessary to perform basic tasks on a Unix or Linux host. However, many basic utilities are missing. For example, the <code>mount<\/code> and <code>umount<\/code> commands are not in this list. Those and many of the other commands that are not in the GNU coreutils can be found in the <code>util-linux<\/code> collection.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">util-linux<\/h2>\n\n\n\n<p>The <code>util-linux<\/code> package of utilities contains many of the other common commands that sysadmins use. These utilities are distributed by the Linux Kernel Organization, and virtually every one of these 107 commands were originally three separate collections\u2014<code>fileutils<\/code>, <code>shellutils<\/code>, and <code>textutils<\/code>\u2014which were <a href=\"https:\/\/en.wikipedia.org\/wiki\/GNU_Core_Utilities\" target=\"_blank\" rel=\"noreferrer noopener\">combined into the single package<\/a> <code>util-linux<\/code> in 2003.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>agetty          fsck.minix      mkfs.bfs        setpriv \nblkdiscard      fsfreeze        mkfs.cramfs     setsid \nblkid           fstab           mkfs.minix      setterm \nblockdev        fstrim          mkswap          sfdisk \ncal             getopt          more            su \ncfdisk          hexdump         mount           sulogin \nchcpu           hwclock         mountpoint      swaplabel \nchfn            ionice          namei           swapoff \nchrt            ipcmk           newgrp          swapon \nchsh            ipcrm           nologin         switch_root \ncolcrt          ipcs            nsenter         tailf \ncol             isosize         partx           taskset \ncolrm           kill            pg              tunelp \ncolumn          last            pivot_root      ul \nctrlaltdel      ldattach        prlimit         umount \nddpart          line            raw             unshare \ndelpart         logger          readprofile     utmpdump \ndmesg           login           rename          uuidd \neject           look            renice          uuidgen \nfallocate       losetup         reset           vipw \nfdformat        lsblk           resizepart      wall \nfdisk           lscpu           rev             wdctl \nfindfs          lslocks         RTC Alarm       whereis \nfindmnt         lslogins        runuser         wipefs \nflock           mcookie         script          write \nfsck            mesg            scriptreplay    zramctl \nfsck.cramfs     mkfs            setarch<\/code><\/pre>\n\n\n\n<p>Some of these utilities have been deprecated and will likely fall out of the collection at some point in the future. You should check <a href=\"https:\/\/en.wikipedia.org\/wiki\/Util-linux\" target=\"_blank\" rel=\"noreferrer noopener\">Wikipedia&#8217;s <code>util-linux<\/code> page<\/a> for information on many of the utilities, and the man pages also provide details on the commands.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>These two collections of Linux utilities, the GNU Core Utilities and <code>util-linux<\/code>, together provide the basic utilities required to administer a Linux system. As I researched this article, I found several interesting utilities I never knew about. Many of these commands are seldom needed, but when you need them, they are indispensable.<\/p>\n\n\n\n<p>Between these two collections, there are over 200 Linux utilities. While Linux has many more commands, these are the ones needed to manage the basic functions of a typical Linux host.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Most everything a Linux sysadmin needs to do can be found in the GNU coreutils or util-linux.<\/p>\n","protected":false},"author":2,"featured_media":4578,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[100,5],"tags":[334],"class_list":["post-4575","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-command-line","category-linux","tag-linux-core-utilities"],"modified_by":"David Both","_links":{"self":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/4575","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4575"}],"version-history":[{"count":2,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/4575\/revisions"}],"predecessor-version":[{"id":4577,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/4575\/revisions\/4577"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/media\/4578"}],"wp:attachment":[{"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4575"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}