Monday, March 17, 2025

How to Use the patch Command in Linux

 The patch command in Linux is a powerful tool used to apply changes to files based on differences (diffs) between file versions. It's commonly used in software development to update source code files. In this blog post, we'll explore how to use the patch command with practical examples.

Understanding the patch Command

The patch command takes a patch file (which contains differences between files) and applies those changes to the original file. The patch file is usually created using the diff command.

Basic Syntax

patch [options] [originalfile] [patchfile]
  • originalfile: The file to be patched.
  • patchfile: The file containing the differences.

Creating a Patch File

Before we can use the patch command, we need a patch file. Let's create one using the diff command.

Example: Creating a Patch File

Suppose we have two files, file1.txt and file2.txt, and we want to create a patch file that contains the differences between them.

diff -u file1.txt file2.txt > changes.patch

This command generates a unified diff and saves it to changes.patch.

Applying a Patch

Now that we have our patch file, let's apply it using the patch command.

Example: Applying a Patch

patch file1.txt < changes.patch

This command applies the changes from changes.patch to file1.txt.

Common Options

The patch command has several options that can be useful:

  • -pNUM: Strip NUM leading components from file names.
  • -R: Reverse the patch (undo changes).
  • --dry-run: Test the patch without applying changes.

Example: Using Options

patch -p1 file1.txt < changes.patch

This command strips one leading component from file names before applying the patch.

Handling Rejected Patches

Sometimes, patches may not apply cleanly, resulting in rejected patches. These are saved in .rej files.

Example: Handling Rejected Patches

patch file1.txt < changes.patch

If there are rejected patches, they will be saved in file1.txt.rej. You can manually review and apply these changes.

Thursday, March 6, 2025

Information about National Pension System



Understanding the National Pension System (NPS) in India

The National Pension System (NPS) is a government-sponsored pension scheme launched in January 2004. It was initially introduced for government employees but was later extended to all Indian citizens in 2009. The NPS aims to provide a sustainable solution for retirement planning by encouraging individuals to save systematically during their working years.

Key Features of NPS

  1. Voluntary Participation: NPS is open to all Indian citizens aged between 18 and 65. Participation is voluntary, allowing individuals to join and contribute according to their financial capacity.

  2. Flexible Contributions: Subscribers can decide how much they want to contribute and when. There is no fixed amount or frequency, making it a flexible option for retirement savings.

  3. Tax Benefits: Contributions to NPS are eligible for tax deductions under Section 80C and Section 80CCD of the Income Tax Act. This makes NPS an attractive option for tax planning.

  4. Investment Options: NPS offers a variety of investment options, including equity, corporate bonds, and government securities. Subscribers can choose their preferred investment mix based on their risk appetite.

  5. Professional Management: The funds in NPS are managed by professional pension fund managers appointed by the Pension Fund Regulatory and Development Authority (PFRDA). This ensures that the investments are handled efficiently and transparently.

  6. Portability: NPS accounts are portable across jobs and locations. This means that subscribers can continue their contributions even if they change jobs or move to a different city.

How NPS Works

When you join NPS, you open an individual pension account known as a Permanent Retirement Account Number (PRAN). There are two types of accounts under NPS:
  1. Tier I Account: This is the primary pension account with restrictions on withdrawals. It is mandatory to open a Tier I account to join NPS. Contributions to this account are eligible for tax benefits.

  2. Tier II Account: This is a voluntary savings account with no withdrawal restrictions. However, contributions to the Tier II account do not qualify for tax benefits.

Withdrawal and Annuity

Upon reaching the age of 60, subscribers can withdraw up to 60% of the accumulated corpus as a lump sum. The remaining 40% must be used to purchase an annuity, which provides a regular pension income. In case of early exit before the age of 60, 80% of the corpus must be used to purchase an annuity, and the remaining 20% can be withdrawn as a lump sum.

 

For more information see youtube video by LLA advisor:  https://www.youtube.com/watch?v=jSF9kdYjiYY