Litecoin-cli - how to run it on Ubuntu?

Hi! I would like to run litecoin-cli so I can send different combinations of passphrase to unlock my wallet (I remember words used, but don’t remember combination). I’m on Ubuntu (Please note: I’m not good in Linux and programming).

In my home directory I’ve got these folders: litecoin-0.10.4.0 and .litecoin.

When in terminal and in home_directory/litecoin-0.10.4.0/bin I type ./litecoin-cli I receive information about Litecoin Core RPC etc. Then, for example, when I want to (according to this API: https://litecoin.info/Litecoin_API) check LTC address (by typing “litecoin-cli validateaddress litecoinaddress” in terminal) I receive: “litecoin-cli: command not found” (translating information from my native language).

I’ve read, that for litecoind two files must be created to run it: litecoin.conf and data folder. Does the same apply to litecoin-cli? In which folders must I create litecoin.conf and data folder - in litecoin-0.10.4.0/bin or in .litecoin?

Thank you in advance! P.

having a hard time running litecoin in linux myself as well so I saved it for another day but I do remember something about you cannot run “applications” in Linux from a root directory…you have to use a user directory or something like that…then all should work fine…thats how I got cgminer working in linux anyway…

bakd247, thank you for your reply. As I mentioned above, I’m not good in Linux, but on the assumption that litecoin-qt is an “application” I have no problem starting it from the terminal (writing ./litecoin-qt command being in appropriate directory), so probably that is not an issue…

Please try the command

Let us know if there’s a solution!

If you want to run Litecoin Core in terminal, then you have to symlink the daemon and cli binaries. Only then can you do something like ./litecoind to start Litecoin, without specifying the directory that you are storing the binaries in.

So to do this, first you need to find out the location of you Litecoin directory:

cd litecoin-folder
pwd

Then once you’ve found this out, you have to symlink it:

ln -s litecoin-folder/litecoind /usr/bin/litecoind
ln -s litecoin-folder/litecoin-cli /usr/bin/litecoin-cli
ln -s litecoin-folder/litecoin-qt /usr/bin/litecoin-qt

(where litecoin-folder is the directory you found when you typed pwd)

The litecoin.conf and the .litecoin/ data directory will be automatically be created when you first start litecoin by starting the litecoind daemon (by doing: ./litecoind). To use any of the command line options, you must use ./litecoin-cli.

losh11, thank you for your reply. I managed to run litecoin-cli the similar way. This is for others, who might find it helpful:

  1. litecoin.conf and data folder have to in .litecoin folder.
  2. Then you have to run litecoind, by, while in terminal, going to the directory where litecoind is and typing ./litecoind -daemon → that starts litecoin server.
  3. Now, after a while, you can use litecoin-cli - type ./litecoin-cli and an appropriate command from litecoin API (https://litecoin.info/Litecoin_API).
1 Like

You don’t have to symlink it, you can either cd into the bin directory or put it in your bash profile path.
If you use a command-line option to point to the conf file, that file will probably point to the data file, if you’ve already run litecoin-qt and synched with the blockchain.

You don’t want to have to re-synch the whole bkchain unnecessarily.

…in other words start the daemon first then start the cli?

Hm. I’m sure that’s documented somewhere :wink:

would suggest a couple of additions to tthis

(*: whever the documentation is for litecoind & litecoin-cli is on github)

first if you have already used the gui to synch the blockchain and configure your wallet, and you did not use the default location for the data directory (~/.config/Litecoin) then use something like this:

(not sure of the exact bash syntax here)
./litecoind -datadir=/home/$USER/sw/mine/Litecoin/data/

…check the top of the output to make sure that it then finds your data folder and if so it should find the wallet properly.

I think that it always looks in .config for the litecoin config file.

If you run litecoind without any flags it will use the defaults for both the config file and the data folder. My config file is in a (custom) data folder as pointed above.

So using the litecoind that I listed above,this is what I get:

Using RdRand as an additional entropy source
Default data directory /home/$USER/.litecoin
Using data directory /home/$USER/sw/mine/Litecoin/data
Config file: /home/$USER/sw/mine/Litecoin/data/litecoin.conf
Config file arg: [main] listen=“1”
Setting file arg: wallet = [$WALLET]
Cmd-line arg: datadir=“/home/$USER/sw/mine/Litecoin/data/”

…it’s ignoring the Litecoin-Qt.conf file that is in the default data folder (~/.config/Litecoin).
Which has this string in it.
strDataDir=/home/$USER/sw/mine/Litecoin/data

which has one problem as I can see:
strDataDir should be just
DataDir.

Since I’m giving it DataDir in the cli, it apparently says “fine, I’ll just go there and look for the data” and it works fine.

since litecoin-cli is apparently just a remote-management tool for the daemon, I’ll just control-c out of the daemon and hope for the best. And as often the case, it catches that cntl-c and shuts down cleanly. But it is clear that a lot of things are running in litecoind that we probably want better control of (without using the gui, since we’re not sure that it’s working correctly), so we want it to read our choice of config file and go from there.

So pulling up the options for litecoind
litecoind -help

we see
-conf=
Specify path to read-only configuration file. Relative paths will be
prefixed by datadir location. (default: litecoin.conf)

and indeed without specifying that it will look for the conf file in the -datadir folder (which explains what happened above). You either have to specify the datadir in the litecoind call, or check the name of the conf file in the default data location to see if it points to the correct conf file that the gui finds when you click “open configuration file” in the gui.

./litecoind -conf=/home/$USER/.config/Litecoin/Litecoin-Qt.conf

Then we run into the problem that Litecoin-Qt.conf is the wrong format for litecoind. It will work with the GUI clearly. Because otherwise it would point to the wrong datadir. But it won’t work with the litecoind. Because it has a block label in it that is “out of date” or something. Change that block label from [General] to [main] (or comment # it out all together.).

also
#strDataDir=/home/$USER/sw/mine/Litecoin/data
datadir=/home/$USER/$USER/mine/Litecoin/data

(save the new file as litecoin.conf and litecoind probably won’t even require the -conf flag)

./litecoind -conf=/home/$USER/.config/Litecoin/litecoin.conf

Then try the daemon again.

So that also works (it finds the blockchain and the wallet)

Now try litecoind with no flags…and now we have a new problem…

Default data directory /home/$USER/.litecoin
Using data directory /home/$USER/.litecoin

…and indeed there is a whole new data folder at that location.
with I take it all the other stuff that litecoind needs.

But there is not a litecoin.conf file in that data tree.

There is however some other interesting stuff…in the litecoind output…

Using the ‘shani(1way,2way)’ SHA256 implementation
Using RdSeed as additional entropy source
Using RdRand as an additional entropy source
Default data directory /home/$USER/.litecoin
Using data directory /home/$USER/.litecoin
Config file: /home/$USER/.litecoin/litecoin.conf (not found, skipping)

…so beware.
The litecoin daemon will not configure a litecoin.conf by default.
if it is not found, it will then probably use the default values for everything.

So this makes life somewhat easier for me.

Instead of using ~/.config/Litecoin as the litecoin.conf folder, I can probably use ~/.litecoin…then not have to use flags with the daemon…so let’s copy the litecoin.conf file over…yep, that works, so now all you have to do is figure out how to connect to the deamon with litecoin-cli.

And remember that the conf file flags will overwrite the gui flags. But the idea here is to make sure that the GUI and the deamon both use the same litecoin.conf file. Which is in my custom data folder. That will mean having to restart the GUI to load the changed flags that are in the custom data folder litecoin.conf file. But you won’t have to worry about whether those flags are getting to the deamon based on the settings in the GUi. You can just run the daemon and check the console output. Then look at the GUI logfile and see if that text matches what you see in the daemon output. You’d have to restart the GUI anyway if you make changes there (to the flag values) but you would not know if those changes are actually getting to the daemon unless there is an output from the daemon that shows up in the gui log file.

So now sort-out which location the GUI is pulling the litecoin.conf file from when you click “open configuration file” in the GUI. The easiest way to do that is to give the conf file a different name in the custom data folder (a copy of litecoin.conf with a new name) point to that copy in the default folder conf file, and see which file is opened in the GUI open config file call. Because clearly the default location of the conf file is different between the daemon and the gui. As we now have two default locations. One with the GUI, another with the daemon. The GUI default config file probably has to have a -Qt in the name. So the other option is to just call litecoind with a -conf flag and let the GUI use its default location.

If either the daemon or the GUI don’t load the correct wallet config properly on startup, then they are using the wrong data folder. This version of the litecoin full node uses the Berkley 4.8 database, there is also a SQLlite database. They probably don’t have the same capabilities and features. The GUI will restore the wallet to the same state, open & closed, locked vs unlocked that it was in when the GUI was properly shut down. If you want to mine also, you have to enable incoming connections.

litecoind default config dir is ~/.litecoin
litecoin-gui default config dir is ~/.config/Litecoin
These are the corresponding default data locations.
The sw expects to find the litecoin.conf file in the data location.

These can be change in the command-line calls.

I’ve yet to get incoming connections in the gui when I got them in the bitcore full node, at least using my phone as the internet connection. Will update this when I get incoming connections using the litecoin gui. You have to have the blockchain fullly synched (or pruned) to mine on a full-node, it won’t accept incoming connections until it can mine. But that also assumes that your network connection will support incoming connections.

“but why would you want to mine on a full-node in 2025 anyway”