3

I messed up my network settings through the command line. I have a headless Ubuntu Server 16.04 without any desktop environment installed for a lighter-weight installation and connected to my local network through ethernet, and I use a Windows 10 laptop with SSH to access it, so I do not have a extra screen to use to reinstall Ubuntu. Is there any way to reset all my network settings through the command line?

What exactly happened was: I was playing around with the command line because I wanted to access my server through SSH without typing in an IP address every time I connected, so I used sudo hostname with all its possible arguments to change its hostname from an IP address to my name. Now, SSH, SFTP, FTP, SMB, HTTP and almost everything possible is a million times slower than usual and sometimes returns "Took too long to load".

I don't mind resetting the entire OS, but I don't have an screen/monitor to use with a bootable USB/DVD. I need a solution because my website is getting affected - It takes about 45 seconds to load a 8.2MB webpage although my internet speed is above 10MBPS.

SSH is working relatively better, so is there any command-line solution to my problem?

2
  • Also, when I ping my server through my local network, the request times out.
    – RJacob41
    Commented Oct 10, 2016 at 12:18
  • did you try my answer
    – lewis4u
    Commented Oct 10, 2016 at 12:26

2 Answers 2

10

Run

ifconfig

and see the name of your network adapter. Mine is: enp0s3

now run this command

sudo nano /etc/network/interfaces

and you should get something inside....delete everything and paste this (but change the network adapter name where enp0s3 is):

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto enp0s3
iface enp0s3 inet dhcp

save the document and reboot...

3
  • 1
    I already had that, but thank you anyway!
    – RJacob41
    Commented Oct 10, 2016 at 15:59
  • And I fixed the problem, my router had a problem; I got a new one
    – RJacob41
    Commented Oct 10, 2016 at 15:59
  • Ah okay...glad you made it work
    – lewis4u
    Commented Oct 10, 2016 at 16:00
-1

use sudo systemctl restart NetworkManager.service to restart of the network manager.

2
  • The question is about "How to reset" not "How to restart". Those two are separate things.
    – Puspam
    Commented May 21, 2021 at 17:00
  • last time I solved the issue by restarting NetworkManager, so I shared this solution Commented May 21, 2021 at 17:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .