How to easily transfer files between computers with croc

If you're looking for an easy command-line tool to transfer files between systems on the same LAN, Jack Wallen believes croc is the tool for the job.

You can transfer files between computers easily with croc

When I want to transfer files between computers on the same network, most of the time, I use the scp command. But when I want something a bit simpler to use, I turn to a very handy command-line tool called croc. With this easy-to-use tool, you can transfer files and folders from one system to another, without having to remember much in the way of commands. 

SEE: Hiring Kit: Linux Administrator (TechRepublic Premium)

Croc is a cross-platform file-sharing tool that creates a full-duplex communication layer between machines, so it doesn't require the addition of port forwarding. Croc can be installed on Linux, macOS and Windows, so you can transfer files between any system on your network.

I'm going to show you just how easy croc is to install and use.

What you'll need

I'll be demonstrating on two Linux machines, both of which are Ubuntu-based. If you're interested in installing croc on either macOS or Windows, you'll need to have either Scoop (Windows) or Homebrew (macOS) installed. You'll also need a user with admin (sudo) rights. Let's get to work.

How to install croc

To install croc on a Ubuntu-based distribution, download the .deb file with the command:

wget https://github.com/schollz/croc/releases/download/v9.4.2/croc_9.4.2_Linux-64bit.deb

Note: Make sure to check out the croc download page to ensure you're downloading the latest release.

You'll need to download that .deb file to all Ubuntu machines that will use croc. Once downloaded, install croc with:

sudo dpkg -i croc*.deb

How to use croc

Let's say you have a file named trtest you want to transfer from Machine A to Machine B. Log into Machine A, open a terminal window, change into the directory housing trtest, and issue the command:

croc trtest

After verifying the transfer (by hitting Y), the command will output a code to be used on the receiving machine, such as croc 7776-gorilla-london-turtle. Copy that entire code. 

Now, log into Machine B, open a terminal window, and paste the code you received from Machine A into the terminal. Hit Enter on your keyboard. You will be prompted to verify the transfer. Hit Y and the file will be received on Machine B.

If you don't want to depend on croc to generate random codes, you can tell it to use a specific code like so:

croc --code YOUR_CODE FILE

Where YOUR_CODE is a unique code and FILE is the file to transfer. 

To send a file with a specific code, on Machine A, issue the command:

croc send --code techrepublic_is_awesome trtest

To receive the file using the specific code, on Machine B issue the command:

croc techrepublic_is_awesome

And that's all there is to using croc. Even better, the same command works for files or folders, so you don't have to add any special options when sending folders.

Subscribe to TechRepublic's How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

Also see

windows-11-security-1.jpg

Illustration: Lisa Hornung/TechRepublic

By Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic, The New Stack, and Linux New Media. He's covered a variety of topics for over twenty years and is an avid promoter of open source. For more news about Jack Wallen, visit his website jackwallen....