{"id":23521,"date":"2023-04-19T09:11:21","date_gmt":"2023-04-19T09:11:21","guid":{"rendered":"https:\/\/www.booksofall.com\/?post_type=product&#038;p=23521"},"modified":"2023-04-19T09:11:21","modified_gmt":"2023-04-19T09:11:21","slug":"unix-lecture-notes-chapter-05","status":"publish","type":"product","link":"https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/","title":{"rendered":"UNIX Lecture Notes &#8211; Chapter 05"},"content":{"rendered":"<h2>5.1 The Different Types of UNIX Programs<\/h2>\n<p>Programs that run in a UNIX environment can be classified by their relationship to terminal devices and by their input\/output streams. They generally fall into one of three categories: software tools, daemons, and interactive user programs.<\/p>\n<h3>5.1.1 Software Tools (Filters)<\/h3>\n<p>A software tool is a program that<\/p>\n<ul>\n<li>receives its input from either \u0015\n<ul>\n<li>one or more \u001cfiles given as <a href=\"https:\/\/data-flair.training\/blogs\/command-line-arguments-in-c\/\">command-line arguments<\/a>, or \u0015<\/li>\n<li>from standard input if no filename arguments are present,<\/li>\n<\/ul>\n<\/li>\n<li>expects its input to be an unstructured stream of bytes, almost always treated as plain text, and<\/li>\n<li>puts its output, which is also a stream of bytes, usually plain text, on standard output.<\/li>\n<\/ul>\n<p>Because software tools can read from standard input and write to standard output, they can be connected via shell pipes to form pipelines, like factory <a href=\"https:\/\/www.investopedia.com\/terms\/a\/assembly-line.asp-0\">assembly lines<\/a>. UNIX has many software tools, including awk, cat, cut, du, fold, grep, od, sed, sort, tr, and uniq.<\/p>\n<h3>5.1.2 Daemons<\/h3>\n<p>Another class of programs are device drivers, which are not even attached to a terminal. A program that is not attached to a terminal is called a daemon in UNIX. A commonly used, but inaccurate, de\u001cfinition of a <a href=\"https:\/\/itsfoss.com\/linux-daemons\/\">daemon<\/a> is that it is a<a href=\"https:\/\/en.wikipedia.org\/wiki\/Background_process\"> &#8220;background&#8221; process<\/a>. To be precise, it is a process that executes without an associated terminal or login shell, waiting for an event to occur. The event might be a user request for a service such as printing or connecting to the Internet, or a clock tick indicating that it is time to run. The word &#8220;daemon&#8221; is from <a href=\"https:\/\/en.wikipedia.org\/wiki\/Greek_mythology\">Greek mythology<\/a>, and refers to a lesser god who did helpful tasks for the people he or she protected. Daemons are like these lesser gods; they are created at boot time, and exist, in hiding, ready to provide services when called upon.<\/p>\n<p>Because daemons must not be connected to a terminal, one of their \u001cfirst tasks is to close all open fi\u001cle descriptors (in particular, standard input, standard output and standard error). They usually make their working directory the root of the fi\u001cle system. They then take additional steps to break their association with any shell or terminal, among which are leaving their process group and registering their intent to ignore all incoming signals. The concept of process groups will be discussed in Chapter 8. Signals are covered later in this chapter.<\/p>\n<p>Daemon process names typically end in &#8216;d&#8217;. This is one way to identify a daemon process in the output of the ps -ef command; \u001cnd the names ending in &#8220;d&#8221; as in ftpd, httpd, lpd, sshd, syslogd, and telnetd. Daemons will be covered thoroughly in Chapter 8.<\/p>\n<h3>5.1.3 Interactive User Programs<\/h3>\n<p>Another category of programs are those that are tied to the user terminal in an inextricable way, because they customize the terminal for their own use. Programs that interact with the user through the terminal, such as text editors (vi, nano, or emacs), pagers (more and less), terminal-based administrative tools such as top, games (snake, worm, and chess), and terminal-based mail clients (pine and mailx), are tightly coupled to the terminal and must control its settings and attributes. They cannot use the standard input and output streams for communicating with the user because these lack the types of controls that a terminal has. These types of programs usually need to control<\/p>\n<p>whether or not characters are echoed,<\/p>\n<p>the number of characters that are bu\u001bffered, if any,<\/p>\n<p>the movement of the cursor on the screen,<\/p>\n<p>whether certain key presses should have their default meaning or have application-de\u001cfined meaning,<\/p>\n<p>whether timeouts should occur on input,<\/p>\n<p>whether signals such as Ctrl-C should be ignored, queued, or handled immediately.<\/p>\n<p>We already saw how to control the state of the terminal using stty at the command level and the tcgetattr() and tcsetattr() functions at the programming level. Here we will explore the various modes into which we can put the terminal for the benefi\u001ct of creating interactive programs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p><iframe style=\"width: 100%; height: 750px; border: none;\" src=\"https:\/\/online.visual-paradigm.com\/share\/book\/unix-lecture-notes-chapter-05-1bs0xf4o7p?p=1\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n","protected":false},"featured_media":23525,"template":"","meta":{"_yoast_wpseo_title":"","_yoast_wpseo_metadesc":"There are 3 categories for programs running in a UNIX environment software tools, daemons, and interactive user programs. Learn more here!"},"product_brand":[],"product_cat":[376],"product_tag":[],"class_list":{"0":"post-23521","1":"product","2":"type-product","3":"status-publish","4":"has-post-thumbnail","6":"product_cat-unix-lecture-notes","8":"first","9":"instock","10":"shipping-taxable","11":"product-type-simple"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>UNIX Lecture Notes - Chapter 05 - BooksOfAll Portuguese<\/title>\n<meta name=\"description\" content=\"There are 3 categories for programs running in a UNIX environment software tools, daemons, and interactive user programs. Learn more here!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/\" \/>\n<meta property=\"og:locale\" content=\"pt_PT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"UNIX Lecture Notes - Chapter 05 - BooksOfAll Portuguese\" \/>\n<meta property=\"og:description\" content=\"There are 3 categories for programs running in a UNIX environment software tools, daemons, and interactive user programs. Learn more here!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/\" \/>\n<meta property=\"og:site_name\" content=\"BooksOfAll Portuguese\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_05-1.jpg\" \/><meta property=\"og:image\" content=\"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_05-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"827\" \/>\n\t<meta property=\"og:image:height\" content=\"1169\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_05-1.jpg\" \/>\n<meta name=\"twitter:label1\" content=\"Tempo estimado de leitura\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/\",\"url\":\"https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/\",\"name\":\"UNIX Lecture Notes - Chapter 05 - BooksOfAll Portuguese\",\"isPartOf\":{\"@id\":\"https:\/\/www.booksofall.com\/pt\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_05-1.jpg\",\"datePublished\":\"2023-04-19T09:11:21+00:00\",\"description\":\"There are 3 categories for programs running in a UNIX environment software tools, daemons, and interactive user programs. Learn more here!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-PT\",\"@id\":\"https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/#primaryimage\",\"url\":\"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_05-1.jpg\",\"contentUrl\":\"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_05-1.jpg\",\"width\":\"827\",\"height\":\"1169\",\"caption\":\"UNIX Lecture Notes - Chapter 05\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.booksofall.com\/pt\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Categories\",\"item\":\"https:\/\/www.booksofall.com\/pt\/categories\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"UNIX Lecture Notes &#8211; Chapter 05\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.booksofall.com\/pt\/#website\",\"url\":\"https:\/\/www.booksofall.com\/pt\/\",\"name\":\"BooksOfAll Portuguese\",\"description\":\"Biggest IT eBooks library and learning resources - Free eBooks for programming, computing, artificial intelligence and more.\",\"publisher\":{\"@id\":\"https:\/\/www.booksofall.com\/pt\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.booksofall.com\/pt\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"pt-PT\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.booksofall.com\/pt\/#organization\",\"name\":\"BooksOfAll Portuguese\",\"url\":\"https:\/\/www.booksofall.com\/pt\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-PT\",\"@id\":\"https:\/\/www.booksofall.com\/pt\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2022\/06\/booksofall-logo-2.png\",\"contentUrl\":\"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2022\/06\/booksofall-logo-2.png\",\"width\":166,\"height\":30,\"caption\":\"BooksOfAll Portuguese\"},\"image\":{\"@id\":\"https:\/\/www.booksofall.com\/pt\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"UNIX Lecture Notes - Chapter 05 - BooksOfAll Portuguese","description":"There are 3 categories for programs running in a UNIX environment software tools, daemons, and interactive user programs. Learn more here!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/","og_locale":"pt_PT","og_type":"article","og_title":"UNIX Lecture Notes - Chapter 05 - BooksOfAll Portuguese","og_description":"There are 3 categories for programs running in a UNIX environment software tools, daemons, and interactive user programs. Learn more here!","og_url":"https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/","og_site_name":"BooksOfAll Portuguese","og_image":[{"url":"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_05-1.jpg","type":"","width":"","height":""},{"width":827,"height":1169,"url":"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_05-1.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_image":"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_05-1.jpg","twitter_misc":{"Tempo estimado de leitura":"3 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/","url":"https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/","name":"UNIX Lecture Notes - Chapter 05 - BooksOfAll Portuguese","isPartOf":{"@id":"https:\/\/www.booksofall.com\/pt\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/#primaryimage"},"image":{"@id":"https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/#primaryimage"},"thumbnailUrl":"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_05-1.jpg","datePublished":"2023-04-19T09:11:21+00:00","description":"There are 3 categories for programs running in a UNIX environment software tools, daemons, and interactive user programs. Learn more here!","breadcrumb":{"@id":"https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/"]}]},{"@type":"ImageObject","inLanguage":"pt-PT","@id":"https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/#primaryimage","url":"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_05-1.jpg","contentUrl":"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_05-1.jpg","width":"827","height":"1169","caption":"UNIX Lecture Notes - Chapter 05"},{"@type":"BreadcrumbList","@id":"https:\/\/www.booksofall.com\/pt\/unix-lecture-notes-chapter-05\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.booksofall.com\/pt\/"},{"@type":"ListItem","position":2,"name":"Categories","item":"https:\/\/www.booksofall.com\/pt\/categories\/"},{"@type":"ListItem","position":3,"name":"UNIX Lecture Notes &#8211; Chapter 05"}]},{"@type":"WebSite","@id":"https:\/\/www.booksofall.com\/pt\/#website","url":"https:\/\/www.booksofall.com\/pt\/","name":"BooksOfAll Portuguese","description":"Biggest IT eBooks library and learning resources - Free eBooks for programming, computing, artificial intelligence and more.","publisher":{"@id":"https:\/\/www.booksofall.com\/pt\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.booksofall.com\/pt\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"pt-PT"},{"@type":"Organization","@id":"https:\/\/www.booksofall.com\/pt\/#organization","name":"BooksOfAll Portuguese","url":"https:\/\/www.booksofall.com\/pt\/","logo":{"@type":"ImageObject","inLanguage":"pt-PT","@id":"https:\/\/www.booksofall.com\/pt\/#\/schema\/logo\/image\/","url":"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2022\/06\/booksofall-logo-2.png","contentUrl":"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2022\/06\/booksofall-logo-2.png","width":166,"height":30,"caption":"BooksOfAll Portuguese"},"image":{"@id":"https:\/\/www.booksofall.com\/pt\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.booksofall.com\/pt\/wp-json\/wp\/v2\/product\/23521","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.booksofall.com\/pt\/wp-json\/wp\/v2\/product"}],"about":[{"href":"https:\/\/www.booksofall.com\/pt\/wp-json\/wp\/v2\/types\/product"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.booksofall.com\/pt\/wp-json\/wp\/v2\/media\/23525"}],"wp:attachment":[{"href":"https:\/\/www.booksofall.com\/pt\/wp-json\/wp\/v2\/media?parent=23521"}],"wp:term":[{"taxonomy":"product_brand","embeddable":true,"href":"https:\/\/www.booksofall.com\/pt\/wp-json\/wp\/v2\/product_brand?post=23521"},{"taxonomy":"product_cat","embeddable":true,"href":"https:\/\/www.booksofall.com\/pt\/wp-json\/wp\/v2\/product_cat?post=23521"},{"taxonomy":"product_tag","embeddable":true,"href":"https:\/\/www.booksofall.com\/pt\/wp-json\/wp\/v2\/product_tag?post=23521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}