266

I use the new built-in "Users" feature of Chrome to switch between Home/Work accounts easily. However, Chrome remembers the "last" user profile you had selected when launching new windows. This is a problem if I close down my "Home" profile last, because when I then click the Email shortcut on my taskbar, because it goes to mail.mycompany.com using my Home profile, and I'm not logged in.

I'd like to change the shortcut to the company webmail to pass a switch that tells Chrome to always start as the "Default" user, regardless of the last one used.

Note: I have tried the command-line parameter --user-data-dir=…, and this seems to do something very different, completely isolated from the Users functionality built in to Chrome. It's possible I'm using it wrong, but please test this before assuming it does the same thing and posting an answer ;-)

7
  • 3
    possible duplicate of Make Google chrome with specific user profile as default browser
    – Synetech
    Commented Jul 19, 2012 at 19:27
  • 2
    For a Gmail shortcut in Windows: C:\Users\username\AppData\Local\Google\Chrome\Application\chrome.exe --profile-directory=Default --app=mail.google.com/mail/u/0
    – user148237
    Commented Jul 25, 2012 at 15:40
  • 4
    The "user-data-directory" contains 1 or more "profile-directorys". The first one being Default, the second one (if existent) Profile 1, then Profile 2 (I assume) and so on. So the --profile-directory=Default parameter is relative to the user data directory by default (i.e. unless it starts e.g. with a drive letter: C:\MyChromeUserData\Default). Apart from the profiles, the user data directory contains little° useful data. When browsing the web on this topic, reckon with confusing inconsistent terminology for these 2 user/profile folder levels. // ° Footnote in next comment: Commented Nov 21, 2016 at 16:04
  • 1
    None of the below solutions work for me. Warning: if you get the bright idea of renaming the profile directories (e.g. so the one you want chromium to consider last_used is always named Default), that also doesn't work, and also loses the bookmarks and some other settings from the profile you renamed to e.g. Default, so, don't try that... (using 90.0.4430.212 (Developer Build) built on Debian 10.9, running on Debian 10.9 (32-bit)) Commented Jun 25, 2021 at 22:34
  • 1
    @SamWatkins Thanks a lot, that really helped me. It didn't quite work out of the box for my system but I was able to make a few tweaks and now it does -- I've posted my own answer with my version, giving credit to you and your answer of course :) Commented Aug 9, 2021 at 16:49

12 Answers 12

254

The command line argument you're looking for is --profile-directory=Default.

Here's the complete command line for Mac OS X:

open -a "Google Chrome" --args --profile-directory=Default

Note: The open command therefore does not launch new instances, as many applications will not be able to deal with multiple instances running as the same user. However there's the -n argument to do that anyway, but it may break the application.

And for Linux:

google-chrome --profile-directory=Default

It expects the internal names of the profiles: My second profile, named "Lemonade" by Chrome, would be --profile-directory="Profile 1".

Determine the profile name by trial and error, or looking in the Local State file (see Justin Buser's answer).

On Mac OS X, the directories are located in ~/Library/Application Support/Google/Chrome. In Linux they are located in ~/.config/google-chrome. In Win7 they are located in %USERPROFILE%\AppData\Local\Google\Chrome\User Data.

17
  • 2
    @DannyTuppeny I got it from the source file after a few failed experiments. But you're right, googling for it is definitely difficult as everyone seems to use the other argument...
    – Daniel Beck
    Commented Jan 11, 2012 at 14:35
  • 5
    As of Nov 2013 this doesn't seem to work in Chrome for Mac. If all sessions are closed the parameter is honored, but after initial opening Chrome chooses same user profile regardless of parameter. (I run as non-admin user). Commented Nov 4, 2013 at 4:31
  • 4
    It's always a good idea to use a bundle identifier instead of the app name, as people sometimes rename their apps. (I renamed mine "Chrome" and the command above does open it at all.) open -b com.google.Chrome --args --profile-directory=Default Commented Jan 2, 2014 at 19:20
  • 2
    As of 2015 Jan, this still does not work on OS X. One thing that does work is opening the application directly with the --profile-directory argument, even if the application is already running. So the problem isn't with the management of open windows so much as it is with how the Mac OS X open command interoperates with the application. Commented Jan 27, 2015 at 22:50
  • 20
    There's a super easy way to identify the profile directory: go to chrome://version and check the Profile Path. Assuming you are seeing /path/to/your/PROFILE, use --user-data-dir=/path/to/your --profile-directory=PROFILE. If your user data directory is the default location (the last paragraph in the answer) you can omit it.
    – yegle
    Commented Nov 28, 2018 at 18:08
78

GUI method with proper icon (for Windows)

  1. Type chrome://settings/ in address bar (or Menu > Settings)
  2. Select Customize your Chrome profile option
  3. Scroll to the bottom and toggle Create desktop shortcut

[1]:

Optional Switch to any other profile & repeat steps 1-4

This creates a shortcut icon to your profile with the correct picture in the icon too. You can drag multiple profiles to your Windows taskbar. The shortcut on Windows 7 icon points to

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory="Default"
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory="Profile 1"
and so on...
9
  • 11
    Does not work for Linux. No button "Add deskop shortcut" Commented Nov 6, 2015 at 0:55
  • 2
    @HeinrichHartmann True, added Windows to the answer. Have to fallback on command line shortcuts for linux.
    – user
    Commented Nov 6, 2015 at 3:51
  • An alternative, at least in win 10 pro, to dragging the newly created Chrome profile icon to the taskbar is to right click the desktop icon, then select "pin to taskbar" (unpin and re pin if already pinned). it seems the desktop icon reference to the programs file system is more promising than opening profiles and pinning all through the taskbar.
    – user289394
    Commented May 11, 2017 at 13:43
  • This doesn't work when using the --user-data-dir flag
    – SpareBytes
    Commented Nov 29, 2017 at 18:23
  • 4
    There is no "Users" section on the settings page. Commented Jan 13, 2020 at 0:56
18

Another, albeit less convenient method of choosing which profile will launch is to edit the Local State file in the Chrome User Data directory and search for "last_used": if you change the value it lists to a different Profile that's the one that will open the next time you launch chrome normally (unless of course you're using the switch mentioned above).

