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.
/usr/bin/idCorrect. /usr/bin/id directly selects the verified executable.
./idIncorrect. ./id depends on the current directory.
$PATH/idIncorrect. 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
Shell function
A reusable group of commands that runs in the caller's shell context.
Positional parameter
A numbered argument or special value supplied to a script or function.
Control flow
Conditions, loops, and exit statuses determine which shell commands run.