On the target Debian host, id is verified at /usr/bin/id.
Run that verified program even if the user's PATH contains another file named id.
Which command is appropriate?
An absolute path bypasses PATH lookup. The expected location must be verified for the target environment because installations can differ.
Detailed explanation
idIncorrect. A bare id uses PATH and may select a user-controlled same-name command.
Incorrect. A bare id uses PATH and may select a user-controlled same-name command.
/usr/bin/idCorrect. /usr/bin/id directly selects the verified executable.
Correct. /usr/bin/id directly selects the verified executable.
./idIncorrect. ./id depends on the current directory.
Incorrect. ./id depends on the current directory.
$PATH/idIncorrect. PATH is a list of directories, not a single directory to append /id to.
Incorrect. PATH is a list of directories, not a single directory to append /id to.
Try it yourself
An example you can run in a temporary verification environment.
test -x /usr/bin/id && /usr/bin/id -uExpected result
現在利用者の数値UIDKey points
- Absolute paths bypass PATH
- Verify the installation location
- ./ depends on the current directory
Notes
- Environment: Debian系Linux / /usr/bin/id / 読み取りのみ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.