Our Feeds

Friday, 2 January 2026

Ajith KP

ZOHO Interview Question - Solution

 ZOHO Interview Question Solution in Java.

CODE

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String input = br.readLine();
            List words = Arrays.asList(input.split(" "));
            Map positional = words.stream()
                    .map(word -> {
                        Pattern p = Pattern.compile("\\d+");
                        Matcher m = p.matcher(word);
                        Integer pos = null;

                        if (m.find()) {
                            pos = Integer.parseInt(m.group());
                        }
                        String text = word.replaceAll("\\d+", "");

                        return new AbstractMap.SimpleEntry<>(pos, text);
                    })
                    .collect(Collectors.toMap(
                            Map.Entry::getKey,
                            Map.Entry::getValue
                    ));

            String result = IntStream.range(0, words.size())
                    .mapToObj(positional::get)
                    .collect(Collectors.joining(" "));

            System.out.println(result);

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

Monday, 29 December 2025

AJITH KP

Understanding Linux File Permissions the Right Way (With Real Examples)

If you work with Linux long enough, you will run into permission issues.
Permission denied is probably the most common error after command not found.


 

In this post, we’ll break down Linux file permissions in a practical, no-nonsense way—using real commands and examples you’ll actually use in production.


1. Why Linux Permissions Matter

Linux is a multi-user operating system. Permissions exist to:

  • Protect system files

  • Prevent accidental deletion or modification

  • Isolate users and services

  • Improve system security

Misconfigured permissions are a common cause of security breaches.


2. The Basic Permission Structure

Run this command:

ls -l

Example output:

-rw-r--r-- 1 root root 4096 Jan 10 10:30 config.conf

Let’s break it down:

-rw-r--r-- │ │ │ │ │ │ │ └─ Others │ │ └──── Group │ └─────── Owner └───────── File type

3. File Types Explained

SymbolMeaning
-Regular file
dDirectory
lSymbolic link
cCharacter device
bBlock device

Example:

drwxr-xr-x 2 user user 4096 folder/

This is a directory (d).


4. Permission Values (r, w, x)

PermissionSymbolValue
Readr4
Writew2
Executex1

Example:

rw- = 6 r-x = 5 r-- = 4

So:

chmod 644 file.txt

Means:

  • Owner → read + write

  • Group → read

  • Others → read


5. Changing Permissions (chmod)

Numeric Mode

chmod 755 script.sh

Result:

  • Owner: rwx

  • Group: r-x

  • Others: r-x

Symbolic Mode

chmod u+x script.sh

Adds execute permission to the owner only.

chmod go-w file.txt

Removes write permission from group and others.


6. Ownership: chown and chgrp

Change Owner

chown user file.txt

Change Owner and Group

chown user:developers file.txt

Recursive Ownership Change (Be Careful!)

chown -R www-data:www-data /var/www/html

⚠️ Never run recursive chown on / or system directories.


7. Directory Permissions – The Common Trap

For directories:

  • r → list files

  • w → create/delete files

  • x → enter the directory

Without x, you cannot access files, even if you have read permission.

Correct permission for web directories:

chmod 755 /var/www/html

8. Special Permissions (Advanced but Important)

SUID (4)

chmod 4755 file

Runs file as file owner (e.g., /usr/bin/passwd).

SGID (2)

chmod 2755 directory

New files inherit group ownership.

Sticky Bit (1)

chmod 1777 /tmp

Users can delete only their own files.


9. Real-World Permission Best Practices

✅ Avoid chmod 777
✅ Use least privilege
✅ Separate users for services (nginx, mysql, etc.)
✅ Audit permissions regularly

Check risky permissions:

find / -perm 777 2>/dev/null

10. Quick Permission Cheat Sheet

CommandPurpose
ls -lView permissions
chmodChange permissions
chownChange ownership
stat fileDetailed file info
getfacl fileACL permissions

Friday, 10 January 2025

AJITH KP

Bubble Sort Tutorial - Algorithm and Code

AJITH KP

Searching Algorithms - Data Structures and Algorithms - Simplified

AJITH KP

Generate ER-Diagram Using pgAdmin 4

Saturday, 19 October 2024

AJITH KP

112. Path Sum - LeetCode Solution

 112. Path Sum - LeetCode Solution in C++.

 


 



/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */
class Solution {
public:
    bool printPath(TreeNode* node, int sum, int targetSum) { 
        if(node == nullptr) return false;
        if(node->left == nullptr && node->right == nullptr) {
            if(sum + node->val == targetSum) {
                return true;
            }
        }
        bool l = printPath(node->left, sum + node->val, targetSum);
        bool r = printPath(node->right, sum + node->val, targetSum);
        return l||r;
    }
    bool hasPathSum(TreeNode* root, int targetSum) {
        if(root == nullptr) return false;
        return printPath(root, 0, targetSum);
    }
};

Thursday, 16 February 2023

AJITH KP

Base64 Encoder Utility Tool - Offline

The Base64 encoder is required for encode the certificates and other files to upload to cloud technologies for create new secrets and configmaps.

The base64 encoder source code is simple GUI tool which can be used to encode the files. 

 

Source Code: https://github.com/ajithkp560/Base64Encoder

Binary File: https://github.com/ajithkp560/Base64Encoder/raw/main/Base64Encoder-1.0.jar