I only mention this in case anyone is interested in a more in-depth solution, that Local State file contains a JSON formatted list of settings that some might find useful.

3
  • 9
    Specifically the JSON object is .profile, thus if you have a tool like JQ you can even easily parse this out via: cat ~/.config/google-chrome/Local\ State | jq .profile to quickly see metadata on the profile like "user_name" (your Google Apps username for the profile), "name", etc. Commented Nov 4, 2016 at 1:48
  • Didn't work for me, it seemed other parameters in that file (or somewhere else?) also affect it. Even copying & renaming the whole profile directories around (so e.g. the one I choose gets renamed to Default) also didn't work on my system, which seems to just want to refuse me doing this with any method. Commented Jun 25, 2021 at 22:31
  • Using jq, we can get the profile keys and names like this: < ~/.config/google-chrome/Local\ State jq -r '.profile.info_cache|to_entries|map(.key + ": " + .value.name)|.[]' | sort -k2,2n Commented Jul 19, 2021 at 16:31
10

--profile-directory is useless if you already have another profile opened or the last window you closed is attributed/was logged in with another profile.

I have app shortcuts with one profile. The apps shortcuts have --profile-directory="Profile 3" plus the --app="..

The default profile shortcut has --profile-directory="Default".

Both profiles get messed up. Extensions and the default shortcut that I use for daily browsing.

4
  • 2
    I've had no issues - I just made sure all my shortcuts have the --profile-directory, so they'll all start with the profile I want :) Commented Jan 24, 2012 at 19:10
  • 1
    I agree with Danny, you don't know what you're talking about. I have 6 profiles and a shortcut for each on my using this method and I can launch any or all of them regardless of whether or not chrome is already running. Commented Jun 13, 2012 at 11:53
  • 2
    @JustinBuser can you still do this in chrome 23? After chrome is open for me, I can't seem to launch a new window or change the profile with these switches. Commented Oct 3, 2012 at 19:08
  • this is only true with open -a using this answer superuser.com/a/1677353/644627 does the trick even if chrome is already opened to another browser. another link that led to it working for myself: howchoo.com/macos/open-google-chrome-terminal-macos Commented Jul 6, 2022 at 18:35
9

on OSX, using the open -a "Google Chrome"... version didn't work for me.

But it works when using the full path:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --profile-directory="Profile 1"
2
  • This works well on macOS. However, if the profile is already open, it opens a new window for that profile. Can anyone think of a version of the above that would not open a duplicate window? It would be better to activate the already-open instance of the profile.
    – McGroarty
    Commented Jul 22 at 16:13
  • @McGroarty, I couldn't replicate your experience. For me, if the profile is already open, the above command opens a new tab in the already existing window. I need to add ` --new-window` to open in a new window.
    – jobwat
    Commented Jul 24 at 10:10
5

I've just tested this with 4 profiles with Chrome Version 22.0.1229.94 m:

