During an incident-response drill you are logged into a production server over SSH. You need to immediately flush all commands that you have executed so far in the current Bash session to the user's persistent history file, but you must avoid overwriting commands coming from other concurrent sessions and you do not want to clear the in-memory history list you are still reviewing. Which single Bash built-in command accomplishes this requirement?
The history built-in option -a appends only the new commands entered during the current session to the history file. It writes those lines to disk without disturbing the file's existing contents, so commands recorded by other open shells remain intact and the in-memory list is preserved.
history -a: Correct - appends the new history lines to the file.
history -w: Writes (overwrites) the entire current in-memory history list to the file, which can clobber commands written by other sessions.
history -r: Reads the history file into the current session; it does not write anything out.
history -c: Clears the in-memory history list and therefore does not meet the requirement.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the purpose of the 'history' command in Bash?
Open an interactive chat with Bash
What is the difference between the 'history -a' and 'history -w' options?
Open an interactive chat with Bash
How does the 'history -c' option impact the in-memory history list?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
System Management
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access