The fastest way to share directories under Linux

Source: Internet
Author: User

The fastest way to share directories under Linux is Chszs, without the permission of bloggers to reprint. Permission to reprint should be marked by the author and blog home: Http://blog.csdn.net/chszs

Build FTP, or build network File system, these methods can realize the directory sharing of Linux. But both the FTP and the network file system are too powerful, so they have some inconvenient places. For example, do you want to quickly share a directory of Linux systems to the entire project team and want to do it in a minute?

Very simple, use simplehttpserver.

Python is often built into a variety of Linux distributions, so it's easy to use this approach. This method is also valid on other OSes (such as Windows), but it is a bit cumbersome to build a Python environment first.

Simplehttpserver is a Python 2 module that is a Python Web server. It has been incorporated into the Http.server module in Python 3. The usage of simplehttpserver in Python 3 is similar to that used in Python 2, this article takes Python 2 as an example.

Simplehttpserver has a feature that if there is index.html in the directory to be shared, the index.html file is considered the default home page, and if no index.html file exists, the entire directory list is displayed.

Simplehttpserver How to use

1) Go to the directory you want to share
2) Execute command python-m simplehttpserver port number
Note: 8000 ports are used by default for the non-populated port number.
3) browser access to the host address: Http://IP: Port number/

Example: Executing a command

# cd /home/abc# python -m SimpleHTTPServer 8000Serving HTTP on 0.0.0.0 port 8000 ...192.168.20.33 - - [09/Jan/2016 15:13:28] "GET / HTTP/1.1" 200 -192.168.20.33 - - [09/Jan/2016 15:13:33] code 404, message File not found192.168.20.33 - - [09/Jan/2016 15:13:38] "GET /favicon.ico HTTP/1.1" 404 -192.168.20.33 - - [09/Jan/2016 15:13:54] "GET /jdk-7u79-linux-x64.tar.gz HTTP/1.1" 200 -

The browser opens and you can see the following:

Click jdk-7u79-linux-x64.tar.gz to download the success.

Also pay attention to the firewall factors of Linux when using. Like Ubuntu, if you use port 8000, you have to enable this port:

# ufw allow 8000

Close this port when you are finished using it:

# ufw delete allow 8000

The fastest way to share directories under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.