Respectfully, I think the confusion is this:

  • If you close all instances of chrome and then launch Chrome with a simple chrome.exe without any switches, then this new instance that is launched will open with the profile of the very last Chrome window/instance that was closed.

  • If however, you click on a shortcut that you've created using the above --profile-directory method, an instance/window with the appropriate login regardless of which window(s)/ instances/ profiles are currently running, and/or which was the last one shutdown.

    4

    Here's a nifty way to open chrome on mac with a brand new user profile:

    open -n -a "Google Chrome" --args --user-data-dir=$(mktemp -d)
    
    1
    • 1
      I was running Chrome with disabled security features via `/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --disable-web-security --disable-site-isolation-trials -incognito --user-data-dir="~/Desktop/chrome_dev_sesh" to get around CORS and a Chrome update broke that command. This is the only answer that solves the issue without me having to debug file permissions.
      – Xchai
      Commented May 11, 2023 at 16:00
    4

    I wrote a script to run Chrome with given profile, selected by the user-friendly profile name (rather than the profile directory name). This is for Linux, specifically Debian 11. We could adjust it for other systems with reference to other answers. It uses jq.

    The first argument is the profile name, the rest are passed along to the google-chrome command-line.

    Example usage:

    chrome_profile "Profile Name" https://google.com/
    

    chrome_profile:

    #!/bin/bash -eua
    profile_name=$1; shift
    local_state=~/.config/google-chrome/Local\ State
    profile_key=`< "$local_state" jq -r '
            .profile.info_cache | to_entries | .[] |
            select(.value.name == env.profile_name) | .key'`
    [ -n "$profile_key" ]
    google-chrome --profile-directory="$profile_key" "$@"
    

    We can list the keys and names of all the profiles like this:

    chrome_profiles_list:

    < ~/.config/google-chrome/Local\ State \
    jq -r '.profile.info_cache | to_entries | map(.key + ": " + .value.name) | .[]' |
    sort -k1,1 -k2,2n
    
    1
    • "chrome_profiles_list" command worked great... but you didn't actually answer the question completely in this answer. But combined with the top rated answer, yours is gold.
      – poleguy
      Commented Jan 27, 2022 at 3:23
    2

    This still works with Chrome Windows as of 4/24/2013. I created a shortcut for each of the 3 profiles I routinely switch between, and I assigned each shortcut a unique "shortcut key".

    One additional nicety -- your profile user icon is in the profile subdirectory, ex: %USERPROFILE%\AppData\Local\Google\Chrome\User Data\Profile 1. I assigned my profile user icon to the windows shortcut.

    I can't reliably put the 3 shortcuts separately on the Win7 taskbar though; win 7 seems to lose count after 2.

    1

    I think the newer version of chrome has already solved this problem. When you signin with a new user in Chrome, it automatically creates a shortcut icon for that user on your desktop.

    1
    • 1
      This seems to be only in Windows, right?
      – Gray
      Commented Jun 5, 2018 at 14:43
    1

    As of April 2016 on Yosemite, I was able to locate Google Apps for all of my 15 Google Profiles (yes, 15). Some were in ~/Applications/Chrome Apps, though we have been told that these are going away.

    To find all of them however I had to do this:

    1. Go to ~/Library/Application Support/Google/Chrome.
    2. In Spotlight search on kind:app
    3. Find 300kb "Applications" with names like Gmail (username).
    4. Copy the ones you want and rename them, then put in your Applications folder of choice.
    1

    Sam Watkins's answer above did not quite work for me, as I have Chromium [specifically version 90.0.4430.212 (Developer Build) built on Debian 10.9, running on Debian 10.9 (32-bit) ] instead of Google Chrome installed, I also had to make a couple of other changes. Credit to Sam's answer for the core functionality. Here's my adapted solution, generally copied from theirs, I note the changes I made afterwards.


    This is for Linux. It uses jq. You may need to run chmod 777 ~/.config/chromium/Local\ State once, before using the scripts.

    The first argument is the profile name, the rest are passed along to the chromium command-line.

    If only the profile name is given, it opens on their default home page.

    If run without any arguments, it opens chromium offering a choice of known profiles. (But if chromium is already running it just effectively does nothing. Of course if it's already running you can just select another profile by clicking your profile's icon next to the address bar.)

    Example usage:

    chromium_profile "Profile Name" https://google.com/

    chromium_profile:

    #!/bin/bash -eu
    profile_name=$1; shift
    local_state=~/.config/chromium/Local\ State
    profile_key=`< "$local_state" jq -r '
        .profile.info_cache | to_entries | .[] |
        select(.value.name == "'"$profile_name"'") | .key'`
    [ -n "$profile_key" ]
    chromium --profile-directory="$profile_key" "$@"
    

    We can list the keys and names of all the profiles like this:

    chromium_profiles_list:

    < ~/.config/chromium/Local\ State \
    jq -r '.profile.info_cache | to_entries | map(.key + ": " + .value.name) | .[]' |
    sort -k1,1 -k2,2n
    

    Specifically to adapt Sam's answer I had to

    • change the paths from google-chrome to chromium. For other browsers based on chrome/chromium (e.g. vivaldi) a similar change would probably work. You can definitively find the path by running find ~ -name Local\ State
    • change permissions on my ~/.config/chromium/Local\ State file to allow access - since only my user and root exist on the machine I just ran

    chmod 777 ~/.config/chromium/Local\ State

    • Although jq apparently installed fine, this part of Sam's code just returned empty strings for me: env.profile_name .For some reason the environment variable did not pass through. So I use some really horrible quoting to get the variable's value to be inserted directly into the jq command string instead.

    You must log in to answer this question.

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