# How to edit Tor circuit in shell

**URL:** <https://forum.torproject.org/t/how-to-edit-tor-circuit-in-shell/955>\
**Category:** Core Tor\
**Tags:** tor\
**Created:** [December 1, 2021, 10:56pm UTC](https://forum.torproject.org/t/how-to-edit-tor-circuit-in-shell/955 "2021-12-01T22:56:54Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aleff](https://forum.torproject.org/letter_avatar_proxy/v4/letter/a/58f4c7/32.png) [@Aleff](https://forum.torproject.org/u/Aleff)\
**Post date:** [December 1, 2021, 10:56pm UTC](https://forum.torproject.org/t/how-to-edit-tor-circuit-in-shell/955/1 "2021-12-01T22:56:54Z")

</div>

Hello, can i use some commands to edit my connection how i want?  
I need to do this in shell, exist some method for edit my circuit like choose how many nodes to use like just one or more than 3?  
Can i choose my exit node on the same command?  
Is extremely important that i don’t use some software, i must use shell(terminal)

---

<div class="post-metadata">

**Author:** ![atari](https://forum.torproject.org/user_avatar/forum.torproject.org/atari/32/392_2.png) [@atari](https://forum.torproject.org/u/atari)\
**Post date:** [December 2, 2021, 10:03am UTC](https://forum.torproject.org/t/how-to-edit-tor-circuit-in-shell/955/4 "2021-12-02T10:03:34Z")

</div>

Information taken from here: [Tor Project: manual](https://2019.www.torproject.org/docs/tor-manual.html.en)

There are ways to manipulate or steer your paths via `torrc`, you can specify explicit nodes, countries or an IP/IP-Ranges:

**ExitNodes** _node_ , _node_ , _…_

**MiddleNodes** _node_ , _node_ , _…_

**EntryNodes** _node_ , _node_ , _…_

**StrictNodes**  **0** | **1**

For playing around it might be fine, when you need anonymity it is not recommended, because you look completely different from the other network…

* * *

building a Tor-binary will let you choose how many hops are used when modifying ‘`#define DEFAULT_ROUTE_LEN 3`’ in ‘`src/core/or/or.h`’

on Debian/Ubuntu:

`sudo apt-get install build-essential libevent-dev libssl-dev zlib1g zlib1g-dev`  
`mkdir ~/tortest`  
`cd ~/tortest`  
`wget https://dist.torproject.org/tor-0.4.7.2-alpha.tar.gz`  
`tar xfz tor-0.4.7.2-alpha.tar.gz`  
`sed -i 's/DEFAULT_ROUTE_LEN\ 3/DEFAULT_ROUTE_LEN\ 6/' tor-0.4.7.2-alpha/src/core/or/or.h` | where 6 is your wanted hop number  
`./configure --prefix=~/tortest`  
`make`  
`make install`  
`cp etc/torrc.sample etc/torrc`  
—\> adjust your torrc to provide debug.log

`mkdir -p ~/tortest/var/lib/tor`  
`mkdir -p ~/tortest/var/log/tor`  
`~/tortest/bin/tor -f ~/tortest/etc/torrc`  
`curl --socks5-hostname localhost:9050 https://check.torproject.org/`

—\> see `~/tortest/var/log/tor/debug.log` for ‘`exit circ (length `’

---

<div class="post-metadata">

**Author:** ![Aleff](https://forum.torproject.org/letter_avatar_proxy/v4/letter/a/58f4c7/32.png) [@Aleff](https://forum.torproject.org/u/Aleff)\
**Post date:** [December 2, 2021, 2:00pm UTC](https://forum.torproject.org/t/how-to-edit-tor-circuit-in-shell/955/5 "2021-12-02T14:00:05Z")

</div>

Thanks for the reply, i think that you have understand correctly what i need but i have some problems with your solution.  
I have created a directory with mkdir and downloaded the Tor Project dist, but after `make install` command nothing else works.

When i run `cp tor/torrc.sample tor/torrc` i have No such file or directory however i found this guide [How to install tor frome source code](https://community.torproject.org/onion-services/setup/install/) that i tried to follow but without success, it however doesn’t work because if i send just `tor` in Shell (after `make install` command) it doesn’t find nothing and if i run tor from `src/app/tor` it doesn’t even work…

What i wrong?

---

<div class="post-metadata">

**Author:** ![Aleff](https://forum.torproject.org/letter_avatar_proxy/v4/letter/a/58f4c7/32.png) [@Aleff](https://forum.torproject.org/u/Aleff)\
**Post date:** [December 2, 2021, 2:00pm UTC](https://forum.torproject.org/t/how-to-edit-tor-circuit-in-shell/955/6 "2021-12-02T14:00:07Z")

</div>

And an another important thing is that i must can change this config file when tor is installed on the machine whenever i want.

For example…  
Now i install Tor and i have 3 default node  
I edit this setting with 6 node circuit  
I run Tor and now i have 6 node circuit  
I edit this setting with 2 node circuit  
I run Tor and now i have 2 node circuit  
And more…

---

<div class="post-metadata">

**Author:** ![atari](https://forum.torproject.org/user_avatar/forum.torproject.org/atari/32/392_2.png) [@atari](https://forum.torproject.org/u/atari)\
**Post date:** [December 2, 2021, 2:34pm UTC](https://forum.torproject.org/t/how-to-edit-tor-circuit-in-shell/955/7 "2021-12-02T14:34:42Z")

</div>

> [@atari](#):
>
> `cp etc/torrc.sample etc/torrc`

sorry - edited this one - there was a typo and that one

> [@atari](#):
>
> `~/tortest/bin/tor -f ~/tortest/etc/torrc`

then it should work

---

<div class="post-metadata">

**Author:** ![atari](https://forum.torproject.org/user_avatar/forum.torproject.org/atari/32/392_2.png) [@atari](https://forum.torproject.org/u/atari)\
**Post date:** [December 2, 2021, 2:34pm UTC](https://forum.torproject.org/t/how-to-edit-tor-circuit-in-shell/955/8 "2021-12-02T14:34:45Z")

</div>

probably this won’t work so easy - you could compile different versions for different hop-settings - maybe there is a more clever approach, but can’t provide you with…

---

<div class="post-metadata">

**Author:** ![Aleff](https://forum.torproject.org/letter_avatar_proxy/v4/letter/a/58f4c7/32.png) [@Aleff](https://forum.torproject.org/u/Aleff)\
**Post date:** [December 2, 2021, 3:07pm UTC](https://forum.torproject.org/t/how-to-edit-tor-circuit-in-shell/955/9 "2021-12-02T15:07:35Z")

</div>

in `~/tortest/etc/` i have just tor directory, i don’t have torrc file and i seen in else directories and i haven’t found torrc file anywhere, except for etc/tor/torrc.sample that i found correctly…

However, if i understand you do you mean, do you think that can i change this option on torrc file?

In case of yes what i must write inside?

Because if exist some command like `ExitNodes {ca} StrictNodes 1` (it is just for an example) where i can declare something like `Route_Len 6` everything is done… but i didn’t find nothing like this on the [manual page](https://2019.www.torproject.org/docs/tor-manual.html.en)

---

<div class="post-metadata">

**Author:** ![atari](https://forum.torproject.org/user_avatar/forum.torproject.org/atari/32/392_2.png) [@atari](https://forum.torproject.org/u/atari)\
**Post date:** [December 2, 2021, 5:07pm UTC](https://forum.torproject.org/t/how-to-edit-tor-circuit-in-shell/955/10 "2021-12-02T17:07:04Z")

</div>

`cp ~/tortest/etc/torrc.sample ~/tortest/etc/torrc`

Add  
`ExitNodes {ca}`  
`StrictNodes 1`  
and you will exit in Canada…

As far as I know you can’t change hops from config - you have to compile a corresponding binary with the specific `DEFAULT_ROUTE_LEN`

---

<div class="post-metadata">

**Author:** ![Aleff](https://forum.torproject.org/letter_avatar_proxy/v4/letter/a/58f4c7/32.png) [@Aleff](https://forum.torproject.org/u/Aleff)\
**Post date:** [December 2, 2021, 5:50pm UTC](https://forum.torproject.org/t/how-to-edit-tor-circuit-in-shell/955/11 "2021-12-02T17:50:40Z")

</div>

ok i discard this idea

i found online\*1 that the only one torrc command enable you to have a different number of circuit nodes is `HiddenServiceSingleHopMode 1` that need to have `HiddenServiceNonAnonymousMode 1`

that change default tor circuit with 3 nodes in an another with just 1 node but when i write it on torrc my tor browser doesn’t start because it have an error in loading tor circuit, do you have some idea how can i solve it?

source\*1: [What's new in Tor 0.2.9.8? | The Tor Project](https://blog.torproject.org/whats-new-tor-0298/)

---

<div class="post-metadata">

**Author:** ![gus](https://forum.torproject.org/user_avatar/forum.torproject.org/gus/32/16_2.png) [@gus](https://forum.torproject.org/u/gus)\
**Post date:** [December 2, 2021, 5:53pm UTC](https://forum.torproject.org/t/how-to-edit-tor-circuit-in-shell/955/12 "2021-12-02T17:53:37Z")

</div>

> [@Aleff](#):
>
> Is extremely important that i don’t use some software, i must use shell(terminal)

Can I ask what exactly are you trying to do?

---

<div class="post-metadata">

**Author:** ![Aleff](https://forum.torproject.org/letter_avatar_proxy/v4/letter/a/58f4c7/32.png) [@Aleff](https://forum.torproject.org/u/Aleff)\
**Post date:** [December 3, 2021, 10:04am UTC](https://forum.torproject.org/t/how-to-edit-tor-circuit-in-shell/955/13 "2021-12-03T10:04:55Z")

</div>

Sure i’m trying to change circuit nodes number on Tor Browser that it can change in 1 or 2 or more of 3 nodes.  
I know that this is not a good idea for anonymity but i’m trying to do it however for a study project and i don’t understand if it is possible or not…  
I found 2 methods for do it…

1. Change source code before installing tor, but it is not good for what i want to do because i need to can change nodes number when tor browser is installed.
2. Change, with torrc file, hop number(so nodes number) to one and yes, it is a good command but i don’t have what i want because i can’t change nodes number to 2 or to more of 3

Forgive me if my English is not good.  
I know that 3 nodes is the perfect circuit for the anonymity online but i need(i don’t know if “need” is the correct word to understand my necessity) do it for my study project

---

<div class="post-metadata">

**Author:** ![atari](https://forum.torproject.org/user_avatar/forum.torproject.org/atari/32/392_2.png) [@atari](https://forum.torproject.org/u/atari)\
**Post date:** [December 4, 2021, 9:45am UTC](https://forum.torproject.org/t/how-to-edit-tor-circuit-in-shell/955/14 "2021-12-04T09:45:44Z")

</div>

> [@Aleff](#):
>
> Change source code before installing tor, but it is not good for what i want to do because i need to can change nodes number when tor browser is installed.

1. You can use the downloaded Tor Browser and start it from command-line.

2. From a second command-line you can kill the tor process e.g. `killall tor`, when something like `psmisc` is installed.

3. Afterwards you start your compiled version of Tor with the specific hop settings. Make sure `9150` is set as socks port in `torrc`.

4. Repeat from 2. to change your hops…

After putting this in an interactive script/application using `dialog` / `ncurses` you will probably get you better grades than just the 1.-4. PoC…

---

<div class="post-metadata">

**Author:** ![Aleff](https://forum.torproject.org/letter_avatar_proxy/v4/letter/a/58f4c7/32.png) [@Aleff](https://forum.torproject.org/u/Aleff)\
**Post date:** [December 5, 2021, 10:04pm UTC](https://forum.torproject.org/t/how-to-edit-tor-circuit-in-shell/955/15 "2021-12-05T22:04:32Z")

</div>

I don’t want to change my hops, i want to change hops number from 3 to N

---

<div class="post-metadata">

**Author:** ![atari](https://forum.torproject.org/user_avatar/forum.torproject.org/atari/32/392_2.png) [@atari](https://forum.torproject.org/u/atari)\
**Post date:** [December 6, 2021, 12:57pm UTC](https://forum.torproject.org/t/how-to-edit-tor-circuit-in-shell/955/16 "2021-12-06T12:57:36Z")

</div>

> [@Aleff](#):
>
> I don’t want to change my hops, i want to change hops number from 3 to N

Probably then your only option is to modify the source code to accept changes to new\_route\_len() at runtime…

---

<div class="post-metadata">

**Author:** ![Aleff](https://forum.torproject.org/letter_avatar_proxy/v4/letter/a/58f4c7/32.png) [@Aleff](https://forum.torproject.org/u/Aleff)\
**Post date:** [December 6, 2021, 3:26pm UTC](https://forum.torproject.org/t/how-to-edit-tor-circuit-in-shell/955/17 "2021-12-06T15:26:28Z")

</div>

Ok, and how can i do what did you say?  
What i must to do, when tor is installed on my computer, to change route len with new\_route\_len() method?

An another question is, is necessary use tor source code or can i use TorBrowser?  
If i need tor source code, how can i install correctly to do what i need?

Thanks for the help

---

<div class="post-metadata">

**Author:** ![atari](https://forum.torproject.org/user_avatar/forum.torproject.org/atari/32/392_2.png) [@atari](https://forum.torproject.org/u/atari)\
**Post date:** [December 6, 2021, 5:15pm UTC](https://forum.torproject.org/t/how-to-edit-tor-circuit-in-shell/955/18 "2021-12-06T17:15:31Z")

</div>

If you want a software to behave different from default, you need to modify it.  
Like you do, when changing the `DEFAULT_ROUTE_LEN` in the source and compile it → This change is static and the binary will have the specified route-length baked in.

To make this length dynamic you need to modify way more things in the source → Read the corresponding source, adapt it according to your needs and compile it…

In other words, there is no easy way →

Compile

> [@Aleff](#):
>
> 3 to N

different versions or learn a little C…

---

<div class="post-metadata">

**Author:** ![Aleff](https://forum.torproject.org/letter_avatar_proxy/v4/letter/a/58f4c7/32.png) [@Aleff](https://forum.torproject.org/u/Aleff)\
**Post date:** [December 6, 2021, 5:30pm UTC](https://forum.torproject.org/t/how-to-edit-tor-circuit-in-shell/955/19 "2021-12-06T17:30:07Z")

</div>

Ok atari, thanks for your amazing help.
