Linux / Mac Troubleshoot or Howto Create a Install Script by Following the History of the System / Trouble Shoot (Oh Sh*t, I Did a Mess)
789 Views, 5 Favorites, 0 Comments
Linux / Mac Troubleshoot or Howto Create a Install Script by Following the History of the System / Trouble Shoot (Oh Sh*t, I Did a Mess)
instructables is also quite good to save personal notes - I've seen... So I do.
My Raspberry-Pi however stopped all it's operations via WIFI somehow. I guess I installed some messy configuration like a DNS server or something, by accident - or I forgot to configure other stuff.
Also during a fresh install and reinstall - you probably don't like to retype all commands at once, or you like to turn your last command sequence or all apt-get's you do in shell into a bash-script.
Command : History
Autocomplete Function (Win,MAC,Linux)
first, when typing commands in shell, you may try to write some chars and press the tab key. This works also on directories. It even works in Windows CMD !
I can not remember ... it was yesterday... what I have done on the system
dont panic, just use the history command:
root@pi2:/home/olaf# history 32 find . -print0 | grep -FzZ "wikimedia" 33 mount -a 34 ls 35 cd /var/log 36 ls
to filter for special commands like installations:
history | grep apt-get
to filter for things where I had my fingers in it:
history | grep nano
and to check - if I already did download this GIT repository e.g. for Roundcube
root@pi2:/home/olaf# history | grep Roundcube
323 git clone https://github.com/JohnDoh/Roundcube-Plugin-Sieve...
324 mv Roundcube-Plugin-SieveRules-Managesieve managesieve
488 mv Roundcube-Plugin-SieveRules-Managesieve managesieve
490 cp Roundcube-Plugin-SieveRules-Mana
Create a Install Script
Thus we know about the history command now, we can easily turn our history into a installation file.
history | grep apt-get > myfilename.sh
The >>> | <<<<< you get on MAC by pressing ALT+7
The " > " will guide the output not to the screen, but into a file called "myfilename.sh". We need to open our file and remove all numbers (as seen on the photo):
nano myfilename.sh
then in the first line of the file insert the shebang:
#!/bin/bash
Exit with CTRL+X
chmod and chown on your personal needs.
Add Some Files to Your New Install Script, If Needed
you can easily add config commands to your file:
root@pi2:/home/olaf# echo mycommand > myfilename.sh<br>
show the modification - and do not forget to move inside your editor the commands to the right position!
root@pi2:/home/olaf# tail myfilename.sh mycommand