On a Linux VPS, Bash history lets you find commands from the current shell, repeat a previous command, reuse its arguments, or open an old command for safe editing. Use history for inspection, !! and related expansions for fast repetition, and fc when you need to review changes before execution. Configure HISTFILE, HISTSIZE, HISTFILESIZE, timestamps, and multi-session synchronization deliberately; history filters are useful, but they are not a substitute for keeping passwords and tokens out of commands.
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
What Bash history does on a VPS
Bash keeps a history list for an interactive shell when its -o history option is enabled. The list is initially in memory. Bash can also read older entries from the file named by HISTFILE when a shell starts and save entries when it exits. The documented default history file is ~/.bash_history.
As an Amazon Associate I earn from qualifying purchases.
Free tools Windows power users keep installed
One-click scans. No signup required.
That distinction matters over SSH. Every login shell has its own in-memory list, while several shells may eventually use the same history file. A command you entered in one SSH window might therefore be absent from another window until you import it, and one shell can overwrite another shell’s additions unless append behavior is configured.
The GNU Bash Reference Manual, edition 5.3 (updated 18 May 2025), documents a default in-memory retention of 500 entries. Your distribution or shell startup files can change that value, so inspect the active settings instead of assuming the default.
#1 Best Overall
- BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
- EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
- COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
- LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
- WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
Check the shell and history settings first
These commands show which shell is running and the values that control history in the current session:
ps -p $$ -o comm=
printf 'history option: '; set -o | grep '^history'
printf 'HISTFILE=%sn' "${HISTFILE-}"
printf 'HISTSIZE=%sn' "${HISTSIZE-}"
printf 'HISTFILESIZE=%sn' "${HISTFILESIZE-}"
printf 'HISTTIMEFORMAT=%sn' "${HISTTIMEFORMAT-}"
printf 'HISTCONTROL=%sn' "${HISTCONTROL-}"
printf 'HISTIGNORE=%sn' "${HISTIGNORE-}"
ps identifies the process behind the prompt. The set -o line tells you whether Bash history is enabled; an interactive shell with history disabled will not behave as these examples describe. The parameter forms with a trailing hyphen keep the diagnostic from printing an error when a variable is unset.
List, limit, delete, and save history entries
The history builtin prints numbered entries. The number is an event designator you can use later with !n or fc.
| Command | Effect | When to use it |
|---|---|---|
history |
Displays the current in-memory list with event numbers. | Inspect recent work before reusing it. |
history 20 |
Displays the last 20 entries. | Reduce a long output on a busy VPS. |
history -c |
Clears the in-memory history list for this shell. | Remove entries from the active shell before deciding what to write. |
history -d 123 |
Deletes event 123 from the in-memory list. | Remove one selected entry. |
history -d 120-125 |
Deletes the inclusive range 120 through 125. | Remove a contiguous group of entries. |
history -a |
Appends this shell’s new entries to HISTFILE. |
Publish commands during a long-lived SSH session. |
history -n |
Reads entries added to HISTFILE since the shell last read it. |
Import work written by another shell. |
history -r |
Reads a history file into the current list. | Load a specified or recovered history file. |
history -w |
Writes the current list to a history file. | Explicitly persist the current list. |
Deleting an entry with history -d changes the current list. It does not by itself guarantee that every copy already written to disk, another shell, a terminal recorder, or an audit system has been erased. If you need the edited list to replace the configured file, use history -w deliberately and understand that it writes the current list as a whole.
Rerun commands with history expansion
Interactive Bash enables history expansion by default. Bash reads a complete input line, performs history expansion, and only then splits the result into words. The default expansion character is an exclamation mark (!).
Rank #2
- WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
- AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
- PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
- ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
- COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
| Expansion | What it selects | Example use |
|---|---|---|
!! |
The previous history event. | After a permission error, sudo !! prefixes the previous command with sudo. |
!42 |
Event number 42. | Run the numbered command after checking it with history. |
!ssh |
The most recent event whose text begins with ssh. |
Repeat the latest SSH connection command. |
^old^new^ |
The previous event with its first matching old changed to new. |
Correct a mistyped path in the immediately preceding command. |
!$ |
The last argument of the previous event. | cd /var/log; less !$ reuses the previous command’s final argument. |
!* |
All arguments of the previous event, excluding its command name. | Pass the same argument list to a different utility. |
Expansion is substitution, not a confirmation prompt. Before pressing Enter on a line containing !, inspect what Bash has placed on the command line. In many interactive configurations, pressing Space or Ctrl-Alt-E after an expansion can expose the resulting text, but behavior depends on Readline settings; the reliable practice is to use history or fc when the command is consequential.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsEvent designators identify a history entry. Word designators then select pieces of that entry, and modifiers can transform the selected text. For example, if event 42 is tar -czf backup.tgz /srv/app, !42:$ selects /srv/app, while !42:2 selects the second word after the command name. The colon syntax is powerful but less readable than editing a copied command, so use it for short, obvious substitutions.
Use fc when review matters
The fc builtin lists, edits, and re-executes a selected portion of the history list. It is the safer choice for a long command, a production change, or any command where you need to inspect several edits before execution.
fc -l
fc -e "$EDITOR" 120 125
fc -s old=new 120
List a range
fc -l lists a recent range. You can select entries by number, by a negative offset relative to the current event, or by a command-name prefix. Listing first lets you verify the event numbers before editing.
Edit and execute
fc -e "$EDITOR" 120 125 opens events 120 through 125 in the editor named by EDITOR. Bash writes a temporary command file, waits for the editor to exit, and then executes the resulting text. Review the complete buffer before saving and exiting. A multiline command, a changed redirection, or an added pipeline can have effects that are not obvious from the first line.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Rank #3
- Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
- Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
- Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
- ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
- Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
Substitute and rerun
fc -s old=new 120 replaces the first matching occurrence of old in event 120 and runs the result. Treat this as an execution command, not a preview. For a sensitive operation, run fc -l 120 120 first, copy the text into an editor, and make the change visibly.
Prevent accidental exclamation-mark expansion
A literal exclamation mark can surprise you in shell prompts, passwords, URLs, configuration values, and application arguments. History expansion is performed even inside double quotes. A backslash suppresses special handling of the next character, and single quotes inhibit history expansion for their contents.
echo 'Build finished!'
echo "Build finished!"
printf '%sn' 'https://example.invalid/?status=ok!'
The first and third examples use single quotes; the second uses a backslash inside double quotes. The URL is only an illustration of quoting: do not assume that enclosing a value in double quotes makes an exclamation mark literal.
Disable expansion for the current shell
set +H
set +H disables history expansion in the current shell. This is useful in scripts and in interactive work that routinely handles literal exclamation marks. To enable it again, run:
set -H
set -H turns the feature on, including in a non-interactive shell where it is otherwise off by default. A practical VPS policy is to leave expansion off in scripts and enable it only in an interactive session where the speed benefit is worth the review risk.
Rank #4
- Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
- Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
- 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
- Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
- USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
Make history persist across SSH sessions
Understand the three retention variables
| Variable | Controls | Important qualification |
|---|---|---|
HISTFILE |
The file Bash reads at startup and writes on exit. | If it is unset, empty, or unwritable, Bash does not save history. |
HISTSIZE |
The number of commands retained in the in-memory list. | The documented default is 500 entries; startup files can override it. |
HISTFILESIZE |
The number of entries kept when Bash truncates the history file. | It limits the on-disk file after Bash writes it. |
At shell startup, Bash reads the file named by HISTFILE. On exit it writes the last HISTSIZE entries and truncates the file to HISTFILESIZE entries. A directory permission problem, a read-only filesystem, or an unwritable path can therefore make history appear to work during a session while silently preventing persistence.
Choose explicit values
export HISTFILE="$HOME/.bash_history"
export HISTSIZE=5000
export HISTFILESIZE=10000
These values are examples of a deliberate policy, not universal requirements. A larger memory list helps when you administer a VPS for long periods; a larger file preserves more audit context but also increases the amount of sensitive command text stored on disk. Put persistent settings in the startup file used by your interactive Bash sessions, then open a new SSH connection and verify them with printf.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Add readable timestamps
export HISTTIMEFORMAT='%F %T '
With this setting, history displays timestamps using the specified strftime format. Bash also writes timestamp markers to the history file, which preserves timing information across sessions and delimits multiline entries. The displayed time is based on the system clock, so check the VPS timezone and clock configuration before treating timestamps as an authoritative incident timeline.
Keep several SSH shells synchronized
Multiple SSH sessions do not automatically share a live in-memory history list. Enable the histappend shell option so exiting shells append rather than replace the existing file:
shopt -s histappend
During a long session, explicitly exchange changes when appropriate:
Best Value
- Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
- Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
- Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
- Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
- Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
history -a # append this shell's new entries
history -n # read entries written by other shells
The usual workflow is to run history -a after a meaningful command block, then history -n in another shell before searching for work performed elsewhere. Without histappend, Bash can overwrite the history file on exit, causing commands from a still-open SSH window to disappear from the shared file.
A practical startup configuration
export HISTFILE="$HOME/.bash_history"
export HISTSIZE=5000
export HISTFILESIZE=10000
export HISTTIMEFORMAT='%F %T '
shopt -s histappend
This configuration provides persistence, a larger retention window, timestamps, and append behavior. It does not make history transactional: two shells can still write at different times, and an explicit history -n is still needed to import entries that another shell has appended since the last read.
Filter routine noise with HISTCONTROL and HISTIGNORE
HISTCONTROL applies broad rules to lines Bash saves. Its documented values include:
ignorespace: skip a line that begins with a space.ignoredups: skip a line identical to the immediately preceding history entry.ignoreboth: combineignorespaceandignoredups.erasedups: remove earlier matching entries before saving the current one.
For example:
export HISTCONTROL=ignoreboth:erasedups
HISTIGNORE provides pattern-based filtering for commands you do not want saved, such as repeated directory listings. Its patterns are matched against the command line, so design and test them carefully; a broad pattern can remove useful operational context as well as noise.
export HISTIGNORE='ls:pwd:history'
Filtering is not secret storage. Do not type passwords, API tokens, private keys, or other credentials directly as command arguments merely because a rule begins with a space or matches a pattern. The command may still appear in a process listing while it runs, in terminal recording, in shell tracing, in an auditing system, or in a copied transcript. Prefer an interactive password prompt, a protected file with correct permissions, an environment or credential mechanism designed for the specific tool, or a secret manager. The warning is an operational security consequence of where command text can travel; Bash’s history controls only what Bash saves to its history list and file.
Recommended Free Tools
Safe workflows for common VPS tasks
Repeat a harmless diagnostic
- Run
history 10and identify the event number. - Read the full command, including redirections and pipelines.
- Use
!nonly when the command is clearly safe and unchanged. - For anything with write access, use
fc -e "$EDITOR" n nand inspect it before saving.
Reuse the previous path without copying it
- Confirm that the previous command’s final argument is the path you intend to use.
- Enter a command containing
!$, such asless !$. - Check the expanded line before pressing Enter, especially if the path contains spaces or shell metacharacters.
Correct a typo in a recent command
- Use
history 5to see the exact text. - For a one-word correction to the immediately previous event, consider
^old^new^. - For several edits or a command with destructive options, open it with
fc -e "$EDITOR". - Save and exit only after checking targets, privileges, redirections, and the command’s final arguments.
Remove a sensitive line from the active list
- Find the event number with
history. - Delete it using
history -d n, or delete a range withhistory -d start-end. - Decide whether the file on disk also needs replacement;
history -wwrites the current list to the configured history file. - Remember that other SSH shells, terminal logs, audit records, process listings, and copied text are separate copies.
Troubleshoot missing or surprising history
history shows nothing
- Confirm that the command is running in Bash and that
set -oreports history enabled. - Check whether
HISTSIZEis zero or unusually small. - Inspect
HISTFILE; an empty or unset value disables file persistence. - Check that the home directory and history file are writable and that the filesystem is not full or mounted read-only.
An earlier SSH session is missing
- Run
history -nto import entries appended by another shell. - Verify
shopt -q histappend; if it is disabled, enable it withshopt -s histappend. - Check whether another shell exited later and overwrote the file before append mode was enabled.
A literal ! causes an error or changes text
- Use single quotes around the literal text.
- Inside double quotes, escape the mark as
!. - Run
set +Hfor the current shell when history expansion is not needed.
fc runs more than expected
- Remember that leaving the editor causes Bash to execute the resulting buffer.
- Use
fc -lto list the range first. - Inspect every line, including continuations, pipes, command substitutions, redirections, and privilege changes, before saving.
Choose the right history technique
| Technique | Speed | Reviewability | Persistence and exposure |
|---|---|---|---|
!!, !n, !$ |
Fastest; often one short expansion. | Lowest; the substitution is automatic, so inspect the line. | Uses the current in-memory list; the resulting command can still be saved like any other command. |
history plus a newly typed command |
Moderate. | High; you manually copy or adapt the visible text. | Works with whatever the current shell has loaded. |
fc -e "$EDITOR" |
Slower than an expansion. | Highest for multiline or destructive commands because you edit before execution. | Reads the selected in-memory events; persistence depends on normal history settings. |
history -a and history -n |
Requires explicit synchronization. | Clear separation between publishing and importing session entries. | Coordinates a shared HISTFILE across SSH shells when append mode is enabled. |
HISTCONTROL and HISTIGNORE |
Automatic filtering. | Not a review mechanism. | Reduces routine entries but cannot protect secrets from other logging or exposure paths. |
Compact command reference
# Inspect
history
history 20
# Edit or remove
history -d 123
history -d 120-125
history -c
# Persist and synchronize
history -a
history -n
history -r
history -w
shopt -s histappend
# Edit and rerun
fc -l
fc -e "$EDITOR" 120 125
fc -s old=new 120
# Expansion control
set +H
set -H
# Retention and timestamps
export HISTFILE="$HOME/.bash_history"
export HISTSIZE=5000
export HISTFILESIZE=10000
export HISTTIMEFORMAT='%F %T '
Use fast expansions for low-risk repetition, switch to fc when a human review is important, and treat the history file as operational data that needs sensible retention and permissions. On a multi-session VPS, append and synchronize explicitly; for secrets, avoid putting them on the command line in the first place.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




