重温Ubuntu 24.04 LTS

用户调整

bash 复制代码
# 创建新用户
sudo adduser newusername
# 设置新用户的密码
sudo passwd newusername
# 将新用户添加到 sudo 组
sudo usermod -aG sudo newusername
# 修改ssh访问权限
sudo nano /etc/ssh/sshd_config
# 将新用户加入,此时root将无法访问
AllowUsers newusername
# 重启服务
sudo service ssh restart
# 之后登录
ssh newusername@x.x.x.x
# 登录进入之后,切回root使用
su -

docker安装

bash 复制代码
# 更新
apt -update
# 安装docker
apt install docker.io
# 配置源
sudo nano /etc/docker/daemon.json
{
  "registry-mirrors": [
    "https://docker.m.daocloud.io",
    "https://docker.imgdb.de",
    "https://docker-0.unsee.tech",
    "https://docker.hlmirror.com",
    "https://docker.1ms.run",
    "https://func.ink",
    "https://lispy.org",
    "https://docker.xiaogenban1993.com"
  ]
}
# 拉取image
docker pull xx/xx
# 通过dockerfile制作image
docker build -t my-python-app .
# 通过docker-compose.yml制作镜像
docker-compose up --build
# 以后台模式运行容器
docker-compose up -d
# 查询镜像
docker images
# 删除镜像
docker rmi my-python-app
# 创建容器
docker run -d -p 8000:5000 --name my-python-app-container my-python-app
# 查询容器
docker ps -a 
# 关闭容器
docker stop xxxx
# 删除容器
docker rm xxxx
# 查看容器log
docker logs xxxx

PostgreSQL

复制代码
# 安装
sudo apt install postgresql postgresql-contrib
# 查看版本号
sudo -u postgres psql -c "SELECT version();"
# 切用户
sudo -i -u postgres
# 命令行
psql
# 修改用户密码
ALTER USER postgres PASSWORD 'your_password';
# 退出命令行
\q
# 配置远程可访问1
sudo nano /etc/postgresql/16/main/pg_hba.conf
host    all             all             0.0.0.0/0            md5
# 配置已远程可访问2
sudo nano /etc/postgresql/16/main/postgresql.conf
listen_addresses = '*'
# 重启
sudo systemctl restart postgresql
# 查看端口
sudo lsof -i -P -n | grep postgres

其他

bash 复制代码
curl http://localhost:8000
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Index Page</title>
    <link rel="stylesheet" href="/static/css/style.css">
</head>
<body>
    <h1>Welcome to the Index Page</h1>
    <script src="/static/js/script.js"></script>
</body>

nc -zv xx.xx.xx.xx 8000
Connection to xx.xx.xx.xx port 8000 [tcp/irdmi] succeeded!
相关推荐
吳所畏惧1 小时前
宝塔面板Redis密码修改指南:SSH命令修改 vs 面板UI界面修改,哪个更靠谱?
运维·服务器·数据库·redis·缓存·ssh
DFT计算杂谈1 小时前
无 Root 权限在 Tesla K80 零门槛部署 DeepSeek 大模型
linux·服务器·网络·数据库·机器学习
维天说2 小时前
CLI-Switch 2026年3月版历史设计:Hook、TTY 隔离与 JSON 状态
java·服务器·json
Zhang~Ling2 小时前
从 fopen 到 struct file:从零开始拆解 Linux 文件 I/O
linux·运维·服务器
DeeplyMind2 小时前
Linux 深入 per-VMA lock:Linux 缺页路径如何摆脱 mmap_lock
linux·per-vma lock
爱写代码的阿森2 小时前
鸿蒙三方库 | harmony-utils之PreferencesUtil首选项数据监听详解
服务器·华为·harmonyos·鸿蒙·huawei
爱写代码的森2 小时前
蒙三方库 | harmony-utils之FileUtil文件重命名与属性查询详解
linux·运维·服务器·华为·harmonyos·鸿蒙·huawei
吠品3 小时前
Zabbix Web界面误报Server未运行的排查与解决
java·服务器·数据库
XMAIPC_Robot3 小时前
软硬协同实时控制|RK3588业务调度+FPGA硬件时序,ethercat实现半导体设备微秒级响应(125us)
linux·arm开发·人工智能·fpga开发
重生的黑客4 小时前
Linux 进程优先级、切换与调度:从孤儿进程到 O(1) 调度模型
linux·运维·服务器·进程优先级·nice