Linux/Ubuntu Commands I used at diff times

Ubuntu Server

Net related issues/commands

When our ethernet is present/detected by the kernel, and also physically connected to a good ethernet/Rj45 cable to your working/ok router, then you may need to force your Ubuntu server to warm up the ethernet and make it request an ip from your router manually. Its because that Linux, unlike windows, Ubuntu Server doesn’t enable or configure all interfaces automatically unless explicitly told (via netplan, ifupdown, etc.).

  • When pinging failed, I used these 2 commands:

sudo ip link set enp12s0 up
sudo dhclient enp12s0

  • Command to check any one adapter up/down/unknown: ip a show enp12s0
  • To check all adapters: ip a
  • ping 192.168.1.1
  • ping -c google.com (anywebsitename)
  • To Restart the service: SystemCtl restart systemd-resolved
  • Then check your DNS: resolvectl (try switch for shorter output: status or for shortest dns wo hyphens). In earlier versions, it was systemd-resolve --status |or| resolvectl --status.
  • Check network service status: systemctl status systemd-networkd (if you use network manager, then use: systemctl status NetworkManager)
  • If you edited nano /etc/systemd/resovled.conf, (restarted with: SystemCtl restart systemd-resolved) then verify your edits with: systemd-analyze verify /etc/systemd/resolved.conf
  • Check that now you can reach: nslookup google.com (or archive.ubuntu.com).
  • Or: dig archive.ubuntu.com

But still when I found that when ping was working, but couldn’t reach any website like google or ubuntu archives to update it, one step was still needed:

  • Edit this file: sudo nano /etc/resolv.conf
  • By adding/replacing the nameserver line to: 8.8.8.8 like this:
  • nameserver 8.8.8.8
  • But this resolve.conf file path is actually a symblink and could be rewritten back to same upon server reboot. For this to avoid, create a file: /etc/systemd/resolved.conf .
  • And in it, simply write these 3 lines:

[Resolve]
DNS=8.8.8.8 8.8.4.4
FallbackDNS=1.1.1.1 1.0.0.1

  • Then restart the service: sudo systemctl restart systemd-resolved
  • As a precaution/Perhaps you could check/recreate the symblink: sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

To start Wifi:

  • we needed net connection and then: sudo apt install bcmwl-kernel-source, which updated my wifi drivers in a moment.
  • Then I found that though ‘networkd’ was very much ok for ethernet and mobile tethering. But wifi only succeeded in getting ip address after I opted for ‘NetworkManager’ in the ‘30-wifi.yaml’ file. So now for mobile tethering and ethernet, I’m using ‘netword’ program and for wifi I’m using ‘NetworkManager’ (case sensitive in yaml).

Ok. Everyting done as you told, and also successfully updated, upgraded, now lets fix wifi not working first and then fix mobile tethering, it might come to my rescue some day.

There are mainly 2 types of networking utilities: Networkd and NetworkManager (perhaps case sensitive). Later is more modern and efficient.

  • See available wifi signals in my area: nmcli device wifi list (or you can refresh/force fresh scan: nmcli device wifi rescan)
  • nmcli radio wifi off / on :: Can also try to reconnect to the same ap automatically when turned back on, and more so for a connection, if auto connect is enabled for that one connection. Or you may have to re-connect it by: nmcli device connect wlp2s0
    * nmcli device connect : Brings all disconnected network devices (not just WiFi) online, allowing them to auto-connect if profiles are present.
  • nmcli device connect (or disconnect) wlp2s0 : If the circumstances allow, it tries to connect the said adapter to any available networks. If any connection profile is set to auto-connect, it will (perhaps) take priority.
  • nmcli device show wlp2s0 : Shows full details of the mentioned adapter and its connection’s full details.
  • nmcli device wifi connect "Your-New-SSID" password "YourNewPassword" : To connect to any other available network.
  • nmcli device wifi list : GOOD. shows connected wifi connections with signals strength in bars.
  • nmcli connection show (or less good: nmcli device status):: GOOD, shows all available (connected or disconnected) available connection profiles/names.
  • nmcli connection up "connection_name": Here ‘connection name/Profilename’ contains connection’s settings, such as ssid name and pw.
    • To enable auto-connection on any one connection: nmcli connection modify "connection_name" connection.autoconnect yes
    • To see all if anyone profile is set to autoconnect or not: nmcli connection show "connection_name" | grep autoconnect
  • ip addr
  • ip link
  • ls -lah /etc/netplan : would show how many networking yaml you’ve got.
  • ip link show wlp2s0
  • nano /etc/netplan/30-wifi.yaml
  • netplan try = will validate and attempt to apply the configuration. If there is an error, Netplan will revert to the previous configuration automatically. If it succeeds, you’ll see “Configuration accepted” and your settings will be applied.
    • To specify a particular file (optional): netplan try --config-file /etc/netplan/30-wifi.yaml
  • netplan generate : Validates wo applying. if any errors, would show.
  • netplan apply : applies the new/edited yaml settings.