
{"id":43604,"date":"2023-01-22T16:06:58","date_gmt":"2023-01-22T16:06:58","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=43604"},"modified":"2024-09-05T06:51:39","modified_gmt":"2024-09-05T06:51:39","slug":"transfer-file-ubuntu-22-04","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2023\/01\/transfer-file-ubuntu-22-04\/","title":{"rendered":"Stupid Easy Way to Transfer Small Files to or from Ubuntu 22.04"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/network-icon.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-43605\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/network-icon-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/network-icon-250x250.webp 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/network-icon-300x300.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/network-icon-600x600.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/network-icon-768x768.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/network-icon.webp 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>There are quite a few ways to transfer files between different machines. For Ubuntu and most other Linux, here&#8217;s an easy way for choice.<\/p>\n<p>Usually, I use a USB cable or a messenger app for transferring photo images between my personal PC and mobile devices.<\/p>\n<p>However, my USB cable is always NOT near at hand and I hate to scan QR code again and again on PC for logging 3rd app. In this case, creating a temporary http file server with Python is an easy and good choice.<\/p>\n<h3>Upside and downside<\/h3>\n<p>Python is pre-installed in most Linux Distros. <strong>So this is an universal method for Linux.<\/strong> It also works in Windows and macOS with Python programming language installed.<\/p>\n<p>As a simply http server, <i>any devices with a web browser<\/i> can download (or upload) files from\/to the server side either over local network or internet.<\/p>\n<p>However, http is NOT designed for transferring files. It&#8217;s OK to handle small files (e.g., photo images and short videos less than a few hundred MB). But for large files with a few GB or more file size, it may not work! As well, it&#8217;s NOT secure for accessing important files outside from local network.<\/p>\n<h3>Single command to create a Python http server:<\/h3>\n<p>For those who are new to Linux, user may first open file manager, navigate to the folder that contains the files to share with other device, right-click on blank area and select &#8220;<strong>Open in Termina<\/strong>l&#8221;.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/open-pics-terminal.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-43606\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/open-pics-terminal-600x339.webp\" alt=\"\" width=\"600\" height=\"339\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/open-pics-terminal-600x339.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/open-pics-terminal-300x169.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/open-pics-terminal-768x434.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/open-pics-terminal.webp 930w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>It will open a terminal window and automatically navigate to that folder as working directory.<\/p>\n<p>Or, you can also open terminal from start menu and run <code>cd<\/code> command to navigate directory. For example, run the command below to navigate to user&#8217;s Pictures folder:<\/p>\n<pre>cd ~\/Pictures<\/pre>\n<p>Then, <b>run the single command to start a http file server<\/b> (For some Linux, replace <code>python3<\/code> with <code>python<\/code> in command):<\/p>\n<pre>python3 -m http.server<\/pre>\n<p>By default, it listens to port 8000. If the port is already in use, use <code>python3 -m http.server 9090<\/code> to set another port number (change number 9090 as you want).<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/python3-httpserver.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-43607\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/python3-httpserver-600x169.webp\" alt=\"\" width=\"600\" height=\"169\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/python3-httpserver-600x169.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/python3-httpserver-300x84.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/python3-httpserver.webp 744w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>After that, visit <u>http:\/\/ip-address:8000<\/u> (change number 8000 if you set another port) in any device via a web browser. You can then open and\/or right-click save as to <b>download any file from that folder.<\/b><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/uploadserver-download.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-43608\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/uploadserver-download-600x364.webp\" alt=\"\" width=\"600\" height=\"364\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/uploadserver-download-600x364.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/uploadserver-download-300x182.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/uploadserver-download-768x466.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/uploadserver-download.webp 930w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<h3>Create python http server with upload support<\/h3>\n<p>1. If you want to send files from any device to Ubuntu Linux, open terminal and run command:<\/p>\n<pre>python3 -m pip install --user uploadserver<\/pre>\n<p><i>Install pip first via <code>sudo apt install python3-pip<\/code> if the command above does not work<\/i>. This command will install a Python module <a href=\"https:\/\/pypi.org\/project\/uploadserver\/\" target=\"_blank\" rel=\"noopener\">uploadserver<\/a>.<\/p>\n<p><b>NOTE: For Ubuntu 24.04, this <code>pip install<\/code> command does NOT work due to policy change. You may either follow this tutorial for <a href=\"https:\/\/ubuntuhandbook.org\/index.php\/2024\/03\/pip-install-error-ubuntu-2404\/\" target=\"_blank\" rel=\"noopener\">workaround<\/a>, or use the command below instead:<\/b><\/p>\n<pre>python3 -m pip install --user uploadserver --break-system-packages<\/pre>\n<p>2. Then open or navigate to your desired folder in terminal window, and <b>run command to create simple http file server with both download and upload support<\/b>:<\/p>\n<pre>python3 -m uploadserver<\/pre>\n<p><i>Also specify port number if you want, for example, <code>python3 -m uploadserver 9990<\/code><\/i><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/py-start-uploadserver.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-43609\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/py-start-uploadserver-600x178.webp\" alt=\"\" width=\"600\" height=\"178\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/py-start-uploadserver-600x178.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/py-start-uploadserver-300x89.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/py-start-uploadserver.webp 751w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>3. Finally, visit <u>http:\/\/ip-address:8000<\/u> in any device via web browser can access and download files. Or, go to <u>http:\/\/ip-address:8000\/upload<\/u> for uploading files.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/uploadserver-upload.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-43610\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/uploadserver-upload-600x364.webp\" alt=\"\" width=\"600\" height=\"364\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/uploadserver-upload-600x364.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/uploadserver-upload-300x182.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/uploadserver-upload-768x466.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/01\/uploadserver-upload.webp 930w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>For security reason, you may add a token authentication so client machines need to verify before being able to upload a file. To do so, run the command below instead in Ubuntu Linux:<\/p>\n<pre>python3 -m uploadserver -t password_here<\/pre>","protected":false},"excerpt":{"rendered":"<p>There are quite a few ways to transfer files between different machines. For Ubuntu and most other Linux, here&#8217;s an easy way for choice. Usually, I use a USB cable or a messenger app for transferring photo images between my personal PC and mobile devices. However, my USB cable is always NOT near at hand [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":43605,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[1317],"class_list":["post-43604","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-network"],"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/43604","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=43604"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/43604\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/43605"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=43604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=43604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=43604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}