install: a file with its permissions from the start
| What the command does | |
| Why not just vi the file | |
| The same in two commands | |
| The folder must exist | |
| Check the result |
What the command does
install -m 600 /dev/null ~/.config/opencode-agent/openrouter.key
It creates an empty file that only you can read and write, before any key is in it.
| Part | Meaning |
|---|---|
| install | A command from GNU coreutils that copies a file and sets its permissions in the same step |
| -m 600 | The permissions (mode) of the new file. In octal, 6 = read + write for you, the first 0 = nothing for your group, the last 0 = nothing for other users |
| /dev/null | A special file that always reads as empty, so the copy is an empty file |
| ~/.config/opencode-agent/ | Where the new file goes |
Why not just vi the file
On Ubuntu 24.04 the default for new files makes them readable by everyone. umask shows the default:
umask
0002
The same empty file made both ways:
touch plain.key
install -m 600 /dev/null safe.key
ls -l plain.key safe.key
-rw-rw-r-- 1 me me 0 Oct 27 15:46 plain.key -rw------- 1 me me 0 Oct 27 15:46 safe.key
If you open a new file with vi, paste a key and save, it gets -rw-rw-r--: any other user on the computer can read the key. When vi saves into an existing file, it keeps that file's permissions. So create the file as -rw------- first, then paste the key into it.
The same in two commands
touch ~/.config/opencode-agent/openrouter.key
chmod 600 ~/.config/opencode-agent/openrouter.key
The folder must exist
install does not create the folder, so make it first:
mkdir -p ~/.config/opencode-agent
This is how the key file is made in OpenCode in Docker.
Check the result
ls -l ~/.config/opencode-agent/openrouter.key
The line should start with -rw-------.
Article author: Klavdiya Kondakova
| Linux | |
| install: a file with its permissions from the start | |
| Files | |
| OpenCode in Docker on Ubuntu 24.04: a safe setup step by step |