I have a user (zabbix) with shell set to /sbin/nologin. The user's home is /var/lib/zabbix and I inserted alias curl='curl -k' into ~zabbix/.bashrc. However it does not work when I (for testing purpose) issue sudo -u zabbix curl https://HOST-WITH-INVALID-ISSUER-CERTIFICATE, it returns null.

Actually, the command curl https://HOST-WITH-INVALID-ISSUER-CERTIFICATE will execute remotely via zabbix-server <--> zabbix-agent interaction.

  • 1
    Use a function instead, maybe.
    – muru
    Jan 28, 2016 at 8:53
  • 1
    you could create a script /usr/local/bin/curl that does just /usr/bin/curl -k ... and make sure /usr/local/bin is before /usr/bin in your path. But you'll have to remember to call /usr/bin/curl instead of just curl for all your other users so that may not be option for you.
    – lgeorget
    Jan 28, 2016 at 11:35
  • @muru where would you write this function?
    – lgeorget
    Jan 28, 2016 at 11:35

2 Answers 2


Instead of an alias, use a .curlrc file in ~zabbix. This contains command line arguments to be added to the curl command when it is run.

# --insecure being the more readable synonym for -k
$ echo "insecure" >> ~zabbix/.curlrc

Non-interactive shells do not expand aliases by default. You need to execute shopt -s expand_aliases explicitly before defining the aliases. Be aware that ~/.bashrc is generally only sourced with an interactive shell as well, so you might want to explicitly source it.

All that being said, functions are a good alternative to aliases, and they do not need any semi-obscure setup to get working. It would look like this:

curl() { command curl -k "$@"; }

The command builtin searches $PATH for the command, so you will not go down the recursion rabbit hole. You can define it in a file that is sourced when the shell is initialized.

  • A function doesn't help here. If there's a place to define a function, it also allows defining aliases. Jan 28, 2016 at 21:11
  • I think Gilles is right. Where should I define that function in order to be accessible by Non-interactive shells? Jan 30, 2016 at 6:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .