Thursday, September 28, 2023
 Popular · Latest · Hot · Upcoming
rated 0 times [  1] [ 0]  / answers: 1 / hits: 20305  / 8 Months ago, sat, february 18, 2023, 11:07:43

I would like to be able to access the files on my Ubuntu laptop from my Android phone and tablet. Ideally, I would want to do this over my own secure Wlan and then over sftp or Samba shares.
Since there is no Wlan that is accessible to me where I want to do this, I want to create that Wlan network with the laptop's built in wifi or a Wifi USB stick.
This Wlan should be accessible by ordinary Android devices.

Here is the problem: when choose "create new wireless network" in the network manager applet, the network created is NOT available in any of my mobile devices. I am told this is because it is an "ad hoc" network which is not supported by these devices.

There are some instructions on how to create managed networks (not sure if this is the correct term) but those look very complex and often differ among each other. Also, all of these instructions are for making the internet connection of the laptop available over Wifi - which I do not need.
All I need is for the Wifi network to make the notebook files available, so the only host that needs to be accessible over this Wlan is the notebook.

Is there a (hopefully) easy way to just start such a WLan network?
If not, would it be possible to achieve what I want with some other kind of hardware (other than a simple USB Wifi stick), so I can create a Wlan where my laptop is the only accessible host?

I think with the increasing number of mobile devices, and with both the mobile phones/tables AND the laptop having their Wlan hardware built right in, it is odd that there is no easy way to connect them directly and without the necessity that both devices have access to some other Wlan.

EDIT: I think this may be not, as suggested a duplicate, since the answer to the other question, as well as many other often slightly different recipes, try to share the internet connection of the computer that provides the access point, while I just want to access files on this computer or use services there, simply using the IP address. So what I was looking for is the easiest way to achieve this. I think I may have found a solution in the meantime which is less complex as the answer for the suggested duplicate, but I cannot seem to create an answer here.

More From » wireless


Below are what I believe are the minimal steps to achieve what I wanted. For now, the steps only work for an additional Wifi USB stick, not the built-in Wifi hardware. I will edit this as I learn more ...

Install and set up hostapd

In order to make the Wifi hardware (the one built into the laptop or some additional Wifi USB stick) work in non ad-hoc mode, the hostapd software is necessary. Note that for this to work at all, the Wifi hardware needs to be supported by the hostapd software and the hardware needs to be able to support non ad-hoc mode.

  1. Install software with sudo apt-get install hostapd

  2. Find the name of the network interface that corresponds to the Wifi hardware. For an additional Wifi USB stick this may be wlan1 or similar. The command ifconfig will show all availble network interfaces.

  3. Create the config file /etc/hostapd/hostapd.conf (e.g. with the command gedit /etc/hostapd/hostapd.conf) with the following content where you replace <INTERFACENAME> with the name found in step 2, <MYSSID> with the name you chose for your network, <CODE> with the two-letter code of your country (e.g. US), <MODE> with the Wifi network mode (e.g. g) and channel with a valid channel number (e.g. 3). Alternately, the lines for hw_mode and channel can be left out entirely. Replace <MYPASSPHRASE> with a phassphrase you like (but avoid umlauts or accented characters).


    See for more information.

  4. Run the command sudo hostapd -d /etc/hostapd/hostapd.conf. This should start the Wifi network and it should be possible already to connect to this network from the mobile device: the network with the SSID you assigned should show up in the list and after entering the password, the device should connect to the network. However, the device will not get an IP address and so no real data transfer is possible yet. Terminate the command by pressing Ctl-C

Install DHCP and set up the network

In order to actually transfer data between the mobile device and the laptop, the network must know which range of IP addresses it should use and a program is needed to assign IP addresses to any device that wants to connect.

  1. Use command sudo apt-get install isc-dhcp-server to install the DHCP server.

  2. Edit the interface configuration file /etc/network/interfaces and add the following to the end:

    iface <INTERFACENAME> inet static

  3. Edit the DHCP configuration file /etc/dhcp/dhcpd.conf and add the following to the end.

    subnet netmask {
    option broadcast-address;
    option routers;

    If you know the MAC address of the mobile device and want assign a fixed IP address to it, you can add the following lines before the closing brace, replacing XX:XX:XX:XX:XX:XX by the MAC address. This will assign the fixed IP address

      host device1 {
    hardware ethernet XX:XX:XX:XX:XX:XX;

  4. Bring up the the interface with the command sudo ifup <INTERFACENAME>

  5. Start the DHCP server with the command sudo dhcpd -f -d <INTERFACENAME> (this will keep running until you terminate with Ctrl-C and show log messages to the terminal)

  6. Start the managed network with the command sudo hostapd -d /etc/hostapd/hostapd.conf

If all goes well you should now be able to connect from a mobile device to that Wifi network and the device should be assigned an IP address in the 192.168.2.X range.

Accessing Files and Services on the Laptop

Once the network is started, the mobile device should be able to access services running on the laptop (but not the internet).
The easiest way to share files from the laptop is to create a Samba share for a directory on the network. This can be done by right-clicking on the directory icon and choosing "Sharing options", then check "Share this folder" and optionally assign some share name, the click "create share".

For android devices, there are several apps that can be used to access Samba shares, I use "ES File Explorer". In the ES File Explorer app, change to the "LAN Shares" tab and add a new server. In the "server" field, enter the IP address of the server, e.g., then enter the Ubuntu userid and password and touch "OK". When you touch the server IP address, all the shares you created should be listed and from there you can copy files or whole directories to the Android device.

Another way to access files on the laptop which is also supported by the "ES File Explorer" app is sftp.

[#32709] Sunday, February 19, 2023, 8 Months  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 290
Total Questions: 115
Total Answers: 114

Location: Egypt
Member since Tue, May 3, 2022
1 Year ago