Master Linux Permissions and Python Regex: Key Interview Questions Explained

This article presents two common interview questions—how to modify Linux file permissions using chown, chgrp, and chmod, and the distinction between Python's re.match and re.search functions—along with clear answers and code examples to help candidates prepare effectively.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Linux Permissions and Python Regex: Key Interview Questions Explained

Question 1 – Linux Permissions

How to modify file and directory permissions in Linux?

Use chown [-R] new_owner file to change the owner, chgrp [-R] new_group file to change the group, and chmod [-R] mode file to set permissions. Modes can be expressed symbolically (e.g., rw-r--r--) or numerically (e.g., 644). The -R flag applies changes recursively.

Linux stores permissions in a 16‑bit field; special attributes can be listed with lsattr and set with chattr. Windows uses ACLs, while Unix focuses on permission bits.

Question 2 – Python regex

What is the difference between match() and search() in the re module? re.match(pattern, string[, flags]) checks only at the beginning of string. re.search(pattern, string[, flags]) scans the entire string for the first occurrence.

Examples:

print(re.match('super', 'superstition').span())  # (0, 5)
print(re.match('super', 'insuperable'))          # None
print(re.search('super', 'superstition').span()) # (0, 5)
print(re.search('super', 'insuperable').span()) # (2, 7)

Readers are encouraged to think about the answers before reviewing them.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PythoninterviewPermissionsre module
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.