Compare Between 2 or 3 Files/Folders in Ubuntu, Fedora, Debian Linux

For software developers or those who want to compare and merge source files, here’s how in Linux using meld.

1. About Meld:

Meld is a free open-source visual diff and merge tool targeted at developers. It’s a GTK tool written in Python programming language.

The tool supports two- and three-way comparison of files or folders to help review code changes and understand patches. It is also useful for comparing changes captured by version control systems. And, it allows to move content between them, or edit the files manually.

2. Install Meld in Linux:

The app is available to install in most Linux official repositories. Simply open “terminal” from start menu and select one of the commands below to get it.

  • For Debian, Ubuntu, Linux Mint etc, use command:
    sudo apt install meld
  • Fedora and its downstream systems may use command to install it:
    sudo dnf install meld
  • And for Arch, Manjaro Linux based systems, run command:
    sudo pacman -S meld

After installation, search for and open the tool from your system start menu (or activities overview):

3. Compare Files via Meld:

Meld opens comparisons in tabs. It defaults to open a new comparison window. Just choose what you want to do: compare files, folders, or view version control, then choose files/folders, and finally click “Compare”.

Meld default app window

For file comparison, it will highlight the differences with background color. To strip out those are not important (e.g., comment), your may use Text Filters available in “Preferences” settings.

By clicking on the “lock” icon, it allows to edit the file. And, the “down arrow” button right after the lock will be clickable to save the file once you change anything.

Meld displays differences in segments. Each segment is a group of lines which correspond between files. By clicking on “Changes” menu, it offers options to switch between these segments, as well as push, pull, move and delete actions.

Meld File Compare

4. Folder Compare via Meld:

When comparing folders, it shows contained files in different colors. Files with normal color are identical, while those in blue are different across folders. And, files in green exist in this folder but not in the others (grayed out with strikethrough).

For issues caused by file permission and/or filename encoding error, they will display in bright red with a yellow background. And, files become identical only when Text Filters applied will be italics.

And, it provides tool bar options to show identical files, compare/delete selected file, and some other actions.

Meld Folder Compare

5. Version Control Compare:

Meld also support a wide range of version control systems, including Bazaar, Darcs, Git, Mercurial, and SVN. It shows the differences between the contents of your local folder and the current repository version.

Each file or folder in a version control comparison has a state. The normal font means the file/folder is the same as the repository version. While, red and bold files are different to the repository version.

File and folder in Green is new and scheduled to be added to the repository. And red bold with strikethrough exists but scheduled to be removed from the repository. As well, there are conflicted in bright red, missing file in blue with strikethrough, ignored with grayed out text, and error with same font to folder compare.

For more about using the tool, you may press F1 on keyboard to get the help dialog.

Hi, I'm Merilyn Ne, a computer geek working on Ubuntu Linux for many years and would like to write useful tips for beginners. Forgive me for language mistakes. I'm not a native speaker of English.