.bash_history makes me happy, how about you?
-
I had used Windows since 3.0 (ca 1991) before I switched to main usage of Linux in 2019 so please don't make fun of me for this too much. I've been working on setting up my .NET Core WebAPIs (hosted under various domains but running on one copy of a DigitalOcean droplet (running Debian)) and setting up the services and forwarding via Nginx and all that. It's all command-line there are a lot of steps that I forget often. 1. set up a service file in /etc/systemd/system/ 2. build the WebAPI and deploy it under a folder in /var/www/ 3. configure nginx to point at your webAPI 4. create link to the nginx config ln -s /etc/nginx/sites-available/<apiName> /etc/nginx/sites-enabled/ There's a bunch of things and I would lose the commands and forget things I should do. And, I be forever up-arrowing to get to old commands that I had used. .bash_history Then I stumbled upon the .bash_history file and noticed I can open it up in an editor (nano, of course, because I am vim-weak and don't know how to exit vim :laugh: ) Wow, that is really cool that all those commands are just sitting in there like that so I can now pull them out and save them to a file with some documentation. Thank you, Linux, it seems like you get better all the time. :laugh: I bet you already knew about .bash_history didn't you? Well, try not to laugh at me too hard for only finding it now. :)
-
I had used Windows since 3.0 (ca 1991) before I switched to main usage of Linux in 2019 so please don't make fun of me for this too much. I've been working on setting up my .NET Core WebAPIs (hosted under various domains but running on one copy of a DigitalOcean droplet (running Debian)) and setting up the services and forwarding via Nginx and all that. It's all command-line there are a lot of steps that I forget often. 1. set up a service file in /etc/systemd/system/ 2. build the WebAPI and deploy it under a folder in /var/www/ 3. configure nginx to point at your webAPI 4. create link to the nginx config ln -s /etc/nginx/sites-available/<apiName> /etc/nginx/sites-enabled/ There's a bunch of things and I would lose the commands and forget things I should do. And, I be forever up-arrowing to get to old commands that I had used. .bash_history Then I stumbled upon the .bash_history file and noticed I can open it up in an editor (nano, of course, because I am vim-weak and don't know how to exit vim :laugh: ) Wow, that is really cool that all those commands are just sitting in there like that so I can now pull them out and save them to a file with some documentation. Thank you, Linux, it seems like you get better all the time. :laugh: I bet you already knew about .bash_history didn't you? Well, try not to laugh at me too hard for only finding it now. :)
A couple of pointers:
!$
is the last argument of the last command e.g.$ cat foo.bar
$ nano !$ # expands to "nano foo.bar"!!
repeats the last commandCTRL+r
does a reverse search through your history so$ CTRL+rfoo
searches backwards through your history for the most recent command with "foo" somewhere in it, so it might match nano
foo
.bar or setfoo
bar able baker charlierepeating [CTL-R] searches to the next previous, etc. There's a whole bunch of other things you can do, but those are the ones I use most often"A little song, a little dance, a little seltzer down your pants" Chuckles the clown
-
A couple of pointers:
!$
is the last argument of the last command e.g.$ cat foo.bar
$ nano !$ # expands to "nano foo.bar"!!
repeats the last commandCTRL+r
does a reverse search through your history so$ CTRL+rfoo
searches backwards through your history for the most recent command with "foo" somewhere in it, so it might match nano
foo
.bar or setfoo
bar able baker charlierepeating [CTL-R] searches to the next previous, etc. There's a whole bunch of other things you can do, but those are the ones I use most often"A little song, a little dance, a little seltzer down your pants" Chuckles the clown
-
I had used Windows since 3.0 (ca 1991) before I switched to main usage of Linux in 2019 so please don't make fun of me for this too much. I've been working on setting up my .NET Core WebAPIs (hosted under various domains but running on one copy of a DigitalOcean droplet (running Debian)) and setting up the services and forwarding via Nginx and all that. It's all command-line there are a lot of steps that I forget often. 1. set up a service file in /etc/systemd/system/ 2. build the WebAPI and deploy it under a folder in /var/www/ 3. configure nginx to point at your webAPI 4. create link to the nginx config ln -s /etc/nginx/sites-available/<apiName> /etc/nginx/sites-enabled/ There's a bunch of things and I would lose the commands and forget things I should do. And, I be forever up-arrowing to get to old commands that I had used. .bash_history Then I stumbled upon the .bash_history file and noticed I can open it up in an editor (nano, of course, because I am vim-weak and don't know how to exit vim :laugh: ) Wow, that is really cool that all those commands are just sitting in there like that so I can now pull them out and save them to a file with some documentation. Thank you, Linux, it seems like you get better all the time. :laugh: I bet you already knew about .bash_history didn't you? Well, try not to laugh at me too hard for only finding it now. :)
In addition to what k5054 said, bone up on the
readline
library that bash (and many other command line utilities) use. Lots more tricks at your fingertips from my second most frequent use, correcting typos in a recalled command, to really esoteric magic. (My most frequent use is autocomplete.)Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
-
I had used Windows since 3.0 (ca 1991) before I switched to main usage of Linux in 2019 so please don't make fun of me for this too much. I've been working on setting up my .NET Core WebAPIs (hosted under various domains but running on one copy of a DigitalOcean droplet (running Debian)) and setting up the services and forwarding via Nginx and all that. It's all command-line there are a lot of steps that I forget often. 1. set up a service file in /etc/systemd/system/ 2. build the WebAPI and deploy it under a folder in /var/www/ 3. configure nginx to point at your webAPI 4. create link to the nginx config ln -s /etc/nginx/sites-available/<apiName> /etc/nginx/sites-enabled/ There's a bunch of things and I would lose the commands and forget things I should do. And, I be forever up-arrowing to get to old commands that I had used. .bash_history Then I stumbled upon the .bash_history file and noticed I can open it up in an editor (nano, of course, because I am vim-weak and don't know how to exit vim :laugh: ) Wow, that is really cool that all those commands are just sitting in there like that so I can now pull them out and save them to a file with some documentation. Thank you, Linux, it seems like you get better all the time. :laugh: I bet you already knew about .bash_history didn't you? Well, try not to laugh at me too hard for only finding it now. :)
raddevus wrote:
I am vim-weak and don't know how to exit vim :laugh:
IIRC it exits with ":q" (short for :quit) and all other variations if you have saved or not, you want to force the saving (even if you open in read modus) or not, if you want to... Yeah, it might be a bit annoying :-D
M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.
-
I had used Windows since 3.0 (ca 1991) before I switched to main usage of Linux in 2019 so please don't make fun of me for this too much. I've been working on setting up my .NET Core WebAPIs (hosted under various domains but running on one copy of a DigitalOcean droplet (running Debian)) and setting up the services and forwarding via Nginx and all that. It's all command-line there are a lot of steps that I forget often. 1. set up a service file in /etc/systemd/system/ 2. build the WebAPI and deploy it under a folder in /var/www/ 3. configure nginx to point at your webAPI 4. create link to the nginx config ln -s /etc/nginx/sites-available/<apiName> /etc/nginx/sites-enabled/ There's a bunch of things and I would lose the commands and forget things I should do. And, I be forever up-arrowing to get to old commands that I had used. .bash_history Then I stumbled upon the .bash_history file and noticed I can open it up in an editor (nano, of course, because I am vim-weak and don't know how to exit vim :laugh: ) Wow, that is really cool that all those commands are just sitting in there like that so I can now pull them out and save them to a file with some documentation. Thank you, Linux, it seems like you get better all the time. :laugh: I bet you already knew about .bash_history didn't you? Well, try not to laugh at me too hard for only finding it now. :)
raddevus wrote:
I am vim-weak and don't know how to exit vim
How to exit vim: Try to turn off the computer. If you cannot - buy the new one. Turn on the computer and reinstall OS.