Some Notes on Ubuntu (1)
11/16/23About 2 min
Tsinghua University Mirror Configuration
- Download the Ubuntu Image
Ubuntu image address: Tsinghua University Open Source Software Mirror
- Configure the Mirror Source
The software source configuration file for Ubuntu is /etc/apt/sources.list.
# By default, source mirrors are commented out to improve the speed of apt update. Uncomment them if needed.
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
# Pre-release software source, not recommended to enable
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverseOfficial website: https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/
Some Common Commands
- Go to a specific location:
cd /home/ - List the current directory:
ls sudo apt install [pkgName]sudo apt update
Install PostgreSQL 14
Because the official default is postgresql-12, you need to configure the PostgreSQL source:
# Create the file repository configuration:
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
# Import the repository signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
# Update the package lists:
sudo apt-get update
# Install the latest version of PostgreSQL.
# If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql':
sudo apt-get -y install postgresql-16Install OpenJDK 11
# Install JRE
sudo apt-get -y install openjdk-11-jre
# Install JDK
sudo apt-get -y install openjdk-11-jdk-headlessService-related Commands
Usage: service < option > | --status-all | [ service_name [ command | --full-restart ] ]
- Check service status:
sudo service postgresql status - Restart service:
sudo service postgresql restart
Register an sh Script as a Service
- Write the
geoserver.servicefile
[Unit]
Description= Description of the service
After = syslog.target
[Service]
Type = Defines the behavior of the process at startup
- Type=simple: Default value, executes the command specified by ExecStart, starts the main process
# ExecStart=/home/bin/startup.sh
ExecStart=Command executed to start the service
ExecStop: Command executed when stopping the current service
ExecReload: Command executed when restarting the current service
#Environment Variables
Environment=GEOSERVER_HOME=/home/path/geoserver_home
ExecStartPre: Command executed before starting the current service
ExecStartPost: Command executed after starting the current service
ExecStopPost: Command executed after stopping the current service
RestartSec: Seconds to wait before automatically restarting the current service
TimeoutSec: Defines the seconds systemd waits before stopping the current service
[Install]
WantedBy=multi-user.target
Alias: Alias that can be used to start the current Unit- Register
geoserver.serviceas a service
- Register service:
systemctl enable /path-to-file/geoserver.service - Start service:
systemctl start geoserver.service - Check service status:
systemctl status geoserver.service - Set auto-start on boot:
sudo systemctl enable geoserver.service
- Other commands
- Uninstall service:
systemctl disable geoserver.service - Disable auto-start on boot:
systemctl disable geoserver.service - Check if it's auto-start on boot:
systemctl is-enabled geoserver.service - Restart service:
systemctl restart geoserver.service
Install OpenSSH-server
sudo apt update # Update sources
sudo apt install openssh-server # Install SSH service
sudo service ssh start # Start service
sudo service ssh stop # Stop service
sudo service ssh restart # Restart serviceConnect to Ubuntu from Windows using SSH
- Copy server files to local:
scp -P 8022 user@remotehost:/path/to/file.txt E:/ - Copy local files to server:
scp -P 8022 E:\testgdal.jar vbox@192.168.0.203:/home/vbox - Connect using SSH:
ssh user@remotehost -p 8022 - Exit:
exit
Install gdal-java
Currently, gdal-java can only be installed on version 20.04. Ref: https://packages.ubuntu.com/search?keywords=gdal&searchon=names
sudo apt-get install gdal-bin
sudo apt-get install libgdal-dev
sudo apt-get install libgdal-javaPackages Query Website
AI Translation | AI 翻译
This article was translated from Chinese to English by AI. If there are any inaccuracies, please refer to the original Chinese version.
本文由 AI 辅助从中文翻译为英文。如遇不准确之处,请以中文原版为准。
