Useful Server Commands

There are some useful commands that I will need from time to time, but due to the bad memory that I have, I cannot remember all of them, so I want to keep them down here.

Show the ssh fingerprint on server side

Sometimes I need to SSH into a remote server, but every first time I try to connect to a server, no matter via password authentication or private key authentication, I am always given a fingerprint of the public key in the server and asked whether I want to accept it. If I type “yes” and continue, this public key will be added to .ssh/known_hosts in my home directory. I just want to verify that it is the correct fingerprint from my remote server whenever it is possible, the commands are as below.

To show the MD5 version of the fingerprint of the key:

To show the SHA1-256 version:

 

My Python Development Environment Setup

I’ve just started learning programming in Python and the famous framework Django and my aim is to become a backend developer. After stumbling for quite a while on the internet, I come up with this seemingly working setup, so I want to write it down for future reference and hope that it may help some others.

Python Version Management

In order to use different versions of Python, there must be a version management tool for easily managing different versions on the same machine, and that is pyenv. It allows the user to install multiple versions of Python and easily switching among them, so the user can test their apps in different environments.
Continue reading My Python Development Environment Setup

How to Setup a WordPress Server

I have setup a wordpress site for a friend, but I’m afraid that I cannot remember all the steps and all corresponding commands, so I recorded what I did.

  1. Edit SSH configuration file, change port, password or disable password login for security, then restart ssh:
  2. Change IPTables rules, only allow connections desired ports, close unused ports:
  3. where 12345 is the port number set in the above step.

  4. By default, IPTables rules are not persistent, i.e. they are reverted to the default after system reboot. To save the rules, install iptables-persistent package:
  5. Continue reading How to Setup a WordPress Server

How I Installed Graphic Interface to a Slim Debian System

I searched online for a slim Debian system, but I just could not find one. There are installer CDs and DVDs. As I understand, CD versions contain less packages than DVDs versions, so I think it may better suit my needs. But the only two options available to me are as CDs: netinst iso, which I thought will only work well with internet connection, and xfce iso, which contains a desktop environment already, although a lightweight one. My idea is, I want a slim version of Debian Linux system that has only command line interface and core packages installed by default, and I’ll install a display manager, but I won’t install a whole desktop environment.

But to my satisfaction, as I try to install with the net installer in VirtualBox, it doesn’t necessarily need internet connection, it just gets a confusing name. But there is a step in the installation process where the installer detects the network card automatically, so I have to connect a virtual network card to the virtual machine in settings pane.

It took a little longer as I expected, but it was smooth enough. When I get into the command line interface, it becomes quite easy to install GUI to it, all I have to do is

and then issue a command

to get into graphic interface.

Since I have only one display manager installed, the dwm, so that’s enough for me. As I understand, if multiple display managers exist in the system, one has to create a .xinitrc  file in home directory with the command

in it to specify dwm as the display manager to use.

My .bash_profile on My Mac

Added Jun 25, 2017: Kary, 我衰記性差,好對唔住,唔應該開你玩笑,求你原諒🌹

Original text:

I’m currently using an CUSTOMIZED Mac😁 I like the default Terminal.app shipped within macOS. I have changed the appearance a little bit, so it look nice to me. I also wanted to customize it even more, to enable it to sync command history between all open terminal sessions. I have tried

and some combinations of them in my .bash_profile, but none of them worked for me properly, so I gave up the idea of syncing. Problems include wrong command history number, failing to remove duplicate command, etc.
Continue reading My .bash_profile on My Mac