Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Make ~/.bash_history a symlink to /boot/config/ssh/.bash_history

Featured Replies

The bash command history will be lost after a reboot. Instead I like to see a symlink to the usb flash drive to have a persistent history.

 

Workaround in my Go-File until this is not realized:

# -------------------------------------------------
# Persistent bash history
# -------------------------------------------------
if [[ ! -L ~/.bash_history ]]; then
  rm ~/.bash_history
  ln -s /boot/config/ssh/.bash_history ~/.bash_history
fi

 

 

EDIT: I don't know why, but in recent Unraid versions this workaround does not work anymore. Because of that I used this Script executed on Array Start by the User Scripts Plugin:

#!/bin/bash

# -------------------------------------------------
# Persistent bash history v1.0
# -------------------------------------------------
if [[ ! -L /root/.bash_history ]]; then
  logger -t gofile "Restore bash history"
  rm -v /root/.bash_history
  ln -v -s /boot/config/ssh/.bash_history /root/.bash_history
fi

 

+1

Seems very usefull to me!

Thank you mgutt for the workaround!

although working, I think it is a bad idea.

 

Using a path to the flash ends up into continous writes to the flash drive setting it to a higher risk of failure.

 

Use a path to the cache drive or something instead.

 

  • Author
36 minutes ago, MAM59 said:

Using a path to the flash ends up into continous writes to the flash drive setting it to a higher risk of failure.

My bash history file has a size of 3 kB after 3 month. It's impossible to kill a flash drive by that.

it does not matter how big it is, just how often it is written does the trick.

  • Author

Which is still a tiny amount.

 

PS it would be even possible to import/export the file on specific events like array start/stop, but I don't think it's worth the effort.

  • Author
43 minutes ago, SimonF said:

Or use a path to a cache only share if they have a cache drive?

Not possible and not worth it.

(there isn't a dir present on a pool which is used by Unraid, not everyone has a pool, not everyone is using a pool as cache, not all use the name "cache", a pool is not usable all the time, ....)

 

Again, we are talking about 0 to 500 (?) writes per year. Most users never use the terminal at all. I don't really understand why this is even worth a discussion.

17 minutes ago, mgutt said:

I don't really understand why this is even worth a discussion.

Flash is vulnarable and UNRAID is picky about it. I had the bad experience of a killed usb flash, I have no intention to redo the procedure.

So, USB-2 speed, no writes unless really necessary (and a history is the least important thing to risk my precious flash drive)

 

Free UNRAID from beeing Flash-Bound(and really BOUND!), and we can talk about it.

 

  • 1 year later...
On 8/6/2022 at 12:12 AM, MAM59 said:

although working, I think it is a bad idea.

 

Using a path to the flash ends up into continous writes to the flash drive setting it to a higher risk of failure.

 

Use a path to the cache drive or something instead.

 

I realize this is an old thread and everyone may already be aware, but this is incorrect.   It would not be continuous writes to the flash drive.  Bash history is stored in memory until you logout/exit the shell...at that point it is written to disk.    So it's a single write per shell session.

Hurray thread necromancy!

 

For what it's worth, I'm 100% with @mgutt on this one. I'm really not sure why USB was even brought up; I can think of very little that would write less.

If you really wanted you could write it to RAM and copy it to flash once an hour or something, but still miniscule. 

 

For what it's worth: +1, I like the idea. Probably wouldn't use it too much myself, but seems like a nice little QoL add.

The idea is what brought me here, I hate losing command history after reboots....very, very irritating    I haven't had a chance to reboot to validate, but I'm very excited about it...it's the little things in life 🙂

 

fwiw: You don't need to do anything special to write it to ram, history is already stored in memory.  It does not write to disk until you logout of the session.   This can be validated by looking at your .bash_history  file it will have the time/date of when you last logged out of a session.   You can also vi the file and you'll not see any of the commands from your current session.

  • 5 months later...
On 10/3/2023 at 7:27 AM, broncosaddict said:

Bash history is stored in memory until you logout/exit the shell...

Is there a way to write history immediately instead of waiting until logout/exit?? I often have multiple SSH sessions open simultaneously and don't really exit/logout on each (remote client restarts or something), but want all their history.

  • 3 weeks later...
On 3/13/2024 at 4:34 PM, digity said:

Is there a way to write history immediately instead of waiting until logout/exit?? I often have multiple SSH sessions open simultaneously and don't really exit/logout on each (remote client restarts or something), but want all their history.

I know what you mean, it's annoying....just hasn't been annoying enough for me to do any digging.

 

On 3/13/2024 at 4:54 PM, mgutt said:

This should work:

https://askubuntu.com/a/115625

Great find!   Thanks, you saved from having to do any digging.  🙂

this is resolved in 6.13 beta

  • 1 month later...
On 4/2/2024 at 8:56 PM, jcofer555 said:

this is resolved in 6.13 beta

Are you saying bash_history is protected against unsafe shutdowns in 6.13?

10 hours ago, mason1171 said:

Are you saying bash_history is protected against unsafe shutdowns in 6.13?

 

Yes, there's a setting in 7.0 beta to have it written to the USB instead of the RAM.

On 7/1/2024 at 5:21 AM, Rysz said:

 

Yes, there's a setting in 7.0 beta to have it written to the USB instead of the RAM.

NICE

  • 3 months later...

It's under Settings -> Console Settings -> Persistent Bash History btw.

 

I wonder how it actually works though.

Edited by steelsoap

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.