The following details a procedure to use tor for any commands used on the command line in Linux. The test env here is a Debian server.
Install tor:
# apt-get install tor
You should create a hashed control password for tor:
#tor --hash-password 'mypassword' Apr 22 21:00:14.198 [notice] Tor v0.2.4.27 (git-412e3f7dc9c6c01a) running on Linux with Libevent 2.0.19-stable and OpenSSL 1.0.1e. Apr 22 21:00:14.198 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning Apr 22 21:00:14.206 [warn] You are running Tor as root. You don't need to, and you probably shouldn't. 16:A08B4CD129C38494608095E8CB6E3CF6FD61987221130F81E49F28783D
Now setup tor options in the control file at /etc/tor/torrc so that it contains the following:
ControlPort 9051 CookieAuthentication 0 HashedControlPassword 16:A08B4CD129C38494608095E8CB6E3CF6FD61987221130F81E49F28783D
Now, Restart the tor service:
service tor restart
Test the current ip:
# curl ifconfig.me 2>/dev/null
196.152.33.228
Now test the torrized ip:
# torify curl ifconfig.me 2>/dev/null 162.247.72.212
To get a new ip, do this:
echo -e 'AUTHENTICATE "mypassword"\r\nsignal NEWNYM\r\nQUIT' | nc 127.0.0.1 9051
Here, you’re providing the password which you created earlier.
Test the new ip:
# torify curl ifconfig.me 2>/dev/null 77.109.141.138
Joel G Mathew, known in tech circles by the pseudonym Droidzone, is an opensource and programming enthusiast.
He is a full stack developer, whose favorite languages are currently Python and Vue.js. He is also fluent in Javascript, Flutter/Dart, Perl, PHP, SQL, C and bash shell scripting. He loves Linux, and can often be found tinkering with linux kernel code, and source code for GNU applications. He used to be an active developer on XDA forums, and his tinkered ROMS used to be very popular in the early 2000s.
His favorite pastime is grappling with GNU compilers, discovering newer Linux secrets, writing scripts, hacking roms, and programs (nothing illegal), reading, blogging. and testing out the latest gadgets.
When away from the tech world, Dr Joel G. Mathew is a practising ENT Surgeon, busy with surgeries and clinical practise.