Configure Proxy for Chromium and Google Chrome From Command Line on Linux
In this tutorial, I will show you how to configure proxy settings of Chromium and Google Chrome browser from the command line on Linux. This little trick is very handy in some circumstances. As you may already know, the Linux version of Chromium and Google Chrome browser does not support configuring proxy in a graphical way. A Windows user can change proxy settings in Chromium and Google Chrome by going to Settings > Advanced > System and click the Change proxy settings button to configure it. However, this button on Linux is grayed out so Linux users can not change proxy in this way.
Normally, users need to install extensions like Proxy SwitchyOmega in order to configure it in graphical interface. That’s Okay for most people, but it’s not convenient for those who can’t access the Chrome Web store in the first place. Google search and Chrome Web store are blocked in some countries like China.
If you use Chromium or Google Chrome browser on Linux, then you can configure proxy for your browser from the command line and you don’t have to install extensions like Proxy SwitchyOmega. Note that this tutorial assumes you have a proxy server like Shadowsocks running on a remote server.
Configure Proxy From Command Line
I use Google Chrome as an example and it applies to Chromium as well. You can start Google Chrome from the command line like below
google-chrome
To start it with proxy, use --proxy-server
option. For example, run the following command to start it with socks5 proxy.
google-chrome --proxy-server="socks5://127.0.0.1:1080"
Chromium and Google Chrome support HTTP, HTTPS, socks4 and socks5 proxy. To set a HTTPS proxy, run the following command.
google-chrome --proxy-server="https://proxy-ip:proxy-port"
You can also set an alias so next time you don’t have to type a long command. To create command alias, edit .bashrc
file
nano ~/.bashrc
Find the alias lines in this file and add the following alias definition to it.
alias google-chrome='google-chrome --proxy-server="proxy-scheme://proxy-ip:proxy-port"'
Save this file. Now close your terminal and re-open it. Then enter google-chrome
command in the terminal, you will see chromium browser is now using a proxy to connect to the Internet.
Note: On Some Linux distributions such as Ubuntu, The command to start Chromium browser is chromium-browser
.
Install Proxy SwitchyOmega extension
Some users can use VPN to access Chrome store and install Proxy SwitchyOmege extension, but in some area, VPN is blocked. So being able to configure proxy from the command line is very handy for those who can’t access chrome web store.
Once the proxy is working, you can go to chrome Web store and install Proxy SwitchyOmega. Notice that if you are going to use SwitchOmega, then you need to remove the proxy options specified from command line. They can’t work with each other.
I like Proxy SwitchyOmega because it has the ability to detect failed resources on web pages and this can really help web developers or webmasters.
Chromium and Google Chrome Browser also support proxy autoconfiguration URL with the --proxy-pac-url
option. For more command line usage , see the man page.
man chromium man google-chrome
To see how to set up your own Shadowsocks proxy server, check out the following post.
I hope this tutorial helped you configure Google Chrome and Chromium proxy from the command line on Linux. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks. Take care.
how to switch on/off proxy without a restart when running `google-chrome –proxy-server=”socks5://127.0.0.1:1080″` ? appreciate for helping we chinese people !
I don’t know.
I think you can install the SwitchyOmega extension after switching on proxy. Then you don’t need to add
–proxy-server=”socks5://127.0.0.1:1080″
to thegoogle-chrome
command anymore.Here’s a head scratcher for you: On CentOS 8, I am trying to set up proxy bypass (no_proxy).
If I use an IP definition like 10.20.30.0/24, it does not work – even if I use the IP in the browser.
If I use a wild-card name like *.foo.bar.org, it works, but not everything under that should be bypassed.
This is the big problem.
The IPs are the ones that should bypass the proxy.
The server FQDNs span multiple IP subnets, so bypassing by name is not the right way to define it.
Any suggestions ?
10.20.30.* should work. Most … applications wont read cidr notation.