Setting Up a Linux Server

Installation

VPS Environment

  1. Create a server

  2. Choose a Linux operating system (Debain10 in this example) and a pricing plan

Wait briefly for the instance to be created.

Then open its details page to obtain the IP address and root credentials for SSH login.

  1. You can now log in remotely with an SSH client. Here I use Bitvise.

Once connected, you can open an SSH terminal window or transfer files over FTP.

The Debain system is now ready to use.

Common Commands

Files

# 切换目录
cd 
# 查看当前位置
pwd
# 新建文件
touch fileName
# 创建目录
mkdir dirName
# 删除文件
rm fileName
# 删除多级目录
rm -rf
# 查看当前目录下的文件
ls
# 移动文件
mv
# 复制文件
cp
# 具体用法可以用help 加命令 或者man 加命令实现

Permissions

# 改变文件的权限
chmod
# 改变文档的拥有者
chown
# 改变文档所属群组
chgrp

Networking

# 测试网络是否连通
ping IP
# 查看网络配置
ifconfig
# 查看网络的连接情况
netstat

Performance

# 查看所有进程
ps -A
# 查看系统资源使用情况
top

Using apt

Repository Location

Repositories are listed in /etc/apt/sources.list. You can add one with the deb command: deb http://deb.debian.org/debian/ buster main contrib non-free.

# 更新命令
apt update
# 升级命令
apt upgrade
# 安装命令
apt install
# 移出
apt remove
# 清理
apt purge
注:update只下载更新的信息,而upgrade则根据下载的更新信息更新实际的软件
apt purge 还会删掉配置文件

Detailed reference

Getting Started with nginx

Installation

# 相关依赖
apt install build-essential
apt install libtool
# 安装nignx
apt install nginx

Check port usage; you can see nginx using port 80.

Also check nginx’s status with service nginx status.

Find nginx’s main website directory, /var/www/html, and upload the static webpage files you prepared to deploy the site. (You can disable the original index.html by adding a .bak suffix.)

Using the Vi Editor

A simple workflow: open a file with vi fileName, then use the arrow keys to move the cursor and browse the document. Alternatively, use ?/ to find the location to edit, then press i to enter edit mode. After editing, press Esc to enter command mode. Enter :wq to save and exit, or :q! to exit without saving.