If windows auto-configured IP was difficult to remove

Your screenshot confirms:

IPv4 Address: 192.168.55.20 (Duplicate)
Autoconfiguration IPv4 Address: 169.254.245.211

So Windows is still rejecting 192.168.55.20. Use a different member-server IP, such as:

192.168.55.21

Run these on MEM01/member VM as Administrator.

1. Remove the bad duplicate IP

Get-NetIPAddress -InterfaceAlias "Ethernet" -AddressFamily IPv4 |
Where-Object { $_.IPAddress -like "192.168.55.*" } |
Remove-NetIPAddress -Confirm:$false

2. Restart the adapter

Restart-NetAdapter -Name "Ethernet"

3. Assign a new IP

New-NetIPAddress `
-InterfaceAlias "Ethernet" `
-IPAddress 192.168.55.21 `
-PrefixLength 24

Do not add a default gateway for host-only network.

4. Set DNS to the Domain Controller

Set-DnsClientServerAddress `
-InterfaceAlias "Ethernet" `
-ServerAddresses 192.168.55.10

5. Verify

ipconfig /all

You want:

IPv4 Address: 192.168.55.21
Subnet Mask: 255.255.255.0
DNS Servers: 192.168.55.10

No (Duplicate).

6. Test

ping 192.168.55.10
Resolve-DnsName powershell.local -Server 192.168.55.10

Your final setup becomes:

Windows 11 host: 192.168.55.1
DC01:            192.168.55.10
MEM01:           192.168.55.21

Also make sure no other VM is running with 192.168.55.20. The duplicate message usually means another machine already has that IP, or the clone/network adapter still has a conflict.

REF: AI Tools/ChatGPT

Check if DNS is working

On the Domain Controller

DNS should be installed and running:

Get-WindowsFeature DNS

Check DNS service:

Get-Service DNS

Check DNS zones:

Get-DnsServerZone

The DC should usually point DNS to itself:

Set-DnsClientServerAddress -InterfaceAlias “Ethernet” -ServerAddresses 127.0.0.1

or sometimes to its own IP:

Set-DnsClientServerAddress -InterfaceAlias “Ethernet” -ServerAddresses 192.168.56.10

On the Windows client

The client DNS must point to the Domain Controller IP, not Google DNS or router DNS:

Set-DnsClientServerAddress -InterfaceAlias “Ethernet” -ServerAddresses 192.168.56.10

Then test:

Resolve-DnsName powershell.local

Test-Connection 192.168.56.10

Test-NetConnection 192.168.56.10 -Port 53

Client Side

Set-DnsClientServerAddress -InterfaceAlias “Ethernet 14” -ServerAddresses 192.168.56.10

Q & A: Linux: Switch Users, Boot Process, File System

Quiz: Root Access, Boot Process, File Systems, Partitions, and Mounting

1. True/False

The root user is the superuser account and has the highest access rights on a Linux system.

Answer: True


2. True/False

It is recommended to stay logged in as root for normal daily work because it is faster.

Answer: False
Explanation: Staying logged in as root is risky because mistakes may affect the entire system.


3. Multiple Choice

Which command is preferred when you need to run one privileged command?

A. su -
B. sudo command
C. exit
D. whoami

Answer: B. sudo command


4. Multiple Choice

What does the command below do?

su -

A. Runs one command as root
B. Opens a login shell as root
C. Shows the current user
D. Lists mounted filesystems

Answer: B. Opens a login shell as root


5. Multiple Choice

Which process is usually started by the kernel as the first userspace process?

A. GRUB
B. BIOS
C. systemd or init
D. fdisk

Answer: C. systemd or init


6. Multiple Choice

Which systemd target usually represents a non-graphical multi-user system?

A. poweroff.target
B. rescue.target
C. multi-user.target
D. graphical.target

Answer: C. multi-user.target


7. Multi-Select

Which of the following are risks of using the root account directly?

Select all that apply.

A. Accidental system-wide file changes
B. Running ordinary tasks with unnecessary privileges
C. Forgetting that you are logged in as root
D. More accountability than sudo
E. Background processes may run with root privilege

Answers: A, B, C, E


8. Multi-Select

Which commands are commonly part of the basic partition, format, mount, and verify workflow?

Select all that apply.

A. lsblk
B. fdisk
C. mkfs
D. mount
E. df -h
F. passwd

Answers: A, B, C, D, E


9. Multi-Select

Which statements about filesystems are correct?

Select all that apply.

A. A filesystem organizes data and metadata on storage
B. Journaling can reduce recovery time after an unclean shutdown
C. ext4 is commonly used on many Linux distributions
D. FAT is a modern Linux-native journaling filesystem
E. NTFS is associated with Microsoft Windows

Answers: A, B, C, E


10. Fill in the Blank with Choices

A filesystem defines how __________ and metadata are organized and accessed on a storage device.

A. users
B. data
C. passwords
D. targets

Answer: B. data


11. Fill in the Blank with Choices

The Linux filesystem table is stored in the file __________.

A. /etc/passwd
B. /etc/fstab
C. /boot/grub
D. /var/log

Answer: B. /etc/fstab


12. Fill in the Blank with Choices

On modern systems, __________ is normally preferred over MBR for large disks unless compatibility requires MBR.

A. FAT
B. GPT
C. ext2
D. BIOS

Answer: B. GPT


13. Matching

Match each FHS directory with its purpose.

DirectoryPurpose
1. /etcA. User home directories
2. /varB. Device files
3. /homeC. System-wide configuration files
4. /devD. Logs and changing data
5. /bootE. Boot loader files and kernels

Answer:

DirectoryCorrect Purpose
/etcC
/varD
/homeA
/devB
/bootE

14. Matching

Match each command with its purpose.

CommandPurpose
1. lsblkA. Format a partition with a filesystem
2. fdiskB. Show block devices
3. mkfsC. Modify partition tables
4. mountD. Attach a filesystem to the Linux directory tree
5. umountE. Detach a mounted filesystem

Answer:

CommandCorrect Purpose
lsblkB
fdiskC
mkfsA
mountD
umountE

15. Ordering

Put the boot stages in the correct order.

A. Kernel starts init/systemd
B. BIOS/UEFI starts
C. GRUB loads the selected kernel
D. System reaches target/services
E. MBR or boot loader code begins the boot manager stage

Correct Order:

  1. B
  2. E
  3. C
  4. A
  5. D

16. Ordering

Put the storage setup steps in the correct order.

A. Format the partition with mkfs
B. Identify the disk with lsblk
C. Mount the filesystem
D. Create a partition using fdisk
E. Verify using df -h

Correct Order:

  1. B
  2. D
  3. A
  4. C
  5. E

17. Short Answer

Explain the difference between sudo and su -.

Sample Answer:
sudo runs a single command with elevated privileges and logs the action. su - opens a new login shell as another user, usually root if no username is provided. sudo is safer for one administrative task, while su - is used when a full shell as another user is needed.


18. Hands-on Short Answer

Write commands to format /dev/sdb1 as ext4, create /mnt/test, mount the partition, and verify it.

Sample Answer:

sudo mkfs -t ext4 /dev/sdb1
sudo mkdir -p /mnt/test
sudo mount -t ext4 /dev/sdb1 /mnt/test
df -h

19. Analytical Short Answer

Why is /dev/sdb commonly used with fdisk, but /dev/sdb1 is commonly used with mkfs?

Sample Answer:
/dev/sdb represents the whole disk, so fdisk uses it to create or modify the disk’s partition table. /dev/sdb1 represents a specific partition, so mkfs formats that partition with a filesystem.


20. Higher-Order Short Answer

A server should automatically mount a new ext4 partition after every reboot. Which file should be configured, and what information does it need?

Sample Answer:
The file /etc/fstab should be configured. It needs the filesystem or UUID, mount point, filesystem type, mount options, dump value, and filesystem check pass value. Example pattern:

UUID=... /mnt/data ext4 defaults 0 2

This allows the system to mount the filesystem automatically during boot.

REF: AI Tools/ChatGPT

Special Permissions: SUID, SGID, sticky bit

Linux Special Permissions: SUID, SGID, and Sticky Bit

Linux normally uses three permission groups:

u = user/owner
g = group
o = others

And three basic permissions:

r = read
w = write
x = execute

Example:

ls -l file.txt

Output:

-rwxr-xr--

But Linux also has special permissions:

SUID       = user +s
SGID       = group +s
Sticky Bit = others +t

They appear in ls -l output as:

s, S, t, or T

1. SUID — Set User ID

Meaning

SUID means:

When an executable file runs, it runs with the permission of the file owner, not the user who started it.

SUID is mainly useful on executable programs, not normal text files.

Set SUID

chmod u+s filename

Numeric form:

chmod 4755 filename

The 4 means SUID.

Remove SUID

chmod u-s filename

Example: /usr/bin/passwd

The passwd command lets a normal user change their own password.

ls -l /usr/bin/passwd

Possible output:

-rwsr-xr-x 1 root root ... /usr/bin/passwd

Notice:

rws

The s appears in the user execute position.

Normal owner permission would be:

rwx

With SUID, it becomes:

rws

Because /usr/bin/passwd is owned by root, when a normal user runs:

passwd

the program temporarily runs with the file owner’s privilege, which is root, but only for the controlled task of changing the password.


SUID: lowercase s vs uppercase S

This is very important.

Lowercase s

Lowercase s means:

SUID is set AND owner execute permission exists.

Example:

touch demo
chmod 755 demo
chmod u+s demo
ls -l demo

Output:

-rwsr-xr-x 1 user user ... demo

Here:

rws

means:

owner has read + write + execute
SUID is also set

Uppercase S

Uppercase S means:

SUID is set BUT owner execute permission is missing.

Example:

touch demo
chmod 644 demo
chmod u+s demo
ls -l demo

Output:

-rwSr--r-- 1 user user ... demo

Here:

rwS

means:

SUID is set
but owner execute permission is missing

So uppercase S usually means the special permission is set, but it is not useful for execution because x is missing.


2. SGID — Set Group ID

Meaning on files

SGID on an executable file means:

When the file runs, it runs with the permission of the file’s group owner.

Meaning on directories

SGID is especially useful on directories.

On a directory, SGID means:

New files and subdirectories created inside the directory inherit the directory’s group ownership.

This is very useful for shared project folders.


Set SGID

chmod g+s filename_or_directory

Numeric form:

chmod 2755 filename_or_directory

The 2 means SGID.

Remove SGID

chmod g-s filename_or_directory

Example: Shared project directory

Suppose we have a group named developers.

sudo mkdir /project
sudo chgrp developers /project
sudo chmod 2775 /project

Check:

ls -ld /project

Possible output:

drwxrwsr-x 2 root developers ... /project

Notice the group part:

rws

That means:

group has read + write + execute
SGID is set

Now when a user creates a file inside /project, the file can inherit the directory’s group:

touch /project/app.txt
ls -l /project/app.txt

Possible output:

-rw-r--r-- 1 alice developers ... app.txt

Even if Alice’s normal primary group is different, the file is created with the developers group because the parent directory has SGID.


SGID: lowercase s vs uppercase S

Lowercase s

Lowercase s means:

SGID is set AND group execute permission exists.

Example:

mkdir shared
chmod 775 shared
chmod g+s shared
ls -ld shared

Output:

drwxrwsr-x 2 user user ... shared

The group permission part is:

rws

This means SGID is set and the group can enter/search the directory.

Uppercase S

Uppercase S means:

SGID is set BUT group execute permission is missing.

Example:

mkdir shared
chmod 764 shared
chmod g+s shared
ls -ld shared

Output:

drwxrwSr-- 2 user user ... shared

The group permission part is:

rwS

This means SGID is set, but group execute is missing.

For a directory, this is usually a problem because group members need x permission to enter or access items inside the directory.


3. Sticky Bit

Meaning

The Sticky Bit is mostly used on directories.

It means:

Users can create files in the directory, but they can delete only their own files.

This is useful for shared writable directories.


Set Sticky Bit

chmod o+t directory

Numeric form:

chmod 1777 directory

The 1 means Sticky Bit.

Remove Sticky Bit

chmod o-t directory

Example: /tmp

The /tmp directory is shared by many users and programs.

ls -ld /tmp

Possible output:

drwxrwxrwt 10 root root ... /tmp

Notice the last character:

t

That means Sticky Bit is set.

The directory is writable by many users, but one user cannot delete another user’s files.


Example: Create a shared temporary directory

sudo mkdir /sharedtmp
sudo chmod 1777 /sharedtmp
ls -ld /sharedtmp

Output:

drwxrwxrwt 2 root root ... /sharedtmp

Now different users can create files inside /sharedtmp, but they cannot delete files owned by other users.


Sticky Bit: lowercase t vs uppercase T

Sticky Bit uses t or T, not s or S.

Lowercase t

Lowercase t means:

Sticky Bit is set AND others execute permission exists.

Example:

mkdir sharedtmp
chmod 777 sharedtmp
chmod o+t sharedtmp
ls -ld sharedtmp

Output:

drwxrwxrwt 2 user user ... sharedtmp

The others permission part is:

rwt

This means:

others have read + write + execute
Sticky Bit is set

Uppercase T

Uppercase T means:

Sticky Bit is set BUT others execute permission is missing.

Example:

mkdir sharedtmp
chmod 776 sharedtmp
chmod o+t sharedtmp
ls -ld sharedtmp

Output:

drwxrwxrwT 2 user user ... sharedtmp

The others permission part is:

rwT

This means Sticky Bit is set, but others do not have execute permission.

For a directory, this usually means others cannot properly enter or access the directory.


Quick Summary of s, S, t, and T

SymbolLocation in ls -lMeaning
suser execute positionSUID set and user execute exists
Suser execute positionSUID set but user execute missing
sgroup execute positionSGID set and group execute exists
Sgroup execute positionSGID set but group execute missing
tothers execute positionSticky Bit set and others execute exists
Tothers execute positionSticky Bit set but others execute missing

Visual Examples

Normal executable file

-rwxr-xr-x

Owner has execute permission.

SUID with execute

-rwsr-xr-x

SUID is active and owner execute exists.

SUID without execute

-rwSr-xr-x

SUID is set, but owner execute is missing.


Normal group-executable directory

drwxrwxr-x

Group has execute permission.

SGID directory with execute

drwxrwsr-x

SGID is active and group execute exists.

SGID directory without group execute

drwxrwSr-x

SGID is set, but group execute is missing.


Sticky Bit directory with others execute

drwxrwxrwt

Sticky Bit is active and others execute exists.

Sticky Bit directory without others execute

drwxrwxrwT

Sticky Bit is set, but others execute is missing.


Numeric Permission Summary

Special permissions are added before the normal three permission digits.

PermissionNumeric valueExample
SUID4chmod 4755 program
SGID2chmod 2775 shareddir
Sticky Bit1chmod 1777 sharedtmp

Examples:

chmod 4755 program      # SUID + rwxr-xr-x
chmod 2755 directory    # SGID + rwxr-xr-x
chmod 1777 directory    # Sticky Bit + rwxrwxrwx

You can also combine them:

chmod 6755 program

Here:

6 = 4 + 2

So 6755 means:

SUID + SGID + rwxr-xr-x

Command Summary

Set SUID:

chmod u+s program

Remove SUID:

chmod u-s program

Set SGID:

chmod g+s directory

Remove SGID:

chmod g-s directory

Set Sticky Bit:

chmod o+t directory

Remove Sticky Bit:

chmod o-t directory

Check permissions:

ls -l filename
ls -ld directory

Practical Use Cases

SUID use case

Used when a normal user needs to run a specific program with the file owner’s privileges.

Common example:

ls -l /usr/bin/passwd

Possible output:

-rwsr-xr-x 1 root root ... /usr/bin/passwd

This allows users to change their passwords safely without giving them full root access.


SGID use case

Used for shared team directories.

Example:

sudo mkdir /team
sudo chgrp developers /team
sudo chmod 2775 /team

Result:

drwxrwsr-x root developers /team

Files created inside /team inherit the developers group.


Sticky Bit use case

Used for shared writable directories where users should not delete each other’s files.

Example:

sudo mkdir /publicdrop
sudo chmod 1777 /publicdrop

Result:

drwxrwxrwt root root /publicdrop

Users can create files, but they cannot delete other users’ files.


Final Blog Summary

SUID: Run an executable as the file owner.
SGID: Run an executable as the file group, or make files inherit a directory group.
Sticky Bit: In shared directories, users can delete only their own files.

The lowercase letters mean the related execute permission is present:

s = SUID/SGID + execute
t = Sticky Bit + execute

The uppercase letters mean the special permission is set, but execute is missing:

S = SUID/SGID set, execute missing
T = Sticky Bit set, execute missing

For practical use, lowercase s and t are usually what you expect to see. Uppercase S or T often indicates a permission setup that should be reviewed.

REF: AI Tools/ChatGPT

Why? Max permissions on a file: 666? what if I give 777?

When people say:

Max permissions on a file: 666

they usually mean default maximum permissions when a new regular file is created, not the maximum you can manually set.

1. Default maximum for new files: 666

For a new regular file, Linux normally starts from:

666 = rw-rw-rw-

That means:

owner  = read + write
group  = read + write
others = read + write

No execute permission by default.

Why? Because most new files are text files, data files, documents, config files, etc. They should not automatically be executable.

Example:

touch file1.txt
ls -l file1.txt

You may see something like:

-rw-r--r-- 1 user user file1.txt

The actual permission is affected by the umask.


2. Default maximum for directories: 777

For a new directory, Linux normally starts from:

777 = rwxrwxrwx

Why? Because directories need x permission to be entered or searched.

Example:

mkdir dir1
ls -ld dir1

You may see:

drwxr-xr-x 2 user user dir1

Again, the final permission is affected by the umask.


3. What if I give a file 777?

You can manually give a file 777:

chmod 777 file1.txt
ls -l file1.txt

Output:

-rwxrwxrwx 1 user user file1.txt

This means:

owner  = read + write + execute
group  = read + write + execute
others = read + write + execute

So everyone can read, modify, and execute the file.


4. Is 777 allowed?

Yes, it is allowed.

But it is usually not safe.

For a regular file, 777 means any user can change the file and possibly run it as a program or script.

For example, this is risky:

chmod 777 script.sh

because any user may be able to modify the script and then execute it.


5. Better permissions

For a normal text/config/data file:

chmod 644 file.txt

Meaning:

owner can read/write
group can read
others can read

For a private file:

chmod 600 file.txt

For a script that only the owner should run:

chmod 700 script.sh

For a script others can read and execute but not modify:

chmod 755 script.sh

Simple summary

666 = normal maximum default for new files
777 = normal maximum default for new directories
777 on a file is possible, but usually unsafe

Slide-friendly version:

Linux does not give execute permission to new regular files by default. New files start from a maximum of 666, while directories start from 777 because directories need execute permission to be entered. A file can be changed to 777 manually, but this gives everyone read, write, and execute access, which is usually insecure.

REF: AI Tools/ChatGPT

Define and describe Selinux in general terms

SELinux stands for Security-Enhanced Linux.

It is a Linux security system that adds an extra layer of protection to the operating system. It controls what users, programs, services, and processes are allowed to do.

A simple definition:

SELinux is a security feature in Linux that enforces strict rules about which processes can access which files, directories, ports, and system resources.

General idea

Normal Linux permissions ask:

Does this user have permission to access this file?

SELinux asks an additional question:

Is this process allowed by security policy to access this object?

So even if normal file permissions allow access, SELinux can still block it.

Example

Suppose Apache web server tries to read:

/var/www/html/index.html

Normal permissions may allow it:

-rw-r--r--

But SELinux also checks the file’s security label. If the file has the wrong SELinux label, Apache may be denied access.

Example command:

ls -Z /var/www/html/index.html

This shows SELinux security context labels.

Why SELinux is useful

SELinux helps protect the system if a service is misconfigured or compromised.

For example, if a web server is attacked, SELinux can limit what the web server process is allowed to access. The attacker may control the web server process, but SELinux can still prevent it from reading unrelated system files.

Common SELinux modes

getenforce

Possible outputs:

Enforcing
Permissive
Disabled
ModeMeaning
EnforcingSELinux policy is active and blocks unauthorized actions
PermissiveSELinux does not block, but logs warnings
DisabledSELinux is turned off

Slide-friendly summary

SELinux is a mandatory access control system for Linux. It uses security policies and labels to control what processes can access. It provides extra protection beyond normal Linux permissions.

REF: AI Tools/ChatGPT

Linux: setfacl remove a user completely

To remove a specific user completely from ACL permissions, use setfacl -x.

Remove a user ACL from a file

setfacl -x u:username filename

Example:

setfacl -x u:john report.txt

Check:

getfacl report.txt

Remove a user ACL from a directory

setfacl -x u:username directoryname

Example:

setfacl -x u:john projectdir

If the directory has default ACLs too

For directories, a user may have:

  1. Access ACL — applies to the directory itself
  2. Default ACL — automatically inherited by new files/subdirectories created inside

Remove both:

setfacl -x u:john projectdir
setfacl -x d:u:john projectdir

Or in one command:

setfacl -x u:john,d:u:john projectdir

Remove user ACL recursively

To remove that user from a directory and everything inside it:

setfacl -R -x u:john projectdir

To remove both access ACL and default ACL recursively:

setfacl -R -x u:john,d:u:john projectdir

Important note

This removes the user from the ACL, but it does not delete the Linux user account.

Also, if that user is the owner of the file, removing ACL will not remove owner permissions. You would need chown or chmod for that.

Example:

chown otheruser report.txt
chmod 640 report.txt

Remove all ACL entries from a file

To remove all extended ACLs, not just one user:

setfacl -b filename

Example:

setfacl -b report.txt

Use this carefully because it removes all extra ACL users/groups.

REF: AI Tools/ChatGPT

Linux: Regular Permissions (symbolic/numeric) vs ACL

Linux has two main permission layers:

1. Traditional permissions: user / group / others  (UGO)
2. ACL permissions: extra permission rules for specific users/groups

1. Traditional UGO permissions

UGO means:

u = user owner
g = group owner
o = others

Example:

chmod ugo+x script.sh

means:

Give execute permission to user, group, and others.

Another example:

chmod 777 file.txt

means:

Owner  = read + write + execute
Group  = read + write + execute
Others = read + write + execute

So 777 is very broad. It gives everyone full access.

r = 4
w = 2
x = 1

7 = 4 + 2 + 1 = rwx

So:

777 = rwxrwxrwx

This is usually not safe, especially for shared systems.


2. ACL permissions

ACL means Access Control List.

ACL lets you give permission to specific extra users or groups, without changing the main owner/group/others permissions.

Example:

setfacl -m u:john:rwx project.txt

This gives user john read, write, and execute permission on project.txt.

Check ACL:

getfacl project.txt

Remove John’s ACL:

setfacl -x u:john project.txt

Main difference

FeatureUGO / chmodACL / setfacl
Basic permission systemYesExtended permission system
Controls owner, group, othersYesYes, but with extra rules
Give permission to one specific extra userLimitedYes
Good for simple permissionsYesYes
Good for complex/shared accessNot idealBetter
Examplechmod 755 filesetfacl -m u:john:rwx file

Example situation

Suppose you have this file:

ls -l report.txt

Output:

-rw------- 1 sayed sayed report.txt

Only sayed can read and write.

Now you want only john to also read it.

Bad approach:

chmod 777 report.txt

This gives everyone full access.

Better approach:

setfacl -m u:john:r report.txt

This gives only John read permission.


Simple summary

chmod / UGO = basic permissions for owner, group, and everyone else.
ACL = extra detailed permissions for specific users or groups.

Use chmod 777 only in rare testing situations. For real systems, ACL is safer when you want to give access to one specific user or group.

REF: AI Tools/ChatGPT

Linux: ACL vs Selinux

ACL vs SELinux

ACL and SELinux both control access, but they work at different levels.

FeatureACLSELinux
Full nameAccess Control ListSecurity-Enhanced Linux
Main purposeGive extra file permissions to specific users/groupsEnforce system-wide security policy
Access modelDAC: Discretionary Access ControlMAC: Mandatory Access Control
Controlled byFile owner/rootSELinux policy/root
Works onFiles/directoriesFiles, processes, ports, services, users
Common commandsgetfacl, setfaclgetenforce, ls -Z, semanage, restorecon

Simple explanation

ACL

ACL is like saying:

“This specific user or group can access this file/directory.”

Example:

setfacl -m u:john:rwx projectdir

This gives user john read, write, and execute permission on projectdir.

Check ACL:

getfacl projectdir

ACL extends normal Linux permissions:

owner / group / others

So ACL is mainly about who can access a file or directory.


SELinux

SELinux is like saying:

“Even if Linux permissions allow this, the system security policy must also allow it.”

Example:

ls -Z /var/www/html

You may see SELinux context labels such as:

system_u:object_r:httpd_sys_content_t:s0

This label tells SELinux what type of object it is.

For example, Apache may be allowed to read files labeled:

httpd_sys_content_t

But Apache may be blocked from reading a file with the wrong SELinux label, even if file permissions are 777.


Important rule

For access to work, both must allow it:

Linux permissions / ACL must allow it
AND
SELinux policy must allow it

If either one denies access, the access fails.

Example:

ACL allows user john
SELinux denies the action
Result: Access denied

Another example:

SELinux allows Apache
File permission denies Apache
Result: Access denied

Example situation

Suppose Apache cannot read a web page.

You check normal permissions:

ls -l /var/www/html/index.html

Output:

-rw-r--r-- 1 root root index.html

Looks okay.

Then check SELinux label:

ls -Z /var/www/html/index.html

If the label is wrong, Apache may still be denied.

Fix SELinux context:

sudo restorecon -v /var/www/html/index.html

or for the whole directory:

sudo restorecon -Rv /var/www/html

Commands summary

ACL commands

getfacl file.txt
setfacl -m u:john:r file.txt
setfacl -x u:john file.txt
setfacl -b file.txt

SELinux commands

getenforce
sestatus
ls -Z file.txt
restorecon -v file.txt

Slide-friendly summary

ACL = extra file permissions for specific users/groups.
SELinux = mandatory security policy using labels and rules.

ACL answers: “Which user/group can access this file?”
SELinux answers: “Is this process allowed to access this object in this way?”

Access works only when both Linux permissions/ACL and SELinux policy allow it.

REF: AI Tools/ChatGPT

Explain the command and each part : Get-Service * | Select-Object Status, DisplayName | Where-Object { $_.Status -eq “Running” -and $_.DisplayName -like “Windows*“ } | Sort-Object DisplayName -Descending | Format-Table -AutoSize

This command lists running Windows services whose display name starts with “Windows”, sorts them by display name in descending order, and displays the result in a neat table.

Corrected version:

Get-Service * |
Select-Object Status, DisplayName |
Where-Object { $_.Status -eq "Running" -and $_.DisplayName -like "Windows*" } |
Sort-Object DisplayName -Descending |
Format-Table -AutoSize

Step-by-step explanation

1. Get-Service *

Get-Service *

Gets all Windows services on the computer.

The * wildcard means:

all services

So this returns services such as:

Windows Update
Windows Audio
Print Spooler
BITS

2. Pipeline |

|

The pipeline sends the output of one command to the next command.

Here, service objects are passed from:

Get-Service

to:

Select-Object

3. Select-Object Status, DisplayName

Select-Object Status, DisplayName

Keeps only two properties:

PropertyMeaning
StatusWhether the service is Running, Stopped, etc.
DisplayNameThe friendly service name shown to users

Example output at this stage:

Status   DisplayName
------   -----------
Running  Windows Audio
Stopped  Windows Search
Running  Windows Update

4. Where-Object { ... }

Where-Object { $_.Status -eq "Running" -and $_.DisplayName -like "Windows*" }

This filters the services.

Only services that meet both conditions are kept.


5. $_

$_

Means:

the current object in the pipeline

In this command, each $_ represents one service object.


6. $_.Status -eq "Running"

$_.Status -eq "Running"

Checks whether the service status is exactly:

Running

-eq means:

equals

7. -and

-and

Means both conditions must be true.

So the service must be:

Running

and its display name must start with:

Windows

8. $_.DisplayName -like "Windows*"

$_.DisplayName -like "Windows*"

Checks whether the service display name starts with Windows.

-like is used for wildcard pattern matching.

The * means:

anything after Windows

Examples that match:

Windows Audio
Windows Update
Windows Event Log
Windows Search

Examples that do not match:

Print Spooler
Background Intelligent Transfer Service

9. Sort-Object DisplayName -Descending

Sort-Object DisplayName -Descending

Sorts the remaining services by DisplayName.

-Descending means:

Z to A

Without -Descending, it would sort:

A to Z

10. Format-Table -AutoSize

Format-Table -AutoSize

Displays the final output as a table.

-AutoSize adjusts column widths so the output is easier to read.


Full meaning in one sentence

Get-Service * |
Select-Object Status, DisplayName |
Where-Object { $_.Status -eq "Running" -and $_.DisplayName -like "Windows*" } |
Sort-Object DisplayName -Descending |
Format-Table -AutoSize

means:

Get all services, keep only Status and DisplayName, filter only running services whose display name starts with “Windows”, sort them by DisplayName from Z to A, and display the result in a neat table.

Important note

Your original command has a curly closing quote here:

"Windows*“

Use a normal straight quote instead:

"Windows*"

REF: AI Tools/ChatGPT