Command Line Tools

diff command find the difference between files. In this article we would see how diff command can help us in RHCE exam.

Everything in Linux is managed through the several configuration files. During the exam you need to change the setting in several configuration files. You should always take backup before making any change in configuration file during the exam.

You can easily find out the changes which you have made if you have backup copy of configuration file.

Example of diff

We would modify vsftpd.conf file for practice.

ftp use vsftpd.conf configuration file for its setting. RHCE exam objective include ftp so you may have to configure it during the exam.

Create a directory and take backup of vsftpd.conf file

take backup of vsftpd

Start the ftp service

start vsftpd

ftp by default allow anonymous login. Open vsftpd.conf

vi vsftpd

Your task is to disallow anonymous login.

anonymous setting

Change configuration setting so ftp disable anonymous login and save the file

entry vsftpd file

Notice that I made wrong setting. It would stop vsftpd service. Try to restart vsftpd service.

vsftpd error

vsftpd service failed with error. To troubleshoot this we need to check what settings we did in configuration file. Here comes the magic of diff command. With diff command we can easily find the modified settings.

diff

Now we know the modified settings. diff command also tell us the line number of modified settings.

Open vsftpd.conf file again

open vsftpd

Display line number (To display line number use ESC + : + set nu)

set nu

To fix the issue delete line no 13 [contain text sdf] and save the file.

delete line

Now restart the vsftpd service again.

restart vsftpd

Restore the original configuration file back after doing this practice.

restore