{"id":79071,"date":"2026-11-17T01:52:33","date_gmt":"2026-11-17T01:52:33","guid":{"rendered":"http:\/\/bangla.sitestree.com\/?p=79071"},"modified":"2026-11-17T01:52:33","modified_gmt":"2026-11-17T01:52:33","slug":"linux-basics-03-editors","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=79071","title":{"rendered":"Linux Basics 03 \u2014 Editing Text and Reading Files"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/bangla.sitestree.com\/?name=linux-course-index\">Linux course index<\/a> \u00b7 <a href=\"https:\/\/bangla.sitestree.com\/?cat=1990\">Linux Basics category<\/a> \u00b7 Lesson 3 of 8<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>AI disclosure<\/strong> \u2014 AI-generated content, posted as is. AI can make mistakes. This lesson draws on the linked Open Education posts and adds original explanations or lab examples where useful. The newly written explanations and examples may be freely reused. Linked source material retains its own terms.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Learning goal<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Edit a text file in a terminal and verify the exact lines you saved.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Concepts and setup<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The site&#8217;s vi example opens a new testfile. This version uses a short service checklist in a temporary lab. vi opens in normal mode. Press i to insert text, Esc to return to normal mode, and type :wq then Enter to save and exit. :q! exits without saving changes. If you are in the middle of a command, press Esc before trying again.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use cat for short files, less for paging, and head or tail for selected ends. Avoid opening huge log files with cat. For live troubleshooting, tail -f follows a growing file and Ctrl-C stops following it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Create and inspect a lab checklist<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>lab=$(mktemp -d)\ncd &quot;$lab&quot; || exit\nvi checklist.txt\n# Inside vi, press i and type these three lines:\n# check service\n# inspect logs\n# verify response\n# Press Esc, then type :wq and press Enter.\nnl -ba checklist.txt\nhead -n 1 checklist.txt\ntail -n 1 checklist.txt<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Possible output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>     1  check service\n     2  inspect logs\n     3  verify response\ncheck service\nverify response<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The comments describe key presses, not text to type into the file. If your lab has nano but not vi, use nano checklist.txt and save the same three lines.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Inspect with a pager<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>less checklist.txt\n# Inside less, type \/logs and press Enter.\n# Press q to quit.<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Possible output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>check service\ninspect logs\nverify response<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Your terminal may highlight the match and show an end-of-file marker. Typing q exits less without changing the file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Questions only<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Quick-check questions<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li>Why is i not used to save the file?<\/li>\n\n\n<li>What is the difference between :wq and :q!?<\/li>\n\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Assessment questions<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li>Which command prints only the last two lines?<\/li>\n\n\n<li>Change inspect logs to read logs and verify the edit using grep -n.<\/li>\n\n\n<li>Why prefer less over cat for a long report?<\/li>\n\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Questions and answers<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Quick-check answers<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li><strong>Why is i not used to save the file?<\/strong><br><strong>Answer<\/strong> \u2014 i switches to Insert mode. Save commands are entered after returning to Normal mode.<\/li>\n\n\n<li><strong>What is the difference between :wq and :q!?<\/strong><br><strong>Answer<\/strong> \u2014 The first writes and exits. The second quits and discards unsaved edits.<\/li>\n\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Assessment answer key<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li><strong>Which command prints only the last two lines?<\/strong><br><strong>Answer<\/strong> \u2014 tail -n 2 checklist.txt.<\/li>\n\n\n<li><strong>Change inspect logs to read logs and verify the edit using grep -n.<\/strong><br><strong>Answer<\/strong> \u2014 In vi, search with \/inspect logs, then edit the line, save, and run grep -n &#8216;read logs&#8217; checklist.txt. The expected line is 2:read logs.<\/li>\n\n\n<li><strong>Why prefer less over cat for a long report?<\/strong><br><strong>Answer<\/strong> \u2014 less pages and searches without dumping the entire report into the terminal.<\/li>\n\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Source articles on this site<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=9740\">\u0987\u0989\u09a8\u09bf\u0995\u09cd\u09b8\u0983 vi \u098f\u09a1\u09bf\u099f\u09b0 \u099f\u09bf\u0989\u099f\u09cb\u09b0\u09bf\u09df\u09be\u09b2 \u0964 UNIX VI Editor Tutorial<\/a><\/li>\n\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=9577\">\u0987\u0989\u09a8\u09bf\u0995\u09cd\u09b8\u0983 \u09ab\u09be\u0987\u09b2 \u09ac\u09cd\u09af\u09ac\u09b8\u09cd\u09a5\u09be\u09aa\u09a8\u09be (Unix \u2013 File Management)<\/a><\/li>\n\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=78655\">30 mixed quiz questions on Linux Command Line Skills<\/a><\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Continue the course<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Previous lesson 02 \u2014 Paths, Files, and Links. Next lesson 04 \u2014 Pipes, Redirection, and Exit Status.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/bangla.sitestree.com\/?name=linux-course-index\">Linux course index<\/a> \u00b7 <a href=\"https:\/\/bangla.sitestree.com\/?cat=1990\">Linux Basics category<\/a> \u00b7 Lesson 3 of 8<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Edit a text file in a terminal and verify the exact lines you saved.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1990],"tags":[],"class_list":["post-79071","post","type-post","status-publish","format-standard","hentry","category-linux-basics","item-wrap"],"jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":79102,"url":"http:\/\/bangla.sitestree.com\/?p=79102","url_meta":{"origin":79071,"position":0},"title":"Linux Administration Course \u2014 Start Here and Lesson Index","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"A 33-lesson Linux course from shell fundamentals to server administration, performance, and a recovery capstone.","rel":"","context":"In &quot;Linux Basics&quot;","block_context":{"text":"Linux Basics","link":"http:\/\/bangla.sitestree.com\/?cat=1990"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79073,"url":"http:\/\/bangla.sitestree.com\/?p=79073","url_meta":{"origin":79071,"position":1},"title":"Linux Basics 05 \u2014 Finding Files and Filtering Text","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Choose find for names, grep for lines, cut for fields, and sed for transforming text.","rel":"","context":"In &quot;Linux Basics&quot;","block_context":{"text":"Linux Basics","link":"http:\/\/bangla.sitestree.com\/?cat=1990"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79072,"url":"http:\/\/bangla.sitestree.com\/?p=79072","url_meta":{"origin":79071,"position":2},"title":"Linux Basics 04 \u2014 Pipes, Redirection, and Exit Status","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Route input, normal output, and errors, then detect a command failure inside a pipeline.","rel":"","context":"In &quot;Linux Basics&quot;","block_context":{"text":"Linux Basics","link":"http:\/\/bangla.sitestree.com\/?cat=1990"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79075,"url":"http:\/\/bangla.sitestree.com\/?p=79075","url_meta":{"origin":79071,"position":3},"title":"Linux Basics 07 \u2014 Processes, Jobs, and Signals","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Identify a process you own, inspect its state, and stop it gracefully.","rel":"","context":"In &quot;Linux Basics&quot;","block_context":{"text":"Linux Basics","link":"http:\/\/bangla.sitestree.com\/?cat=1990"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79069,"url":"http:\/\/bangla.sitestree.com\/?p=79069","url_meta":{"origin":79071,"position":4},"title":"Linux Basics 01 \u2014 Linux, the Shell, and Your First Lab","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Tell the kernel, distribution, terminal, and shell apart, then identify the system you are actually using.","rel":"","context":"In &quot;Linux Basics&quot;","block_context":{"text":"Linux Basics","link":"http:\/\/bangla.sitestree.com\/?cat=1990"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79070,"url":"http:\/\/bangla.sitestree.com\/?p=79070","url_meta":{"origin":79071,"position":5},"title":"Linux Basics 02 \u2014 Paths, Files, and Links","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Navigate confidently, copy and rename a file, and explain the difference between hard links and symbolic links.","rel":"","context":"In &quot;Linux Basics&quot;","block_context":{"text":"Linux Basics","link":"http:\/\/bangla.sitestree.com\/?cat=1990"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/79071","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=79071"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/79071\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=79071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=79071"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=79071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}