I need to disable Google chrome's print preview option using the script "defaults write com.google.Chrome DisablePrintPreview -boolean true -contributed by CutMaster", to a mac using ssh and apply this to all users.

The script above only works when you enter it when logged in as a user. However, I do not have access to the user's account but I do have access to the admin account.

Your help is much appreciated.

  • Forgot to mention that this is a task that I need to apply to 20+ workstations and would prefer not bugging them. Unfortunately we haven't setup a server yet so all settings should be done manually for now. – Mart Angelo Babaan May 17 '16 at 17:10
  • If the command only works when a user in logged then you need to login as the users. You can try to ssh to the admin account then sudo defaults write /Users/foo/Preferences/com.google.Chrome DisablePrintPreview -boolean true -contributed by CutMaster then adjust then privileges to the preference. This isn't hard to script if it works. – fd0 May 17 '16 at 18:01

Use the sudo command

The command is sudo -u username command

So, after you SSH in as the admin, issue the command:

sudo -u <username> defaults write  /Users/<username>/Library/Preferences/com.google.Chrome.plist D
isablePrintPreview -boolean true

That will set the preferences value for the particular user you are interested in without having to know their password.

I personally checked this on OS X 10.11.4 using an account called "testguy". I was able to SSH into the machine, set the preferences using the command you provided and verify that it was set by issuing the command:

sudo -u testguy defaults read  /Users/testguy/Library/Preferences/com.google.Chrome.plist Di

The response was 1 (true)

  • This is a nice suggestion Allan but it still involves me going into each workstation and logging in as a user. I forgot to mention that I have to apply this to 30 workstations. What I wanted was to connect to each workstation through SSH without disturbing the user and apply the settings to all users in that workstation. The script provided by CutMaster actually saves the settings and does not need to run every time the mac boots. – Mart Angelo Babaan May 17 '16 at 17:09
  • Ahh... I thought it was multiple users on one Mac. I have a solution for you that just might work - I remembered it while at lunch – Allan May 17 '16 at 18:36
  • Can you not su to the user after ssh'ing in as admin? – agentroadkill May 17 '16 at 18:50
  • I just tested this and it worked. Use sudo -u username command on the remote computer. su requires you to know the users password. The upside is you get their environment and variables, but in this case, you don't need those..just the file you want to write. – Allan May 17 '16 at 19:02

First I have to say that at the moment I'm not where I can ssh into another Mac to test this, however I'm going to offer it anyway as I believe this can work.

Some assumptions on my part...

  • Each of the systems to be touched have more then one User Account.
  • You will use Administrator Credentials to modify the target .plist file.


In order to touch the target .plist file under each Account you'll need to use sudo and as such it will change the owner:group of the target file to root:wheel and will need to be changed back after the defaults write ... command is executed on the target file. So the owner:group info of the file will need to be ascertained and stored in variables before being touched.

If Google Chrome is running at the time its .plist is touched, the changes will probably not take effect until the app is closed and reopened. Also, depending on the version of OS X, the change may get overwritten when the app is closed. If this is the case you need to add additional code to check and see if the app is running and close it before touching its .plist file.

The following bash script should do what's necessary.



for d in /Users/*; do
    if [[ -f $d$f ]]; then
        og="$(ls -l "$d$f" | awk '{print $3":"$4}')"
        defaults write "$d$f" DisablePrintPreview -boolean true
        chown "$og" "$d$f"

enter image description here

  • I'm not sure what the purpose of the image was, but if it was because of the syntax highlighting I've fixed that. I didn't want to remove it though. – grg May 17 '16 at 18:55

I appreciate your suggestions guys. Allan and User3439894's suggestion are both correct and really helped me a lot. I tested this in 10.11.4 and used the scripts above to 10.9-10.11. I probably just need to email the users to relaunch google chrome for the settings to take effect.

The reason why I want to disable this print preview in chrome for mac is because when users print to our Konica printer, which has authentication enabled, it shows "print" as the username from the logs. Other browsers like firefox or safari does show the appropriate username. I wasn't able to find a solution to that so I decided to disable chrome's print preview instead.

You must log in to answer this question.

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