Chapter 7: Static Website Hosting (3 OSes × 2 Web Servers)
7.5 Step 3 (common): copy files and set permissions
Friends, the files are in your home folder. Now let's copy the public sample into a new practice web root. Folders 755 and files 644 are useful starting modes for these public files. The server also needs access along the parent path, and its site rules and host security policy still apply.
मित्रांनो, फाइल्स होममध्ये आल्या. आता सार्वजनिक नमुना नवीन सरावाच्या वेब रूटमध्ये कॉपी करू. या नमुन्यासाठी फोल्डर्स 755 आणि फाइल्स 644 ही सुरुवातीची सेटिंग आहे. सर्व्हरला वरच्या डिरेक्टरीमधून जाण्याची परवानगीही हवी. साइटचे आणि होस्टच्या सुरक्षा धोरणाचे नियम लागू राहतात.
दोस्तों, फ़ाइलें होम में आ गईं। अब सार्वजनिक नमूना नए अभ्यास वाले वेब रूट में कॉपी करेंगे। इस नमूने के लिए फ़ोल्डर 755 और फ़ाइलें 644 शुरुआती सेटिंग हैं। सर्वर को ऊपरी डायरेक्टरी से गुज़रने की अनुमति भी चाहिए। साइट और होस्ट की सुरक्षा नीति के नियम भी लागू रहते हैं।
Run this short version only on your assigned disposable server when the target does not already exist. If the first mkdir reports an existing directory, stop and inspect it with your trainer. Use the staging lab below for the four-file sample created in the expanded lesson 7.3.
(
set -eu
source_tree="$HOME/mysite"
target='/var/www/mysite'
if [ ! -d "$source_tree" ] || [ -L "$source_tree" ] ||
[ ! -d "$source_tree/css" ] || [ -L "$source_tree/css" ]; then
printf '%s\n' 'Select the approved sample and its regular CSS directory.' >&2
exit 1
fi
for name in index.html 404.html css/style.css; do
if [ ! -f "$source_tree/$name" ] || [ -L "$source_tree/$name" ]; then
printf 'Missing or linked source: %s\n' "$name" >&2
exit 1
fi
done
sudo mkdir -m 0755 -- "$target"
sudo mkdir -m 0755 -- "$target/css"
for name in index.html 404.html css/style.css; do
sudo install -m 0644 -- "$source_tree/$name" "$target/$name"
cmp "$source_tree/$name" "$target/$name"
done
ls -ld "$target" "$target/css" "$target/index.html" "$target/css/style.css"
)
Now follow the section for your combination.
Ravindra Bagale's Tip
From inside the server, request the lab site through its configured local listener, using the intended hostname and path. Check both the response status and a distinctive line in the page. A request to localhost alone may select the default site. Compare a successful local result with the external request to check where the two paths differ.
Ravindra Bagale's Tip – मराठी
सर्व्हरच्या आतून सरावाची साइट तिच्या स्थानिक listener वर योग्य hostname आणि path वापरून उघडा. Status आणि पेजमधली ओळखता येणारी ओळ तपासा. फक्त localhost वापरल्यास default साइट लागू शकते. स्थानिक आणि बाहेरच्या request मधील फरक मग तपासा.
Ravindra Bagale's Tip – हिंदी
सर्वर के अंदर से अभ्यास की साइट के स्थानीय listener पर सही hostname और path के साथ अनुरोध करो। Status और पेज की पहचान करने वाली पंक्ति जाँचो। केवल localhost से default साइट खुल सकती है। फिर स्थानीय और बाहरी अनुरोध के बीच का अंतर देखो।
Lab
Chala, trainer ne dilelya saravachya server var, /var/www/mysite navin asel tar varchya commands vapra. Mag ls -ld cha output bagha. Folders drwxr-xr-x aani files -rw-r--r-- distat ka te check kara. Linux var namei -l /var/www/mysite/index.html ne varchya directories pan tapaasa.
Keep the received copy, prepared release and live site separate
Mauli Dairy's sample files have reached the authorized stage. That confirms the transfer was completed and can be inspected. A public web server may still read yesterday's approved site from a different directory. The publish step determines what the server reads for the site's requests. Treat it as a two-part change: prepare a complete candidate with appropriate ownership and access, then activate it for the approved site only after verification.
Draw three directories. The first is the receiving stage, writable by the approved transfer identity. The second is the prepared release, which contains only intended assets and has the chosen permissions. The third is whatever path the active web server currently uses. On a new disposable host those roles can be simpler, but on a shared site they should be explicit. A path name such as /var/www/mysite doesn't tell you which operator owns it or whether a different site already depends on it.
Before copying, inspect the exact source and destination scope. Use a new isolated destination or the site's controlled versioned directory process. If the target already exists or serves another site, do not overwrite it for classroom convenience. Check the known file list and whether entries are normal files rather than links to unrelated data. Preserve the currently approved release and configuration where the owner requires it, and know which direction the rollback should take. The exercise's local copies do not require privileged access or any global service changes.
Write the expected result in terms of responsibility. A deployment identity can prepare and update the candidate. The web worker should be able to read the intended files and traverse the required directories, often without having permission to write them. An approved client can ask for the exact published paths. Those three permissions belong to distinct operations. Adding broader write access is not needed merely to show a server can read a stylesheet.
Read the permission digits for a file and a directory
A traditional Unix mode has groups of bits for the owner, the owning group and other users. In simple numeric notation read contributes 4, write contributes 2 and execute or search contributes 1. A value of 7 includes all three, 6 includes read and write, and 5 includes read plus execute or search. Every bit decision should answer who needs to perform which operation. Users, groups, ACLs and platform policies can affect which accesses actually apply.
| Numeric mode | Owner | Group | Other accounts |
|---|---|---|---|
0644 on a normal file | Read and write | Read | Read |
0755 on a directory | Read, write and search | Read and search | Read and search |
0640 on a normal file | Read and write | Read | No ordinary mode access |
0750 on a directory | Read, write and search | Read and search | No ordinary mode access |
For a normal HTML or CSS file, the web worker needs to read the bytes. It does not need to execute the HTML as a local program. A 0644 file leaves writing to its owner and can be readable to others who can reach it. A 0755 directory permits other users to search named entries, while writing remains with its owner under ordinary bits. This pair is a common simple example for public content. A restricted publisher may use an approved group-based model, such as 0750 directories and 0640 files, if the worker and parent paths actually allow the intended reading.
The leading zero in 0644 is a conventional way to write an octal mode in many teaching examples, where each digit describes three bits. In tools that print symbolic mode text, an ordinary file might begin with a dash followed by rw-r--r--. A directory begins with a d and its mode contains search bits shown as x. Verify whether you're inspecting an ordinary file, directory or symbolic link before interpreting the rest. Mode alone does not establish which user the web server runs as.
Do not make all paths writable to repair an access failure. Directory write and search can permit changing directory entries, which is broader than serving a file. Protect the data path and choose the intended deployment role. Keep keys, drafts and private source outside a directory meant to be accessible to the web server. Make this separation clear before opening a network route to the service.
Trace file access through every parent directory
A colleague reports index.html is readable because it shows 0644. The page returns 403. The web worker may be unable to search an earlier directory on the path. A file can sit below a private home directory with ordinary 0700 protection. Another user can lack the ability to pass through that directory even though the final file looks readable. Changing the final file's mode alone cannot supply access to a parent.
Imagine the selected file is /var/www/training-mauli/css/style.css. A process has to follow the relevant path components to reach the file. Inspect the actual ownership and mode of the dedicated site root and subdirectory, as well as the parent locations allowed by the environment. Linux namei -l can decompose the path and show each entry and permissions. It can reveal a link or restricted directory that a single ls -l of the file does not show.
Next identify the actual worker account. The process that starts the web server can have administrative privileges so it can bind the intended socket and prepare its workers. The process serving files can run under a different user. Group membership, configured ACLs and security context can influence its access. A root account reading the file in an administrative shell is not a reliable test of what an ordinary worker can read. Ask the owner for the approved worker and path evidence.
Production directory controls can add other behavior. Apache can use directory authorization to decide which requests are allowed. Nginx can handle a particular path through a different rule or actively deny it. SELinux can restrict access on a host using an enforcing policy. A correct ordinary mode is one necessary check in many designs, but other decisions can still affect a request. Read the responding site's approved logs and relevant configuration instead of weakening the entire tree to make a test pass.
Copy only the reviewed files into a new local candidate
Use Bash and the system's ordinary install tool. Start with the four-file output from Lesson 7.3, or prepare the same layout in a disposable directory. These steps target a new temporary directory owned by your local session. They do not use sudo, a public server root or any existing release. Replace the first placeholder with your actual prepared tree. The shell block refuses to continue if one of the required files is absent or is a symbolic link.
(
set -eu
source_tree='REPLACE_WITH_APPROVED_PRACTICE_SOURCE'
if [ ! -d "$source_tree" ] || [ -L "$source_tree" ] ||
[ ! -d "$source_tree/css" ] || [ -L "$source_tree/css" ]; then
printf '%s\n' 'Select the approved candidate and its regular CSS directory.' >&2
exit 1
fi
for name in index.html rates.html 404.html css/style.css; do
if [ ! -f "$source_tree/$name" ] || [ -L "$source_tree/$name" ]; then
printf 'Expected an ordinary publication file: %s\n' "$name" >&2
exit 1
fi
done
workspace=$(mktemp -d "${TMPDIR:-/tmp}/mauli-publish.XXXXXX")
target="$workspace/release"
mkdir -m 0755 "$target"
mkdir -m 0755 "$target/css"
for name in index.html rates.html 404.html css/style.css; do
install -m 0644 "$source_tree/$name" "$target/$name"
cmp "$source_tree/$name" "$target/$name"
done
printf 'Verified candidate root: %s\n' "$target"
ls -ld "$target" "$target/css" "$target/index.html" "$target/css/style.css"
)
The outer parentheses run the lab in a subshell, so the strict settings do not alter the rest of the student's shell. The loop selects four known files and ignores other source entries. The install tool copies each file and sets its intended mode at the newly created destination. The cmp test compares source and destination bytes and typically prints nothing when they match. The last lines print the scoped candidate path and selected directory and file details. This does not change any server's active root.
The temporary workspace itself can have more restrictive permissions, commonly allowing only its owner to enter. It is appropriate for an isolated local test. Do not place a production web root under that temporary ancestor and expect another account to read through it. The final deployment needs an approved parent path and worker identity. This exercise verifies the candidate file and directory modes in isolation. It deliberately does not grant anonymous access to the local machine.
If the setup fails, inspect the error and the approved source paths, do not point the variables at a shared root. Remove only its newly created scratch location if one exists and the lab owner confirms it is yours, or keep it to inspect a partial result. Staged errors should never change live site files.
Inspect the approved production-style path without altering modes
Use the candidate root from the local exercise or an exact approved Linux training path. On Linux, ls -ld and namei -l are read-only ways to inspect the relevant directory and its parent components. The variable below must name the known disposable candidate or the existing approved read-only scope. If the system has no namei command, use the platform's approved file properties and inspect the parent chain one level at a time.
LAB_ROOT='REPLACE_WITH_APPROVED_CANDIDATE_ROOT'
ls -ld "$LAB_ROOT" "$LAB_ROOT/css" "$LAB_ROOT/index.html" "$LAB_ROOT/css/style.css"
namei -l "$LAB_ROOT/css/style.css"
In the basic example the site directories show drwxr-xr-x and normal public files show -rw-r--r--, absent additional display indicators. Inspect ownership and each parent. A private temporary ancestor can intentionally show restrictive mode. A corresponding public deployment path needs relevant worker traversal under the approved design. Neither command tries to alter the mode, start a server or read another user's data. Record what you actually observed rather than assuming the hosting OS uses a fixed owner.
On a Linux host using SELinux and the permitted diagnostic tools, the instructor can help compare getenforce and the file context shown by ls -Zd for the scoped path. A correct label depends on the approved policy and whether the server needs only read access or performs another authorized task. Do not use a command that recursively re-labels an entire live shared tree just because an example directory needs review.
If the intended server is already configured, check that site's current approved response. Use the exact expected hostname, path, port and scheme. A bare loopback request can reach an unrelated default server. Verify response marker and type after any authorized activation. A successful permitted local request proves more than a root shell listing, and a separate required client test verifies the path from the intended outside network. The read-only diagnostics do not require cleanup.
Assign edit, deploy and serve access without sharing ownership blindly
Identify the roles before choosing final ownership. An author maintains source files and asks for a release. A transfer user sends the approved artifact into a stage. A deployment process installs the files and applies the valid site configuration. The web worker reads the result and answers requests. One person may fill these roles in a lab, while the permissions for the actions remain distinct. A setting that makes the serving process able to edit everything is unnecessary for a page with no server-side writes.
| Role | Needed access for the simple case | What to verify |
|---|---|---|
| Author | Write the approved source and build output in the authoring workspace. | Known revision and selected public artifact. |
| Transfer identity | Read the files to send and write to the intended staging location. | Verified host and incoming relative tree. |
| Deployment owner | Prepare the identified release and make the authorized site's change. | Reviewed modes, configuration, rollback and response. |
| Web worker | Read approved content and traverse the designated paths. | Correct worker context, listener and permitted resource response. |
Choose ownership and group according to the actual platform policy. An account may put the release under a deploy owner and a web read group. It might use root-owned directories for parts of the server data. There can be a distinct managed service account. The group associated with the worker can be configured differently on Apache or Nginx. Review actual groups and process identity before asserting that a sample rule grants or denies permission.
If you need to update permissions on a new candidate, write down the exact tree and file types first. A recursive chmod across an existing root can affect links, configured directory behavior or files that should have another mode. A recursive chown can remove the expected owner of other content. Using known file and directory sets for a new candidate is easier to explain and verify. Never use a broad recursive change to make an unknown global site able to serve.
Verify what an installation command did to modes and content
Copying files and choosing permissions are related but independent. A normal copy might use the current user's defaults, preserve modes under a selected option, or overwrite a target. An installation command with an explicit mode records a clear teaching choice. Both operations depend on source and destination names. Compare them before and after. A wrong root or a file landing one level too deep cannot be fixed through ownership alone.
The process's umask also affects some newly created file and directory permissions. It limits modes that creation calls would otherwise request. If two students use different umasks, their plain copy and directory creation results can differ. Apply the approved creation mode deliberately for the candidate and inspect the actual result. Do not try to solve the problem by globally weakening an account's umask. Future files outside the lesson could then be created more openly than intended.
Verify exact paths rather than trusting a wildcard. A shell expansion such as * normally does not include leading-dot names. It may also include any ordinary visible file currently in the source folder, not only your approved page and stylesheet. Hidden operating files or editor copies should stay outside the final release. Build the publication list from the artifacts needed for the site and compare against a known candidate. Following links or copying private files should never happen just because an argument expands.
Check the destination bytes as well as names. A stylesheet can have its expected path with incorrect content or an old release's body. Another file can be partially copied. The cmp checks in the local exercise establish byte equality for that candidate. If the deployment uses a trusted signed artifact or manifest, follow its documented verification rules. Then check the deployed response under the chosen HTTP route and type. A match in an inactive directory does not prove the browser receives it.
Model switching between two known release directories on the same filesystem
This local Python example illustrates one possible release reference design. It creates two small releases in a private temporary directory. A symbolic link called current selects one of the local candidates. The example prepares and replaces a link inside the same temporary directory to choose another release, and then restores the old one. It does not start a service, read an existing web root or modify any machine's actual site. Real deployments should use the authorized publication mechanism and any server policy about links.
python3 - <<'PY'
from pathlib import Path
from tempfile import TemporaryDirectory
import os
with TemporaryDirectory(prefix="mauli-release-pointer-") as tmp:
site = Path(tmp)
for name, marker in [("release-one", "Approved one"),
("release-two", "Candidate two")]:
(site / name).mkdir()
(site / name / "index.html").write_text(marker + "\n")
current = site / "current"
current.symlink_to("release-one", target_is_directory=True)
print("before:", (current / "index.html").read_text().strip())
next_link = site / "next"
next_link.symlink_to("release-two", target_is_directory=True)
os.replace(next_link, current)
print("after:", (current / "index.html").read_text().strip())
next_link.symlink_to("release-one", target_is_directory=True)
os.replace(next_link, current)
print("rollback:", (current / "index.html").read_text().strip())
PY
Expect the words “Approved one,” “Candidate two” and then “Approved one” in that order. Both release directories remain complete during the example. The final read works because the previous known contents are still present. The test demonstrates path resolution and a replacement of a directory entry on the same filesystem. It has no reverse proxy, browser cache, live site configuration or operating authorization. Those would need independent checks.
Production environments can use a link, package directory switch, artifact deployment or versioned routing rule. A web server may restrict following links or cache certain filesystem or response details. Atomic replacement expectations can differ across filesystems and tools. A single change in a pathname does not guarantee active connections or external caches instantly see the same version. Use the actual approved deployment model and test it. If the exercise fails because the platform restricts links, use the example outcomes and keep the restriction in place.
Try a decision without running another command. Candidate two passed its file checks but returns the wrong rate page from the intended frontend. List which checks must happen before returning to release one. Confirm the scoped old release is still valid, apply the authorized rollback and verify the exact page and asset responses from the selected site. The script removes only its own temporary workspace after exiting.
Verify the selected site after the approved activation
After preparing a candidate, check the current site identity and deployment owner. Identify the relevant active server configuration and old known working release. Validate any candidate server change using the selected daemon's documented checks. A content-only release may not need a configuration reload if the existing mapping remains correct. A root or virtual-host change usually needs an authorized apply. Verify the actual mechanism rather than restarting the server just to make new bytes available.
Define the expected request before activating. For Mauli's candidate the home page includes a known release marker. The rate page has the expected fictional value, CSS should return its own content type and a known nonexistent path should give the agreed error. Verify the intended hostname and scheme. A loopback request can target a named local site when the appropriate host information is supplied. A generic localhost URL could show an unrelated welcome page that is unrelated to your copy.
Plan the scope for a shared service. Changing one directory and configuration should change only the authorized website. Record the approved assurance checks for any other sites managed on that host and avoid probing unrelated targets. If the candidate does not pass validation, keep the old version in place and repair the candidate outside the live path. If a published test fails, apply the agreed scoped recovery and verify the same intended requests. A config test or a listing is earlier evidence.
Leave the site with a record of the selected release, location, affected configuration, verified response and applicable retention. A student who tested only a disposable tree should state that no database, service route or cloud change was tested. Preserve the documented backup of the authorized old configuration and files where needed. Another operator can use the record to check a rollback without merging an old home page into a half-new tree.
Locate a 403 or a wrong page using the smallest relevant check
| Observation | First evidence to collect | What a successful next check adds |
|---|---|---|
| The file shows 0644, but a request returns 403. | Actual hostname, mapped path, worker identity and parent or policy restriction. | Verify the intended access in the minimum approved scope. |
| The expected stylesheet returns 404. | Resolved asset URL and file location under the loaded site's root. | Find whether the asset was omitted, nested differently or mapped elsewhere. |
| A generic localhost request shows a welcome page. | Selected host and listener rather than assumptions about the configured site. | A named check can show the new site's actual content. |
| Correct local response but authorized outside request fails. | Outside origin, destination, scheme, route and relevant firewall and listener. | Distinguish an outside path requirement from a local copy problem. |
Investigate code and status together. A 403 can come from a configuration rule rather than ordinary file access. A 404 can result from an unintended document root rather than the actual file being destroyed. A correct site marker and body can establish which active version answered. If the error still seems ambiguous, use the allowed log for that site and compare the exact request time and URI. Do not quote unrelated request logs in the student record.
Check group and ACL decisions when mode bits are insufficient
A directory listing can give the owner, group and ordinary mode bits. Some systems also use access control lists to grant particular users or groups additional access. A Linux file listing can display an indicator beside its mode when there is additional access information. Consult the installed tools and filesystem behavior. To inspect an authorized path with an ACL-aware tool, use a read-only command such as getfacl where available. Compare the exact worker identity, applicable ACL entries and any effective access mask.
Imagine the file belongs to the deployment account and is assigned to an approved web-reader group. The worker needs read access on the file and search access on each required directory. Giving a specific group that access can satisfy the goal while denying ordinary reads by unrelated local accounts. A mistake adding the process to a group must be resolved under the actual running service configuration. Checking an account database entry alone doesn't always establish which supplementary groups a running process already has.
A directory can define default ACL settings that affect future children. A copied release can consequently show modes and entries different from the source or from another candidate. Check which installation process preserved or created ACLs and whether the access mask permits the intended entry. When troubleshooting, state at which step the files obtained their observed access: local authoring, transfer, preparation or publication. Fix the appropriate layer rather than applying unrelated whole-tree changes.
For the worksheet, give a worker account and one named group, list the mode of a parent and the current file, and state which policy lets the worker search and read. Then change only the directory access and identify why a read can fail even though the file itself was not modified. This model applies to an ordinary static site. Writable runtime data, uploads and cache directories may need different controlled role permissions elsewhere.
Recognize when an enabled filesystem label policy needs a separate check
On a host with an enforcing SELinux policy, the identity and mode bits can be correct while a file still cannot be served. SELinux can make a decision based on the process domain, object type and related policy. A location prepared under a home directory can retain an unsuitable type if it is moved into a new root under an unexpected administrative procedure. Inspect both the actual context of the file and the path's expected context under the host policy before changing it.
In standard RHEL-family web-server examples, a type such as httpd_sys_content_t is used for web content intended to be read under the documented policy. The role and exact setup matter. A read-only web tree does not need the same permission as an application directory that stores submitted data. Do not change an entire filesystem to the same type. Follow the documented scoped label and restore procedure for the exact authorized site and keep writable state separate.
Check what information you already have. A mode listing may show the file is readable through its parents. A context listing can show an unexpected type. The server's approved error report can indicate which operation failed at that time. Combine those observations before proposing an authorized change. If the relevant policy is disabled or permissive in the disposable environment, the same label observation may have a different effect. Be clear about what the actual runtime mode establishes.
In a troubleshooting handoff, give the site owner the exact selected file, allowed worker, expected purpose and observed context under the real host mode. State whether you tested any correction. On a systemic host changing the enabled policy to hide a single denied access can undermine unrelated services. The intended exercise is to narrow the directory and label adjustment or use an approved standard content location. A document root is a candidate for review, not a reason to change global access controls.
Keep dependent assets usable during a version switch
Imagine a reader received release one's home page just before a new publication. The page references a stylesheet by its original path. A moment later the reader requests that stylesheet after the site has switched to release two. The document and asset are separate HTTP requests. An atomic pointer change for a server-side pathname does not group the browser's whole navigation into one transaction. The old document must still have the required assets under the intended rollout policy.
One approach uses versioned asset names and keeps the required previous asset versions available during the planned transition. Another uses a known stable stylesheet path for compatible changes. Compare how the previous and candidate pages refer to their assets. If an older response can still be cached or in use, test it during the course's allowed rollout. Keeping the old local directory without making the expected URLs reachable through the configured path does not automatically protect those clients.
Cache and actual storage also need observations. Nginx can use file-opening caches under configured settings, and intermediate HTTP caches can reuse previously obtained representations. A switched root can have been replaced correctly on disk even if a particular allowed client still sees an older response. Compare the approved origin marker and the actual intended user response. Review relevant timing and policy before repeating activation or purging broad categories across other sites.
Make an outage example on paper. Candidate two serves the correct home page, but its new asset path is missing for another route. The owner restores the previous release pointer under the authorized plan. The old page again has the correct marker and required CSS. Then repair candidate two outside the live root and run the same selected-host and asset tests. Record which path failure led to rollback. This is significant recovery evidence beyond just knowing that the symlink name changed.
Review a destination before a privileged installation touches it
Serving under a protected system directory can require scoped administrative access. That permission is meaningful because it can affect others. Before any approved privileged write, inspect the exact destination, existing ownership, whether a link or already active directory has that path and which site uses it. In a classroom a new disposable root can be created once. A second attempt should detect an existing candidate and stop rather than quietly changing its files or ownership.
For a real site change, record a backup or verified predecessor of the selected content and applicable config according to the owner's rollout plan. Inspect the same allowed files and their read or traversal behavior on the new candidate. Do not collect unrelated websites or privileged data for the exercise. A backup path must be private and known to the authorized operator. A test of the current site and the exact planned post-change check help determine whether the recovery plan is usable.
If a privilege prompt fails or the account is not allowed to create the required destination, work in a local authorized stage or consult the site owner. Directly copying into a different system directory can create a new problem. A private release can still be fully verified at the artifact level and offered for approved deployment by a distinct role. The learner's ability to inspect and test the file under the current scope is enough to demonstrate the key concept.
End by verifying a small checklist. The required four files exist with the expected paths and intended modes, the web worker uses the approved accessible directory, and the selected service responds with the expected marker and asset type. Check either a permitted rollback plan or no-live-change status for the local model. The result's correctness comes from observed files, policy and response. It does not come from assuming that a successful copy command owns every path it touched.
Prepare a copy and permission record for the site owner
Give the exact four paths that belong to the candidate from Lesson 7.3. Identify the separate receiving parent and serving root. Explain which stage each operator can write and why the web worker needs only the approved read path.
Given a 0644 stylesheet inside a 0700 ancestor that belongs to another user, explain what may be preventing the web worker from serving it. Include the intended account, relevant directory search evidence and one safer correction path than broadening every mode.
Compare a local group's 0750 and 0640 design with the teaching 0755 and 0644 modes. State what group membership, parents and policies would need to be true for the worker to serve the same public content under the stricter local design.
Write the sequence for preparing a candidate, validating permissions, checking the response and restoring a known previous release. Identify a status, content type and marker for the home and stylesheet requests. Explain which earlier copy checks cannot supply these live response facts.
Interview questions and worked answers
Why does a web-serving directory generally need search permission?
A worker must traverse the relevant parent directories to reach the selected file. Search controls access to named entries in a directory. The final file can allow reads and still be unreachable through a parent. Check which worker and path apply.
Should a web worker be allowed to write the whole static directory?
For this read-only static service, the worker needs the applicable read and traversal access. A separate deploy role performs approved updates. Other workloads may have specific write areas, which should be narrowly identified rather than added to every public file.
Can a 403 be caused by more than chmod settings?
Yes. It can come from the actual mapping or a server rule, parent access, group or ACL, and relevant platform security policy. Inspect the exact responding site and allowed logs and verify the worker context. Choose an evidence-based correction.
Does a staged candidate become the live site automatically?
The service must use the candidate's path and relevant configuration. A comparison proves what exists in the stage, while a named published response proves which release and resource the client received. Keep these steps separate so rollback remains possible.
What does an HTTP header-only check fail to show?
It can show status and response fields, but it does not verify the intended response body. A default site or fallback might return the same status. Use a permitted check for the expected marker or actual file when body identity matters.
Check the mode and evidence needed for each change
Which ordinary permission bit lets a user search a directory for a named child? A. The directory execute or search bit. B. The file's owner write bit alone. C. The HTTP certificate.
Show answer
A. Directory search allows path traversal under the applicable mode and policy. The process then also needs the intended file access. A readable file doesn't override parents.
What does mode 0644 ordinarily give other local users for a normal file? A. Read only, subject to other access rules. B. Write and execute. C. A public network route.
Show answer
A. The final 4 represents read. Users still need access to the parent path and remain subject to policy. File bits do not set a cloud route.
What should happen after comparing the staged file bytes? A. Verify intended activation and the selected site's response if authorized. B. Assume the other live sites now use those bytes. C. Remove the old release regardless of its recovery purpose.
Show answer
A. A stage comparison proves what was prepared. Publishing and serving have separate steps, and the previous approved release can be needed for rollback.
A normal localhost request returns a server's welcome page. What should you check? A. Intended host selection and mapping. B. Every file mode recursively. C. Whether HTTPS uses a printer driver.
Show answer
A. A default site can answer a different name on the same port. Test the expected host and path before altering files or other configurations.
Which statement explains why a previous full release is useful? A. It gives an identified fallback including affected files and paths. B. It automatically disables caching. C. It changes ownership for all other sites.
Show answer
A. A known previous artifact can restore the intended content under the approved mapping. Verify the prior version and its related configuration. Other sites and cache behavior need their own scope.
Revision cards
- Prepare before activation
- Build and verify a complete candidate outside the active root. Apply only the approved site change.
- Mode groups
- Owner, group and other have separate read, write and search or execute values.
- Directory parents
- The worker must traverse the selected path and read the final file. Inspect every relevant parent.
- Worker identity
- The process serving files may use another account or security context than the operator.
- Scoped evidence
- Compare file bytes and permissions, then verify the actual site hostname, status, type and body.
- Recovery
- Keep the approved old release and relevant configuration available and verify the intended result after rollback.
Check a file added after the first release
When someone copies just a replacement logo into a working site, the directory permissions can stay correct while that one new file has a different owner, mode, group, or security context. A new file is a fresh filesystem object, so its attributes depend on how it was created or installed. Compare its listing with the corresponding file from the known-good release, then request the exact logo URL and confirm the intended image format and a successful response. A preview of the homepage alone can miss the regression because a browser may still be displaying its cached logo.
References
- Linux install command and explicit file modes
- Linux chmod modes
- Linux namei path inspection
- Linux ACLs and effective access rules
- Read a file access control list
- Nginx file-open cache behavior
- Linux path resolution and directory search
- File creation mask
- Linux rename and replacement behavior
- Python os.replace semantics
- Python isolated temporary workspace
- Nginx root and file mapping directives
- Nginx host selection
- Apache Directory scope
- Apache access control guide
- SELinux file context and access policy
- HTTP request methods and response semantics