Using the Terminal in Ubuntu Server

Using the Terminal in Ubuntu Server

A graphical User Interface(GUI) makes it easy for us to navigate and do work especially in the Ubuntu desktop version. The Ubuntu server version is a lightweight copy of the deskop version, you do most of your work from the command line terminal making it a daunting task if you are not too familiar with the commands to use.

In this article, I will be going through the steps involved after installing a server version in a server in the office. From mounting a flash drive to statically assigning an address to the network interface is what will be shown.

Using lsblk to determine the location of the flash-drive after it is plugged into the usb port.

lsblk        

sdc-----sdc1 is the 64GB flash that is plugged in, take note that your result will not include the "part /media/flash_drive" since I mounted the drive earlier, it is showing the mount location.

Next, create a new directory in the specified location and mount the drive using the above location.

mkdir -p /media/flash_drive
mount /dev/sdc1 /media/flash_drive        

What I needed in the flash was a bash script to configure the network interface. Doing a ls-lah /media/flash_drive reveals the script file.

The content of the static_ip.sh script is what is show below and the comments show what is accomplished in each step.

#!/bin/bash

# Variables - Replace with your own values
INTERFACE="enp1s0"  # Network interface
STATIC_IP="192.168.32.23"  # Desired static IP address
GATEWAY="192.168.32.10"  # Default gateway
DNS1="8.8.8.8"  # Primary DNS
DNS2="4.4.4.4"  # Secondary DNS

# Backup the current Netplan configuration
NETPLAN_CONFIG="/etc/netplan/00-installer-config.yaml"
BACKUP_CONFIG="/etc/netplan/00-installer-config.yaml.bak"

echo "Backing up current Netplan configuration to $BACKUP_CONFIG"
cp $NETPLAN_CONFIG $BACKUP_CONFIG

# Create a new Netplan configuration
echo "Creating new Netplan configuration for static IP setup"

cat <<EOF > $NETPLAN_CONFIG
network:
  ethernets:
    $INTERFACE:
      dhcp4: no
      addresses:
        - $STATIC_IP/24
      gateway4: $GATEWAY
      nameservers:
        addresses:
          - $DNS1
          - $DNS2
  version: 2
EOF

# Apply the new Netplan configuration
echo "Applying new Netplan configuration"
netplan apply

echo "Static IP setup complete. Please check your network settings."        

Executing the script.

sh  /media/flash_drive/static_ip.sh    ##OR
bash  /media/flash_drive/static_ip.sh         

A successful execution of the script creates a file "/etc/netplan/00-installer-config.yaml" , enabling the the server to be connected to the network.

And there it is, we have successfully connected a machine to the network working purely in the terminal.


















Alois Napitalai

ICT Lab Manager at Surveying and Land Studies Dept(UNITECH)

8 个月

If your internet access is from behind a web proxy server use the export command, export http_proxy=https://username:password@proxy_address:port export https_proxy=https://username:password@proxy_address:port

回复
Alois Napitalai

ICT Lab Manager at Surveying and Land Studies Dept(UNITECH)

8 个月

Use timeshift to make a snap shot of the state of the OS in a clean state, meaning without issues, this will serve as the restore point if after an intstallation, you find that the OS misbehaves. timeshift --create --comments "A working state" --tags D timeshift --restore ##to restore that backup state or snapshot.

回复
Alois Napitalai

ICT Lab Manager at Surveying and Land Studies Dept(UNITECH)

8 个月

For doing edits in config files, use the vi text editor.

回复

要查看或添加评论,请登录

Alois Napitalai的更多文章

  • Logistic Regression

    Logistic Regression

    This is a follow up tutorial on my previous post linear regression on my road to understanding machine learning. As a…

    8 条评论
  • Road to Understanding Machine Learning

    Road to Understanding Machine Learning

    Traditional Machine Learning-Linear Regression Algorithm Machine learning is simply training a machine to make…

  • Automate a Full-stack Application Deployment Using GitHub Actions

    Automate a Full-stack Application Deployment Using GitHub Actions

    #githubactions #git #reactjs #expressjs #virtualization #fullstackdevelopment #githubrepository #statemanagement I have…

    2 条评论
  • Using Github Actions For Website Building

    Using Github Actions For Website Building

    name: Website Deployment Automation on: push jobs: installs: runs-on: ubuntu-latest…

    2 条评论
  • Excel Functions and Formulas

    Excel Functions and Formulas

    I got stuck on excel formulas and functions the other day, it took me some time to get what I wanted. I have a little…

  • React and Ionic Routing

    React and Ionic Routing

    React Routing What is routing in react? Routing in React is the process of mapping URLs(uniform resource locators) to…

  • Persisting GeoSpatial Data in MongoDB

    Persisting GeoSpatial Data in MongoDB

    Persisting data is crucial in web applications, if data is not saved, the data is wiped out when a page refresh is done…

  • Under the Hood of React Components

    Under the Hood of React Components

    Doing It The JSX Way Components are the building blocks of react websites and UIs and these components are built using…

  • Web Proxy Authentication

    Web Proxy Authentication

    In my last article, I wrote about the installation of squid as a caching server that can be used to locally cache pages…

    7 条评论
  • Squid Cache Web Proxy

    Squid Cache Web Proxy

    Many computer networks tend to crawl when there are many users accessing the internet, or there are unwanted traffic…

    4 条评论

社区洞察

其他会员也浏览了