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?


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


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


Open it with a text editor and enter the following:



Make the file executable by all:

chmod a+x /etc/profile.d/dotnet_optout.sh

Afterwards, you can log out and back in or:


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

To confirm when you're done, enter:


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.

  • @Andy Dalton Updated to account for this. – Nasir Riley Jun 25 '18 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. – Nasir Riley Jun 25 '18 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 Jun 26 '18 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. – Nasir Riley Jun 26 '18 at 12:16
  • I'm not sure I'm using the right terminology. When I log into ubuntu it goes straight into the graphical interface. When that happens, I thought the bash config is not read? So isn't /etc/environment "better"? – lonix Jun 27 '18 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.