Saturday, January 17, 2026

allowing a non-root user to restart a service on Ubuntu Linux server

As described by ChatGPT, the preferred method was to create sudoers rules for the relevant service(s).

sudo visudo -f /etc/sudoers.d/ourapi

and inside that file, write

deployuser ALL=NOPASSWD: usr/bin/systemctl restart ourapi.service, \
                         usr/bin/systemctl start ourapi.service, \
                         usr/bin/systemctl stop ourapi.service, \
                         usr/bin/systemctl status ourapi.service

where ourapi.service is the service and deployuser is the non-root user.

Here, we double-checked the location of systemctl using 
which systemctl

After doing this, on logging on as deployuser, we can do things like

sudo systemctl start ourapi.service

where it will prompt for deployuser's password and then carry out the command.

But a caveat - we need to type exactly the same command as mentioned in the custom sudoers file - even equivalent commands like

sudo systemctl start ourapi

will not work unless we add that to the sudoers file also.

Friday, January 16, 2026

some quirks of my KVM setup and Apple keyboard layout

Currently using this product, 

HDMI KVM Switch 4 Port - 

there were some quirks which I had to work around. 
  1. The Dell desktop running Linux Mint needed the USB keyboard to be mapped to it while booting, or else it would boot into Windows instead, even though the default boot sequence was set to Linux. Probably because the "fail-safe" boot option is different, when it beeps to indicate "No keyboard detected."
  2. The KVM switch defaults to number 4 on power up, not number 1. So, the Dell desktop needs to be connected to 4 and not 1, for booting up without having to hit the KVM switch.
  3. The Mac mini can boot OK without having the KVM mapped to it, but if we leave it on and not logged in, the login screen blanks and we can't get the screen to come back to life with the keyboard or mouse - we need to short-press the power button.
  4. The Mac mini default keyboard mapping was showing the Indian rupee symbol instead of the backtick symbol ` for the key to the left of 1 (perhaps after the upgrade to MacOS Tahoe). Since I need ` for markdown on github etc, changed the keyboard layout to "US" from "ABC India" which was the default. For this, following this,
    chose Apple menu > System Settings, then searched for Keyboard in the sidebar. There, Input sources > Edit button, the small + button at the bottom left to add Input sources. Quite easy to miss.