Manipulating Files on Debian 11 bullseye system - All about it ?

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.

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.

Here at LinuxAPT, we shall look into how to control file content like a pro in Debian 11 system.


Benefits of diff & patch

The diff program has the ability to show the difference between two files. We will demonstrate to you how does it do exactly. Once you have experienced the power of diff, you will realize how powerful your server administration experience will become.

Here, We have already created two files file1 and file2.

We have also added some content to those files. Now, we will run a very important command to see how different these two files are on my Debian 11 server:

$ diff -u file1 file2

From the output, you will see that the diff -u command displayed the contents of both files. It also showed when they were updated and at what time.

We have modified file1 for now, and we will run the command again to see a clear picture of file1 on our server.

Again, run the command and see the changes.

We have added a few more lines and the diff program differentiated that the file1 has some markdown comments as well. It also shows when file1 was modified last time.


More about Patch Utility

Patch helps us to take a patch file, the file which was created by diff and applies the difference to a file. Run the below commands:

$ diff -u file1 file2 > File
$ cat File

You can see that with the help of the patch utility, We patched file1 and file2 into File which is now a patch file.


[Need help in fixing Linux system issues ? We can help you. ]

This article covers an introduction into Using diff and patch in Linux systems. In fact, Both diff and patch programs help a Linux server admin to control their files and make new files when things go wrong.

Related Posts