4

I'm using Microsoft's dotnet in linux (ubuntu), and it has dial-home telemetry. I want to disable it, and the instructions say:

The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous and doesn't include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

I've read that .profile, .bashrc, .bash_profile, /etc/environment, etc, have differences in when they are read, if at all.

So I'm not sure where to put DOTNET_CLI_TELEMETRY_OPTOUT=1? I want it to always be loaded, regardless whether I login without desktop, login with desktop, ssh in remotely, start a terminal, start a terminal from a parent terminal, etc.

Which file (or files) should I put it in? And how would I do it for all users?

1 Answer 1

6

If you are using Ubuntu as one of your tags says, you'll have a directory called

/etc/profile.d

As root, create a file inside. Let's call it

dotnet_optout.sh

Open it with a text editor and enter the following:

#!/bin/sh

DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_CLI_TELEMETRY_OPTOUT

Uodate: You don't have to make the file executable. It's just a force of habit from my early Linux days. It doesn't hurt anything if you do, though.

Afterwards, you can log out and back in or:

bash

And that will start a new shell session which sources /etc/profile.d/dotnet_optout.sh

To confirm when you're done, enter:

echo $DOTNET_CLI_TELEMETRY_OPTOUT

You'll get an output of 1.

In short, any script that is executable by everyone who is using bash (or some sh-like shell that sources /etc/profile) that you put inside of that directory will affect everyone's environment.

If you have users who use other shells, the configuration will be similar, but you'll need to update different configuration files.

8
  • @Andy Dalton Updated to account for this. Commented Jun 25, 2018 at 18:03
  • @AndyDalton That's why he can put a .csh file in and set the shebang for it. I didn't specifically say that but I think he's able to work that out with a little googling. Failing it, he can use /etc/profile which I also mentioned and a lot easier. It's highly unlikely that he's got other users who are using every possible shell that exists. If that's somehow the case then he can use /etc/profile which is sourced by everything. Commented Jun 25, 2018 at 22:46
  • Thanks for that really detailed info. I read on the ubuntu site that a good place to put system-wide stuff like this is in /etc/environment. Do you think it's better/worse than your recommendation of using /etc/profile? Also, will this get read when someone logs into an X session, I thought in that case the bash config isn't read?
    – lonix
    Commented Jun 26, 2018 at 6:41
  • @Ionix If by X session, you mean ssh -X or ssh -Y, then yes, the bash initialization files are indeed read. As long as a shell session is started, the initialization files will be sourced so this will work for you. If this does what you want, you can accept my answer by clicking the check mark next to it. Commented Jun 26, 2018 at 12:16
  • 1
    @Marc.2377 I know. I've updated the answer to show this. It's just a force of habit from my early days of Linux. Commented Jun 22, 2019 at 2:27

You must log in to answer this question.

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