Sunday, August 3, 2025

Linux Link

ln command by default creates a hard link which is a file that share the same inode as the original file it links to.

Soft link (symbolic link) is a newer link type that addresses some disadvantage of hard link.  It can link to a directory.  It can like to entry in another file system.  It can link to an entry that does not exist currently (e.g. a file that is created from time to time).

When cd to a directory using symlink, the shell builtin pwd will display the name of the symlink that link to but /bin/pwd (utility) will display the destingation directory.  When you cd to .. it will return to the directory that holding the symlink.

Linux file and directory permissions

 To execute shell script, you mean r+x to the script file.  To execute a binary, you just need x.

The "+" after the permission indicated if the file has an ACL

Numbers to represent rwx is 1/2/4.  Or (add) the number to create composite permissions.  For example, 700 means 1+2+4 for owner and 0 for group/other.

Setuid/setgid change the permission x to s in the listing.  Set these permissions by specifying a 4th digit.  For example. 2700 or 4700 sets the setgid or setuid respectively.  "1" is to set the sticky bit to the program.

Kernel will not execute a script with setuid/setgid on.

Execute permission in directory indicated if the user can cd into the directory and access file that he has been permitted to.  If user has x but no r for a directory, he cannot display the directory file content (i.e. list of files in directory) using ls command.

Using ACL has overhead and should not enable ACL on system directory and files.  Not all file utility preserve ACL by default.  Destination filesystem may or may not support ACL.  In addition, the filesystem must be mounted with ACL enabled (default no ACL). 

ACL grant access to other user or group beside the owner's.  Beside ugo. ACL has a role called "mask" which specified the effective (maximum) permission ACL permitted for the directory or file.  Any ACL specified more than mask's will not be effective (i.e. denied).  Mask is usually set to the max permission allowed and individual ACL rule is more restrictive than mask's.

Registry tools

REGEDIT is a GUI tool to see and manipulate registry entries. 

REG.EXE is a CLI tool

REGINI is a CLI that can use a text file containing REG commands as input 

POWERSHELL has command to manipulate registry


.reg file

This is an exported registry file in text format. It is not the registry file itself. Content can be import into the registry. 

KHLM subkeys

SAM AND SECURITY

the former contains info that used to connect the pc to the domains it entitled to, including the local domain. The latter contains the security policy download from connected domain

SYSTEM

contain windows config, drives connected and file system info

SOFTWARE

contains info for windows installation and softwares installed. It is organised by vendor 

Registry structure

The registry is organized into 5 groups or sections. 

HKCR (class root) section keep info about registered software, OLE object class id and file associations

HKCU (current user) contains config options for the currently signed-in user like disvknlocation of the user folders, control panel settings and app config settings. 

HKLM (local machine) contains setting for the pc. It co tains the sub key files - SAM, security? System and software. Another file Hardware is created each time the pc starts containing detected plug and play hardware. This key also contain the files Components and BCD which contain boot configuration data. 

HKU (user) contain settings and options for the currently sign in user.

HKCC (current config) contains info gathered for the current session and will be discarded when season ends. 

HKEY_PERFORMANCE_DATA is not visible to Reddit. It contains performance data of the current session. It is discarded when the session ends

Saturday, August 2, 2025

Windows registry

First introduced in windows 95, registry is to consolidate ini files in windows 3.1. There are 5 main registry files residing in ststem32\config directory. 

SAM security access manager

Security

Software

System

User diff (used for OS upgrade)

Each user has its own registry files as well in the %userprifile% directory. They are 

ntuser.dat contain customisation for software and UsrClass.dat contains com related info specific to the user. 

Registry is managed by configuration manager in kernel. It has journaling to protect from corruption.