17/02/2024
Windows home as Cygwin home
Working as a GNU/Linux sysadmin means working all day long on a terminal, it doesn’t matter if you’re dealing with a server, a container or a Kubernetes cluster, and for me terminal means Cygwin.
Microsoft made huge changes since Windows 10 to make it easy to work with GNU/Linux on a Windows workstation, think about OpenSSH available by default or WSL, but for me Cygwin is still the 1st choice, no virtualization, no WSL network issues, (almost) all the GNU/Linux utils available, fast and native to Windows.
But sometimes having two home directories (one for Cygwin, one for your Windows user) is not convenient at all… but there’s a solution for that, it’s easy and it’s fast and do not involve any workaround or symlinks, you can tell Cygwin to use the Windows home directory as a Cygwin home.
For doing it you simply have to edit the /etc/nsswitch.conf file and change the db_home variable, using as value “/%H”, here’s the result:
tas@tas ~ $ grep ^db_home /etc/nsswitch.conf db_home: /%H
The next terminal you’ll open will have its home into “C:\Users\<user>” or if you are a Cygwin lover “/cygdrive/c/Users/<user>” ;)