LFCS · Question #733
What is the purpose of the Bash built-in export command?
The correct answer is D. It sets up environment variables for applications. The Bash export command is used to mark an environment variable to be passed to child processes.
Question
Options
- AIt allows disks to be mounted remotely.
- BIt runs a command as a process in a subshell.
- CIt makes the command history available to subshells.
- DIt sets up environment variables for applications.
- EIt shares NFS partitions for use by other systems on the network.
How the community answered
(50 responses)- A2% (1)
- B4% (2)
- C2% (1)
- D92% (46)
Why each option
The Bash `export` command is used to mark an environment variable to be passed to child processes.
Exporting disks for remote mounting typically involves services like NFS or Samba, not the Bash `export` command.
Running a command in a subshell is done by enclosing the command in parentheses `(command)` or using `bash -c 'command'`, not by the `export` command.
The command history is managed by the shell itself and can be configured through variables like `HISTFILE` or `HISTSIZE`, but `export` does not make it directly available to subshells.
The `export` command makes environment variables available to subsequently executed commands within the current shell and to any child processes or subshells that are spawned from it. This ensures applications or scripts executed in subshells inherit these specific environment settings.
Sharing NFS partitions is handled by the NFS server daemon and configured in `/etc/exports`, not by the Bash `export` command.
Concept tested: Bash shell environment variables, export command
Source: https://www.gnu.org/software/bash/manual/bash.html#index-export
Topics
Community Discussion
No community discussion yet for this question.