removebom
Remove the invisible UTF-8 byte order mark (BOM) from the start of PHP files in one site, one path, or all sites in
/home
- Command:
/go/removebom - Category: PHP files
- Required argument:
<domain>,<path>, orall - Output: None on success
- Last updated: 2026-11-21
On this page: Overview · Quick start · Syntax · Options · Output · Examples · Troubleshooting · Details · See also
Overview
A byte order mark (BOM) is a three-byte marker (EF BB BF) that some text editors put at the very start of a UTF-8 file. In a PHP file it is sent to the browser before any code runs. It is invisible, but it often causes:
Cannot modify header information - headers already senterrors- broken redirects, sessions, and cookies
- corrupted JSON responses, downloads, and generated images
- a blank line or odd characters at the top of pages
/go/removebom strips the BOM from the first line of every .php file in the place you choose, including all subfolders. It can run on:
- one hosted site, by domain name
- any folder or single file, by path
- every site, with
all
[!WARNING] The command rewrites every
.phpfile it finds, not only those with a BOM, and there is no undo or preview. Any existing path is accepted, including/or.. Check the argument before you press Enter, and usefindbomfirst to see which files are affected.
Quick start
# Fix one site (its /home/<domain>/www folder)
/go/removebom example.com
# Fix every site
/go/removebom all
Syntax
/go/removebom <domain|path|all>
| Form | Target |
|---|---|
/go/removebom <domain> |
/home/<domain>/www |
/go/removebom <path> |
That folder or file. |
/go/removebom all |
/home, which is every account. |
Only the first argument is used. There are no --option flags.
The argument is resolved in the order shown in How the target is chosen. An existing path in the current directory always wins over a domain name or all.
Options
| Argument | Required | Default | Notes |
|---|---|---|---|
<domain> |
One of the three | — | The full domain of a hosted site, for example example.com. |
<path> |
One of the three | — | A folder or a single file. Paths with spaces don't work. |
all |
One of the three | — | Everything under /home. This can take a long time. |
Output
| Outcome | What you get |
|---|---|
| Files processed | Nothing. The command is silent on success. |
| The target can't be found | <argument> does not exist and exit status 1. |
Notes on the output:
- There is no list of changed files and no count. To see what was affected, run
findbombefore and after. - With no argument, the message is
does not exist(empty name), and there is no usage text. - A single file that doesn't end in
.phpis skipped without any message. - Every run is logged with a timestamp and its arguments to
/var/log/go/removebom.log.
Examples
# One site
/go/removebom example.com
# One theme folder
/go/removebom /home/example.com/www/wp-content/themes/mytheme
# One file
/go/removebom /home/example.com/www/index.php
# Check whether a file starts with a BOM (shows "efbb bf" at the start if it does)
head -c 3 /home/example.com/www/index.php | xxd
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
<argument> does not exist |
A typo, or the domain isn't hosted on this server. | Use the full domain, or a path that exists. |
headers already sent is still shown |
The problem is not a BOM. It can be output before <?php, or whitespace after a closing ?>. |
Read the error: it names the file and line that sent the first output. |
| A file still starts with a BOM | The file doesn't end in lowercase .php (for example .phtml, .inc, .PHP), or it uses a different encoding such as UTF-16. |
Fix those files with your editor, or run sed on them yourself. |
| Ownership or permissions look different afterwards | The files were rewritten by root. | Run fix for the account. |
| Every file shows as changed in Git or in a backup | sed -i rewrote all .php files and updated their modification times. |
Expected. Use findbom to see which files really had a BOM. |
| The command ran on the wrong folder | The argument was an existing path, such as . or /. |
Check which files changed with your backup tool, and restore with snapshot or restore if needed. |
A domain name fixed more than www |
You ran it in a folder that has a subfolder named like the domain, so the path matched first. | Run it from another folder, or pass the full path. |
all is very slow |
One sed process is started for every file. |
Run it during a quiet period, or fix one site at a time. |
Details
How the target is chosen
The checks run in this order, and the first one that matches is used:
| Order | Check | Target |
|---|---|---|
| 1 | The argument is an existing file or folder (relative to your current directory, or absolute). | That path. |
| 2 | The argument is all. |
/home |
| 3 | The argument contains /www/ and is a folder. |
That folder. This case is already covered by check 1. |
| 4 | /home/<argument>/www is a folder. |
/home/<argument>/www |
| 5 | None of the above. | Prints <argument> does not exist and exits with status 1. |
Because check 1 comes first, running /go/removebom example.com from inside /home processes the whole /home/example.com folder, not only www. A folder or file in your current directory named all also beats the all keyword.
What is changed
flowchart TD
A["removebom argument"] --> B["Log the call"]
B --> C{"Existing path, all, or domain?"}
C -- "None" --> X["Print: does not exist, exit 1"]
C -- "Yes" --> D["Find every *.php file under the target"]
D --> E["On the first line, delete a leading EF BB BF"]
E --> F["Next file"]
For each file, sed -i '1s/^\xEF\xBB\xBF//' deletes the three BOM bytes if they are at the very start of the first line, and writes the file back. The rest of the file is untouched.
| Detail | Behavior |
|---|---|
| Which files | Regular files whose names end in lowercase .php, in the target and all its subfolders. |
| Which BOM | Only the UTF-8 BOM at the start of the file. UTF-16 and UTF-32 markers are left alone. |
| Files without a BOM | Rewritten with identical content. Their modification time changes. |
| Symbolic links | Not followed, because only regular files are processed. |
| Hard links | sed -i replaces the file, so hard links between files are separated. |
The command runs as root, so it can change any account's files.
See also
| Command | Description |
|---|---|
findbom |
Find PHP files that start with a UTF-8 byte order mark, in one site, one path, or all sites |
fix |
Reset ownership and permissions for one account or all accounts |
snapshot |
Back up, list, check, restore, and delete restic snapshots of hosting accounts |
restore |
Restore accounts, databases, SSL certificates, or folders from GoAdmio backups |
backup |
Back up one or all GoAdmio accounts |