Steve Kobes | 22fb19c | 2017-07-05 21:49:08 | [diff] [blame] | 1 | # User Data Directory |
| 2 | |
| 3 | [TOC] |
| 4 | |
| 5 | ## Introduction |
| 6 | |
| 7 | The user data directory contains profile data such as history, bookmarks, and |
| 8 | cookies, as well as other per-installation local state. |
| 9 | |
| 10 | Each [profile](https://support.google.com/chrome/answer/2364824) is a |
| 11 | subdirectory (often `Default`) within the user data directory. |
| 12 | |
| 13 | ## Current Location |
| 14 | |
| 15 | To determine the user data directory for a running Chrome instance: |
| 16 | |
| 17 | 1. Navigate to `chrome://version` |
| 18 | 2. Look for the `Profile Path` field. This gives the path to the profile |
| 19 | directory. |
| 20 | 3. The user data directory is the parent of the profile directory. |
| 21 | |
| 22 | Example (Windows): |
| 23 | |
| 24 | * [Profile Path] `C:\Users\Alice\AppData\Local\Google\Chrome\User Data\Default` |
| 25 | * [User Data Dir] `C:\Users\Alice\AppData\Local\Google\Chrome\User Data` |
| 26 | |
| 27 | ## Default Location |
| 28 | |
| 29 | The default location of the user data directory is computed by |
| 30 | [`chrome::GetDefaultUserDataDirectory`](https://cs.chromium.org/chromium/src/chrome/common/chrome_paths_internal.h?q=GetDefaultUserDataDirectory). |
| 31 | |
| 32 | Generally it varies by |
| 33 | |
| 34 | * OS platform, |
| 35 | * branding ([Chrome vs. Chromium](chromium_browser_vs_google_chrome.md), based |
| 36 | on `is_chrome_branded` in [GN |
| 37 | args](https://www.chromium.org/developers/gn-build-configuration)), and |
| 38 | * [release channel](https://www.chromium.org/getting-involved/dev-channel) |
| 39 | (stable / beta / dev / canary). |
| 40 | |
| 41 | ### Windows |
| 42 | |
| 43 | The default location is in the local app data folder: |
| 44 | |
| 45 | * [Chrome] `%LOCALAPPDATA%\Google\Chrome\User Data` |
Raymond Toy | 4e660807 | 2021-04-15 21:38:26 | [diff] [blame] | 46 | * [Chrome Beta] `%LOCALAPPDATA%\Google\Chrome Beta\User Data` |
Steve Kobes | 22fb19c | 2017-07-05 21:49:08 | [diff] [blame] | 47 | * [Chrome Canary] `%LOCALAPPDATA%\Google\Chrome SxS\User Data` |
Peter Kvitek | b21d620 | 2024-10-04 12:06:04 | [diff] [blame] | 48 | * [Chrome for Testing] `%LOCALAPPDATA%\Google\Chrome for Testing\User Data` |
Steve Kobes | 22fb19c | 2017-07-05 21:49:08 | [diff] [blame] | 49 | * [Chromium] `%LOCALAPPDATA%\Chromium\User Data` |
| 50 | |
| 51 | (The canary channel suffix is determined using |
| 52 | [`InstallConstants::install_suffix`](https://cs.chromium.org/chromium/src/chrome/install_static/install_constants.h?q=install_suffix).) |
| 53 | |
| 54 | ### Mac OS X |
| 55 | |
| 56 | The default location is in the `Application Support` folder: |
| 57 | |
| 58 | * [Chrome] `~/Library/Application Support/Google/Chrome` |
Raymond Toy | 4e660807 | 2021-04-15 21:38:26 | [diff] [blame] | 59 | * [Chrome Beta] `~/Library/Application Support/Google/Chrome Beta` |
Steve Kobes | 22fb19c | 2017-07-05 21:49:08 | [diff] [blame] | 60 | * [Chrome Canary] `~/Library/Application Support/Google/Chrome Canary` |
Peter Kvitek | b21d620 | 2024-10-04 12:06:04 | [diff] [blame] | 61 | * [Chrome for Testing] `~/Library/Application Support/Google/Chrome for Testing` |
Steve Kobes | 22fb19c | 2017-07-05 21:49:08 | [diff] [blame] | 62 | * [Chromium] `~/Library/Application Support/Chromium` |
| 63 | |
| 64 | (The canary channel suffix is determined using the `CrProductDirName` key in the |
| 65 | browser app's `Info.plist`.) |
| 66 | |
| 67 | ### Linux |
| 68 | |
| 69 | The default location is in `~/.config`: |
| 70 | |
| 71 | * [Chrome Stable] `~/.config/google-chrome` |
| 72 | * [Chrome Beta] `~/.config/google-chrome-beta` |
| 73 | * [Chrome Dev] `~/.config/google-chrome-unstable` |
Peter Kvitek | b21d620 | 2024-10-04 12:06:04 | [diff] [blame] | 74 | * [Chrome for Testing] `~/.config/google-chrome-for-testing` |
Steve Kobes | 22fb19c | 2017-07-05 21:49:08 | [diff] [blame] | 75 | * [Chromium] `~/.config/chromium` |
| 76 | |
| 77 | (The beta and dev channel suffixes are determined from `$CHROME_VERSION_EXTRA`, |
| 78 | which is passed by the [launch wrapper script](https://cs.chromium.org/chromium/src/chrome/installer/linux/common/wrapper?q=CHROME_VERSION_EXTRA).) |
| 79 | |
| 80 | The `~/.config` portion of the default location can be overridden by |
| 81 | `$CHROME_CONFIG_HOME` (since M61) or by `$XDG_CONFIG_HOME`. |
| 82 | |
| 83 | Note that `$XDG_CONFIG_HOME` affects all applications conforming to the |
| 84 | [XDG Base Directory Spec](https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html), |
| 85 | while `$CHROME_CONFIG_HOME` is specific to Chrome and Chromium. |
| 86 | |
| 87 | ### Chrome OS |
| 88 | |
| 89 | The default location is: `/home/chronos` |
| 90 | |
| 91 | ### Android |
| 92 | |
| 93 | The default location comes from |
Steve Kobes | 4966641 | 2017-07-06 01:02:49 | [diff] [blame] | 94 | [Context.getDir](https://developer.android.com/reference/android/content/Context.html#getDir%28java.lang.String,%20int%29) |
Steve Kobes | 22fb19c | 2017-07-05 21:49:08 | [diff] [blame] | 95 | and is specific to the app. |
| 96 | |
| 97 | Example: `/data/user/0/com.android.chrome/app_chrome` |
| 98 | |
| 99 | ### iOS |
| 100 | |
| 101 | The default location is inside the application support directory in the app |
| 102 | sandbox. |
| 103 | |
| 104 | * [Chrome] `Library/Application Support/Google/Chrome` |
| 105 | * [Chromium] `Library/Application Support/Chromium` |
| 106 | |
| 107 | ## Overriding the User Data Directory |
| 108 | |
| 109 | ### Command Line |
| 110 | |
Zhaoyang Li | f632baa | 2021-08-06 16:33:01 | [diff] [blame] | 111 | On most platforms, the user data directory can be overridden by passing the |
Steve Kobes | 22fb19c | 2017-07-05 21:49:08 | [diff] [blame] | 112 | `--user-data-dir` command-line flag to the Chrome binary. |
| 113 | |
Zhaoyang Li | f632baa | 2021-08-06 16:33:01 | [diff] [blame] | 114 | The override happens in `chrome/app/chrome_main_delegate.cc`. Platforms not |
| 115 | building with the file may not have implemented the override. Overriding the |
| 116 | user data directory via the command line is not supported on iOS. |
| 117 | |
Steve Kobes | 22fb19c | 2017-07-05 21:49:08 | [diff] [blame] | 118 | Example: |
| 119 | |
| 120 | * [Windows] `chrome.exe --user-data-dir=c:\foo` |
| 121 | * [Linux] `google-chrome --user-data-dir=/path/to/foo` |
| 122 | |
| 123 | ### Environment (Linux) |
| 124 | |
| 125 | On Linux, the user data directory can also be overridden with the |
| 126 | `$CHROME_USER_DATA_DIR` environment variable. |
| 127 | |
| 128 | The `--user-data-dir` flag takes precedence if both are present. |
| 129 | |
| 130 | ### Chrome Remote Desktop sessions (Linux) |
| 131 | |
Yuwei Huang | 6c8d6ad | 2022-08-02 21:25:25 | [diff] [blame] | 132 | [Chrome Remote |
| 133 | Desktop](https://support.google.com/chrome/answer/1649523) (CRD) used to set |
| 134 | `$CHROME_USER_DATA_DIR` or `$CHROME_CONFIG_HOME` on the virtual session on a |
| 135 | Linux host, since a single Chrome instance cannot show windows on multiple X |
| 136 | displays, and two running Chrome instances cannot share the same user data |
| 137 | directory. However, with the obsolescence of `dbus-x11`, most modern Linux |
| 138 | distros have lost the ability to simultaneously run multiple graphical sessions |
| 139 | for the same user without running into difficult-to-trace dbus cross talk |
| 140 | issues, and Chrome can only be run on a single X display per user in reality. |
| 141 | Therefore, CRD no longer sets these environment variables for new installations |
| 142 | after CRD host M105. |
Steve Kobes | 22fb19c | 2017-07-05 21:49:08 | [diff] [blame] | 143 | |
Yuwei Huang | 6c8d6ad | 2022-08-02 21:25:25 | [diff] [blame] | 144 | The CRD host will continue to set these environment variables if either |
| 145 | `chrome-config/` or `chrome-profile/` exists in |
| 146 | `~/.config/chrome-remote-desktop/`. If you want to use the local Chrome profile |
| 147 | in CRD sessions, quit Chrome and delete these folders from |
| 148 | `~/.config/chrome-remote-desktop/`, then reboot the host device. |
Steve Kobes | 22fb19c | 2017-07-05 21:49:08 | [diff] [blame] | 149 | |
| 150 | ### Writing an AppleScript wrapper (Mac OS X) |
| 151 | |
| 152 | On Mac OS X, you can create an application that runs Chrome with a custom |
| 153 | `--user-data-dir`: |
| 154 | |
| 155 | 1. Open Applications > Utilities > Script Editor. |
| 156 | |
| 157 | 2. Enter: |
| 158 | |
| 159 | ``` |
| 160 | set chrome to "\"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome\"" |
| 161 | set userdatadir to "\"$HOME/Library/Application Support/Google/Chrome Alt\"" |
| 162 | do shell script chrome & " --user-data-dir=" & userdatadir & " > /dev/null 2>&1 &" |
| 163 | ``` |
| 164 | |
| 165 | 3. Modify as needed for your installation path, Chrome versus Chromium, and |
| 166 | desired user data directory. |
| 167 | |
| 168 | 4. Save the script in your Applications directory with the file format |
| 169 | "Application". |
| 170 | |
| 171 | 5. Close the Script Editor, find your newly created application, and run it. |
| 172 | This opens a Chrome instance pointing to your new profile. |
| 173 | |
| 174 | If you want, you can give this application the same icon as Chrome: |
| 175 | |
| 176 | 1. Select the Google Chrome application and choose File > Get Info. |
| 177 | 2. Select the icon at the top left of the info dialog. You will see a blue |
| 178 | highlight around the icon. |
| 179 | 3. Press ⌘C to copy the icon. |
| 180 | 4. Open the info dialog for the new application and select the icon in the |
| 181 | top left. |
| 182 | 5. Press ⌘V to paste the copied icon. |
| 183 | |
| 184 | ## User Cache Directory |
| 185 | |
| 186 | On Windows and ChromeOS, the user cache dir is the same as the profile dir. |
| 187 | (The profile dir is inside the user data dir.) |
| 188 | |
| 189 | On Mac OS X and iOS, the user cache dir is derived from the profile dir as |
| 190 | follows: |
| 191 | |
| 192 | 1. If `Library/Application Support` is an ancestor of the profile dir, the user |
| 193 | cache dir is `Library/Caches` plus the relative path from `Application |
| 194 | Support` to the profile dir. |
| 195 | 2. Otherwise, the user cache dir is the same as the profile dir. |
| 196 | |
| 197 | Example (Mac OS X): |
| 198 | |
| 199 | * [user data dir] `~/Library/Application Support/Google/Chrome` |
| 200 | * [profile dir] `~/Library/Application Support/Google/Chrome/Default` |
| 201 | * [user cache dir] `~/Library/Caches/Google/Chrome/Default` |
| 202 | |
| 203 | On Linux, the user cache dir is derived from the profile dir as follows: |
| 204 | |
| 205 | 1. Determine the system config dir. This is `~/.config`, unless overridden by |
| 206 | `$XDG_CONFIG_HOME`. (This step ignores `$CHROME_CONFIG_HOME`.) |
| 207 | 2. Determine the system cache dir. This is `~/.cache`, unless overridden by |
| 208 | `$XDG_CACHE_HOME`. |
| 209 | 3. If the system config dir is an ancestor of the profile dir, the user cache |
| 210 | dir is the system cache dir plus the relative path from the system config |
| 211 | dir to the profile dir. |
| 212 | 4. Otherwise, the user cache dir is the same as the profile dir. |
| 213 | |
| 214 | Example (Linux): |
| 215 | |
| 216 | * [user data dir] `~/.config/google-chrome` |
| 217 | * [profile dir] `~/.config/google-chrome/Default` |
| 218 | * [user cache dir] `~/.cache/google-chrome/Default` |
| 219 | |
| 220 | On Android, the user cache directory comes from |
Steve Kobes | e26f53bd | 2017-07-06 00:15:02 | [diff] [blame] | 221 | [Context.getCacheDir](https://developer.android.com/reference/android/content/Context.html#getCacheDir%28%29). |