Steven Almeroth

Steven Almeroth

Code Of Honor

Prime Site Tech


  • Tropical Solar: Capricornus (♑) Cardinal Earth Sea-goat | The Sumerian Enki was the god of intelligence, creation, crafts, magic & water

  • Sidereal Solar: Sagittarius (♐) Mutable Fire Archer | The centaur of mythology, the learned healer whose higher intelligence forms a bridge between Earth and Heaven

  • Chinese: Wood Snake (蛇) Month: May Time: 9:00 to 11:00 a.m.

  • Living Honestly
  • Family Matters
  • Information Retrieval
  • Colored Pill Revelations, 1965

    School of Hard Knocks

  • BSc in Computer Science, 1988

    University of Dayton










Git commands


How to update a fork from the upstream branch

First add the upstream remote, let’s call it upstream. Then display it to make sure it took. Then fetch the code and rebase it into master. Finally push it up to the fork remote, probably origin.

$ git remote add upstream
$ git remote -v
$ git checkout master
$ git fetch upstream
$ git rebase upstream/master
$ git push

Ref Log

How to get back files from atomic actions

I’m saying “atomic actions” here to mean something that you told Git to do which is no longer in any of your branches we see in the normal log. The fact is that it might still available in the reflog.

Scenario: I made changes to two files which I committed in a single commit. I realized I wanted them to be in two separate commits so I reverted one of the file’s changes and merged it back into the commit. This as you may have guessed erased my changes to the second file.

To get the changes back from the second file I did:

$ git reflog
0442192 (HEAD -> stdhttp) HEAD@{1}: rebase (continue) (pick): TEMP: count index 0
c41e23b HEAD@{2}: rebase (continue) (fixup): f: server: gold signal
584d118 HEAD@{3}: rebase: fast-forward
ce8f2bf HEAD@{4}: rebase -i (start): checkout
eaf27f2 HEAD@{5}: rebase (continue) (finish): returning to refs/heads/stdhttp
eaf27f2 HEAD@{6}: rebase (continue) (pick): TEMP: count index 0
042ec6b HEAD@{7}: rebase (continue) (pick): f: tx revert
584d118 HEAD@{8}: rebase -i (start): checkout
d6664ce HEAD@{9}: commit: f: tx revert
669952e HEAD@{10}: commit: TEMP: count index 0
584d118 HEAD@{11}: commit: f: server: gold signal
ce8f2bf HEAD@{12}: commit: f: server: good job

I could see the line where I committed the reversion (I’m glad I take the extra half-second to give meaningful names to my fixups):

d6664ce HEAD@{9}: commit: f: tx revert

So then I did:

$ git co 669952e -- ./src/bot/telegram/

I got this from Joshua Wehner’s blog post: How to undo (almost) anything with Git in the section Redo after undo “local”.


Node.js commands


ncu - npm-check-updates dependencies to the latest versions

$ ncu
Checking site/package.json
[====================] 2/2 100%
 express      ^4.9.0  →  ^4.17.1
 nodemon      ^2.0.3  →  ^2.0.4
Run ncu -u to upgrade package.json
$ ncu -u
Upgrading site/package.json
[====================] 2/2 100%
 express      ^4.9.0  →  ^4.17.1
 nodemon      ^2.0.3  →  ^2.0.4
Run npm install to install new versions.

yarn - package manager

How to update package.json after yarn updates:

$ yarn upgrade --latest
$ npm install


Simple commands that I don’t use often enough to remember them


netstat - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships

$ netstat -tunlp
Proto  Local         Foreign    State   PID/Program name
tcp*  LISTEN  8731/nginx: master
tcp*  LISTEN  5752/sshd
tcp*  LISTEN  8731/nginx: master
tcp6   :::80         :::*       LISTEN  8731/nginx: master
tcp6   :::21         :::*       LISTEN  5752/sshd
tcp6   :::443        :::*       LISTEN  8731/nginx: master

$ netstat -tulp
Proto  Local Address Foreign    State   PID/Program name
tcp*  LISTEN  8731/nginx: master
tcp*  LISTEN  5752/sshd
tcp*  LISTEN  8731/nginx: master
tcp6   [::]:http     [::]:*     LISTEN  8731/nginx: master
tcp6   [::]:ssh      [::]:*     LISTEN  5752/sshd
tcp6   [::]:https    [::]:*     LISTEN  8731/nginx: master

ss - another utility to investigate sockets

$ ss -atpu
Netid State  Local Address:Port  Peer Address:Port
tcp   LISTEN*      (("nginx",pid=26743,fd=15),("nginx",pid=26626,fd=15))
tcp   ESTAB    237.140.142:ssh  (("sshd",pid=4159,fd=3),("sshd",pid=4158,fd=3))
tcp   ESTAB    237.140.142:ssh  (("sshd",pid=4133,fd=3),("sshd",pid=4127,fd=3))
tcp   LISTEN          [::]:http          [::]:*      (("nginx",pid=26743,fd=16),("nginx",pid=26626,fd=16))
tcp   LISTEN          [::]:ssh           [::]:*      (("sshd",pid=622,fd=4))

file - determine file type

$ file ~/Pictures/the-national-plan.jpg
JPEG image data, JFIF standard 1.01, resolution (DPI),
density 72x72, segment length 16, comment: "Created with GIMP",
progressive, precision 8, 994x797, frames 3


Get your outside IP number

$ wget -O - -q ; echo

$ curl; echo

$ curl

$ curl

$ nslookup varan

Address: 2600:1700:c010:c40:5e76:d88f:16d3:d8a4
Address: 2600:1700:c010:c40:a151:413a:de1e:f6a8
Address: 2600:1700:c010:c40::44
Address: 2600:1700:c010:c40:d943:2bf6:2800:4ddf
Address: fe80::167c:2090:9293:38c7

$ host varan has address has IPv6 address 2600:1700:c010:c40:a151:413a:de1e:f6a8 has IPv6 address 2600:1700:c010:c40::44 has IPv6 address 2600:1700:c010:c40:d943:2bf6:2800:4ddf has IPv6 address fe80::167c:2090:9293:c783 has IPv6 address 2600:1700:c010:c40:5e76:d88f:16d3:d8a4

Linode Shell


$ ssh -t COWBOY
(exit to the Lish prompt by pressing ctrl+a then d)


last - show a listing of last logged in users

$ last
stav     pts/0     Wed May 20 11:58   still logged in
stav     pts/2     Wed Mar  4 23:07   still logged in
stav     pts/1     Tue May 19 21:13 - 22:49  (01:36)
stav     pts/0     Tue May 19 19:29 - 22:49  (03:20)
stav     pts/0     Tue May 19 19:11 - 19:29  (00:17)

$ sudo lastb
change   ssh:notty    Sun Mar  1 00:00 - 00:00  (00:00)
root     ssh:notty     Sun Mar  1 00:00 - 00:00  (00:00)
rstudio1 ssh:notty   Sun Mar  1 00:00 - 00:00  (00:00)

fail2ban - read password failure reports and ban the corresponding IP addresses using firewall rules

$ cat /etc/fail2ban/jail.local
enabled  = true
port     = ssh
filter   = sshd
logpath  = /var/log/auth.log

$ sudo fail2ban-client status
|- Number of jail:      1
`- Jail list:   sshd

$ sudo fail2ban-client status sshd
Status for the jail: sshd
|- Filter
|  |- Currently failed: 0
|  |- Total failed:     0
|  `- File list:        /var/log/auth.log
`- Actions
   |- Currently banned: 0
   |- Total banned:     0
   `- Banned IP list:

$ # sudo fail2ban-client reload sshd