Helpful Linux Commands
Helpful Linux Commands
Setting Static IPs
Good common practice when running services on VMs is to have everything running on static IP addresses. This can be done through your DHCP server or in your VM itself. The easiest way to do this on Ubuntu Server is through netplan. Use whatever addressing scheme you have setup in your network.
sudo nano /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
ens5:
dhcp4: no
addresses: [192.168.1.6/24]
gateway4: 192.168.1.1
nameservers:
addresses: [192.168.1.1]
sudo netplan apply
Mounting SMB Shares
Often in a VM you will be utilizing external or shared storage on your network. In Ubuntu Server, we can utilize the fstab to mount these on boot.
- Define Share Mount
sudo apt install cifs-utils
sudo nano /etc/fstab
//truenas.jellayy.com/Data /Data cifs credentials=/etc/share-credentials,uid=1000,gid=1000 0 0
- Create Credentials File:
sudo nano /etc/share-credentials
username=user
password=password
- Secure Credentials File:
sudo chown root: /etc/share-credentials
sudo chmod 600 /etc/share-credentials
- Mount share:
sudo mount -a