Linux Server
*************************************************
# Check Ubuntu update - for Ubuntu 20.04
$sudo apt update
# Execute Ubuntu upgrade
$sudo apt upgrade
# Set
Linux Host Fix IP for Ubuntu 20.04
ls
/etc/netplan
ip a - to check
the name and ip address of interfaces
sudo nano /etc/netplan/01-network-manager-all.yaml
network:
Version: 2
Renderer: NetworkManager/ networkd
ethernets:
enp0s25:
Dhcp4: no
Addresses: [192.168.88.188/24]
Gateway: 192.168.88.1
Nameservers:
Addresses: [192.168.88.1,
8.8.8.8]
Note: use space bar only, DO NOT use tab to
indent
$ sudo netplan try ;To testing
configuration
$
sudo netplan apply
$sudo systemctl restart
network-manager
Use setting at network icon of top right
desktop corner to verify the setting implemented
4) Setup SSH server
sudo apt install openssh-server
# Configuration - set port, authentication
method for password or key
sudo nano /etc/ssh/sshd_config
#Set Key file authentication
#Append public key to /home/user/.ssh/authorized_keys
sudo cat id_key_2014.pub >> authorized_keys #
key name is doesn't care, content does
sudo service ssh restart
5) Set timezone
1)
Check time $ sudo timedatectl
status
2)
Set timezone $ sudo timedatectl set-timezone
"Australia/Sydney"
6) Set Hostname
1)
Change hostname from /etc/hostname
2)
Change hostname from /etc/hosts
******************************************************************************************
7) Mount external disk after system booted up
1)
sudo fdisk -l #detect disk even in unpartition
#Show
the device name /dev/sdxx
#First
command to work on a new disk
2) sudo fdisk /dev/sdx #Manipulate disk partition on /dev/sdx,
#Create
partition table by "n" command
#Note:
/dev/sdb is disk level
# /dev/sdb1 is partition level
#Must
create partition eg. /dev/sdb1 before format disk.
Format patition but not disk.
3) sudo mkfs.ext4
/dev/sdxn
#format /dev/sdb1 to ext4
#
Using mkfs.vfat32 to FAT32
4)
sudo blkid #locate the universal unique
Identifier of /dev/sdb2
#Format,
show UUID="XXXXXXXXXXXXXX"
#Unformat,
show PTUUID="XXXXXXXXXXXXX"
5)
sudo lsblk #Concise list all disk partitions
6)
sudo lshw -C disk #Also for all hardware
7)
sudo mkdir /srv/data #Create mount point with root on uid and gid
8)
sudo groupadd data
9)
sudo usermod -aG data USERNAME #
user to be added
10)
sudo chown -R :data /srv/data #
change ownership of the mount point
11)
sudo nano /etc/fstab
12)
Add line
UUID=XXXXXXXXXXXXXXXXX /srv/data exfat umask=002,gid=1003,uid=1000
13)
sudo mount -a #test
the entry before boot
****************************************************************************************
8) List disk and their partitions
9) System User Maintanence: ;Ubuntu
setup NO root account by default
$sudo adduser ;adduser
$sudo addusr quakershill
sudo ;add
user to a group
$sudo usermod -u 1000 quakershill ;change
user id
$sudo useradd USERNAME --shell
/bin/false ;add user to system without
home directory and account disabled
$sudo usermod -d /srv/2tb/home/username -m username ;Change home directory
$sudo usermod -u 1009 user :change
user id
$sudo groupmod -g 1009 sambashare ;change
group id of a user or group : a user must has his own group but group can be
group only
Remove
user and home directory saftety
$sudo userdel quakershill
$sudo rm -r /home/quakershill
10) Remove Linux network presistence
rule: sudo rm -rf /etc/udev/rules.d/70-persistent-net.rules
This
is reset Linux weired networking issue
11) Send job to Background
$Cntl Z -> bg
$jobs
12) delete
thumbs.db in unix sudo find
/home/user -name Thumbs.db -exec rm {} \;
13) How to disable auto suspend when I close
laptop lid
Edit
/etc/systemd/logind.conf
Set
HandleLidSwitch=ignore
14) Solve "system program problem
detected" in 20.04
sudo nano /etc/default/apport
Change
enable=1 to enable=0
*****************************************************************
Setup FTP server
$ sudo apt update
$sudo apt install vsftpd
$sudo systemctl status vsftpd
$sude systemctl restart vsftpd
$du -sh .
@sudo /etc/vsftpd.conf
anonymous_enable=NO
local_enable=YES
write_enable=YES
chroot_local_user=YES
allow_writeable_chroot=YES
#Test connection from REOLINK camera is port
21
#Create ftp receive driectory
/srv/srv_2tb/2tb/ftp
#set directory access owner:siueric
group:2tb
#create ftp user
#As create normal user quaker01
#Assign to group 2tb
sudo chgrp 2tb quaker01
#set home directory /srv/srv_2tb/2tb/ftp/quaker01
sudo usermod -d /srv/srv_2tb/2tb/ftp/quaker01 quaker01
*********************************************************************
Get public ip
address from ubuntu
#shell is bash
$ sudo nano ~/.bashrc
#add
alias wan='curl ifconfig.me &&echo'
*****************************************************************
#Setup Zerotier VPN
node on Ubuntu:
$ sudo snap install
zerotier-one
$ sudo snap connect
zerotier-one:network-control
$ sudo zerotier-one.zerotier-cli info
$ sudo zerotier-one.zerotier-cli join
"network ID"
$ sudo zerotier-one.zerotier-cli listnetworks
$ ifconfig
$ sudo zerotier-one.zerotier-cli
list -- to display available cli
command
$ sudo snap remove zerotier-one
$ sudo systemctl --
command can control all load service
$ sudo service
--status-all --display loaded services
list
*****************************************************************
3) Set up Samba:
Install
Samba $sudo apt-get install samba
add
smb user $sudo smbpasswd -a username ; For
create smb user, but username must be in system user
List
smb user $sudo pdbedit -L -v
Create
group 2tb $sudo
groupadd 2tb
Add
user to group 2tb $sudo addusr siueric 2tb
Make
share directory $sudo mkdir /srv/2tb : Do not use sudo
to create otherwise would be root right and unable to access for user
Change
owner $sudo chown siueric /srv/2tb
Change
group $sudo chgrp 2tb /srv/2tb
configure
service $sudo
nano -w /etc/samba/smb.conf
reload
smb service $sudo systemctl restart nmbd
Test
SMB and list service share $sudo testparm
Edit
smb.conf file for the following
[2tb]
path
= /srv/2tb
available
= yes
valid
users = siueric
read
only = no
browseable = yes
public
= yes
writable
= yes
*************************************************