{"id":16751,"date":"2022-04-22T19:56:46","date_gmt":"2022-04-22T19:56:46","guid":{"rendered":"https:\/\/linuxways.net\/?p=16751"},"modified":"2022-04-22T19:56:46","modified_gmt":"2022-04-22T19:56:46","slug":"how-to-manipulate-files-on-debian-11","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/debian\/how-to-manipulate-files-on-debian-11\/","title":{"rendered":"How to Manipulate Files on Debian 11"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>In this article, we are going to learn how to control file content like a pro in Debian 11 Servers. These commands and instructions are valid for all Linux distributions which have an APT packaging system. I am using Debian 11 Edition to discuss the nature of file manipulation in Linux. Not only everything discussed in this article applies to servers, but also they are helpful for desktop use.<\/p>\n<h2>File Manipulation on CLI<\/h2>\n<p>When it comes to Linux servers, system admins rarely use any graphical user interface. A simple command-line interface also known as CLI is enough for them to get what they are intended to do.<\/p>\n<p>CLI has several advantages, but it also comes with its disadvantages. Beginners with limited knowledge get into trouble and are often seen breaking their servers. This article will walk you through file management, and I believe it will take your skills to next level.<\/p>\n<h2>Advantages of diff &amp; patch<\/h2>\n<p>The <strong>diff<\/strong> program has the ability to show the difference between two files. I will demonstrate to you how does it do exactly. Once you have experienced the power of <strong>diff<\/strong>, you will realize how powerful your server administration experience will become.<\/p>\n<p>In our case, I have already created two files <strong>file1<\/strong> and <strong>file2<\/strong>.<\/p>\n<p>I have also added some content to those files. I will run a very important command to see how different these two files are on my Debian 11 server.<\/p>\n<pre><strong>$ diff -u file1 file2<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"481\" height=\"139\" class=\"wp-image-16752\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-188.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-188.png 481w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-188-300x87.png 300w\" sizes=\"auto, (max-width: 481px) 100vw, 481px\" \/><\/p>\n<p>As you can observe, the <strong>diff -u<\/strong> command displayed the contents of both files. It also showed when they were updated and at what time.<\/p>\n<p>I have modified <strong>file1<\/strong> for now, and we will run the command again to see a clear picture of file1 on our server.<\/p>\n<p><strong>Let\u2019s run the command again and see the changes.<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"512\" height=\"244\" class=\"wp-image-16753\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-189.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-189.png 512w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-189-300x143.png 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/p>\n<p>There you go!<\/p>\n<p>We have added a few more lines and the <strong>diff<\/strong> program differentiated that the <strong>file1<\/strong> has some markdown comments as well. It also shows when <strong>file1<\/strong> was modified last time.<\/p>\n<h2>Patch Utility<\/h2>\n<p>Our next utility is <strong>patch<\/strong>. It helps us to take a patch file, the file which was created by <strong>diff<\/strong> and applies the difference to a file. Let\u2019s do it now:<\/p>\n<pre><strong>$ diff -u file1 file2 &gt; File<\/strong><\/pre>\n<pre><strong>$ cat File<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"501\" height=\"240\" class=\"wp-image-16754\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-190.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-190.png 501w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-190-300x144.png 300w\" sizes=\"auto, (max-width: 501px) 100vw, 501px\" \/><\/p>\n<p>You can see that with the help of the <strong>patch<\/strong> utility, I patched <strong>file1<\/strong> and <strong>file2<\/strong> into <strong>File<\/strong> which is now a <strong>patch file<\/strong>.<\/p>\n<h2>Conclusion<\/h2>\n<p>Both <strong>diff<\/strong> and <strong>patch<\/strong> programs help a Linux server admin to control their files and make new files when things go wrong. A beginner must continue to explore how things work on Linux servers or even on desktops. In case your desktop Linux system does not boot into a graphical user interface then you can use these instructions using the command-line interface. This will help you to take back control of your system and easily solve complex issues.<\/p>","protected":false},"excerpt":{"rendered":"<p>Introduction In this article, we are going to learn how to control file content like a pro in Debian 11 Servers. These commands and instructions are valid for&hellip;<\/p>","protected":false},"author":1,"featured_media":16797,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[521,135],"class_list":["post-16751","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-debian","tag-debian-11","tag-files-2"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/16751","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=16751"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/16751\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/16797"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=16751"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=16751"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=16751"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}