As you already know, the commands you run on your shell will be saved in .bash_history file and you can view them at any time by using either history command or using UP/Down arrows keys or doing a reverse search using CTRL+R key combination from the Terminal. However you can view, access, and re-run them only from the same machine itself. What if you want to access your Terminal history from a different system on the network? No problem! Here is where "Bashhub" utility comes in help. It is a web service where you can save all commands and access them from anywhere. Bashhub saves every commands entered across all sessions and systems, so you can access them from anywhere. To put this simply, your entire BASH history will be available in the cloud and the entire bash history is indexed, and searchable! Bashhub is completely free and open source.
All commands will be stored in Bashhub's database which is encrypted using storage level encryption via LUKS. Bashhub will generate a unique identification token to each user. This token is mandatory to perform any actions on behalf of a user for the command api. The commands recorded on behalf of a user are only accessible using that user's authentication token. There is currently no way to share these commands and they're not publicly accessible. Also Bashhub allows you to ignore some commands that contains sensitive information like user's password. You can safely ignore such commands from being recorded by Bashhub to turn off the recording completely at any time.
Make sure you have installed Python 2.7 on your system. Python 2.7 is available in the default repositories of most Linux distributions, so you can install it using your distribution's package manager. For example, run the following command to install python 2.7 on Debian and variants.
$ sudo apt-get install python2.7
After installing Python 2.7, run any one of the commands given below depending upon the SHELL you use.
If your shell is BASH, enter the following command:
$ curl -OL https://bashhub.com/setup && bash setup
$ curl -OL https://bashhub.com/setup && zsh setup
After few minutes, you will be asked to create a new account if you don't have already one. Enter a valid Email id, username and password and your system's name.
What's your email? [email protected] What username would you like? sk What password? Email: [email protected] Username: sk Are these correct? [Y/n] y Registered new user sk What do you want to call this system? For example Home, File Server, ect. [ubuntuserver]: Registered a new system ubuntuserver Should be good to go! Please close and restart your terminal session.
Done! Your account has been created at Bashhub. You can access your profile at https://bashhub.com/<your-user-name>. Bashhub will create a directory named .bashhub that contains a few scripts and a python virtual environment in your $HOME directory.
If you're an existing user, type "n" when you 're asked "Are you a new user?" and enter your registered Email and password.
Close and restart your Terminal to start recording your Terminal history.
Access Your Terminal History From Anywhere Using Bashhub
Now, run any random commands to verify if it really works.
I ran the following commands:
clear pwd uname -a ls -l touch test.txt
Now it is time to check what commands I have entered.
To do so,run:
This command will display the last 100 commands by default. You can override the default limit by using "-n" flag.
To display only the last 10 commands, run:
$ bh -n 10
Display commands by using specific term
You can also display a specific command by using specific term, for example "ls".
$ bh -n 10 "ls"
If you want to search for a specific command with a search term and run it at the same time, use "-i" flag as shown below.
$ bh -i "ls"
If you've run command more than one time, choose the command you want to run from the list and hit enter.
As you see above, I have run "ls" command three times.
Display the list of commands executed in a directory
To display the list of last commands you executed in the current working directory, use "-d" flag.
$ bh -d
Bashhub will display the most recently used commands.
The other notable feature of Bashhub is interactive search. It is similar to reverse search, you can invoke it by pressing either bh -i or ctrl + b keys.
Let us do interactive search.
$ bh -i (bashhub-i-search): uname
The above command will search for for a command that has "uname" string. You can perform the interactive search in the current working directory using "-d" flag as shown below.
$ bh -i -d (bashhub-i-search): ls
Viewing the details of a command
From interactive search, you can also view the detailed information of a command.
First launch the interactive search:
$ bh -i
Then choose the command from the list and hit "i" or "space bar" keys to display the selected command details.
Bashhub allows you to delete a particular command(s) at any time from the Bashub database. To do so, launch the interactive search:
$ bh -i "ls"
Choose the command that you want to delete and hit "Backspace" or "Delete" keys from the keyboard.
Ignore particular commands from recording
This is another useful feature of the Bashhub utility. You can prevent a particular command that contains sensitive information like username or password from being recorded by bashhub.
To do so, just add #ignore at the end of the command.
$ uname -r #ignore
The above command "uname -r" will not be recorded. Please note that if you've already configured your history to ignore space, Bash will not save the commands if run them with a space at the start of those commands. In that case, you don't need to use "#ignore".
Disable recording commands
If you want Bashhub record the commands, you can turn it by running the following command:
$ bashhub off
The commands won't be recorded anymore until you turn it on.
Please remember this only affects the current shell session by default. To disable recording of all sessions globally, run the following command:
$ bashhub off --global
To turn on Bashhub recording again. run:
$ bashhub on
Just rerun the installation command to update Bashhub. Alternatively, run "bashhub update" command to update it.
Access Bashhub from a different system
Please note that you don't need to run "bh" in the same system itself. Since all commands are stored in Bashhub's database, you can view all your Terminal history from any system. Make sure you have installed Bashhub client on the system and login with the registered Email id and the password.
Are you a new user? [Y/n] n Please enter your bashhub credentials Username: sk Password:
Check the user statistics
$ bashhub status
=== Bashhub Status https://bashhub.com/sk Total Commands: 21 Total Sessions: 1 Total Systems: 1 === Session PID 1154 Started 2 hours ago Commands In Session: 21 Commands Today: 21
If you're concerned about the privacy and security implications, Bashhub is not for you. You can uninstall it by removing the following directory from your system.
$ rm -r ~/.bashhub
For more details, refer the help section:
$ bashhub Usage: bashhub [OPTIONS] COMMAND [ARGS]... Bashhub command line client Options: -V, --version Display version -h, --help Show this message and exit. Commands: filter Check if a command is filtered from bashhub. help Show this message and exit off Turn off saving commands to Bashhub. on Turn on saving commands to Bashhub. save Save a command to Bashhub setup Run Bashhub user and system setup status Stats for this session and user update Update your Bashhub installation util Misc utils used by Bashhub version Display version