重温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!
相关推荐
YuMiao4 小时前
gstatic连接问题导致Google Gemini / Studio页面乱码或图标缺失问题
服务器·网络协议
chlk1231 天前
Linux文件权限完全图解:读懂 ls -l 和 chmod 755 背后的秘密
linux·操作系统
舒一笑1 天前
Ubuntu系统安装CodeX出现问题
linux·后端
改一下配置文件1 天前
Ubuntu24.04安装NVIDIA驱动完整指南(含Secure Boot解决方案)
linux
深紫色的三北六号2 天前
Linux 服务器磁盘扩容与目录迁移:rsync + bind mount 实现服务无感迁移(无需修改配置)
linux·扩容·服务迁移
SudosuBash2 天前
[CS:APP 3e] 关于对 第 12 章 读/写者的一点思考和题解 (作业 12.19,12.20,12.21)
linux·并发·操作系统(os)
哈基咪怎么可能是AI2 天前
为什么我就想要「线性历史 + Signed Commits」GitHub 却把我当猴耍 🤬🎙️
linux·github
十日十行3 天前
Linux和window共享文件夹
linux
Sinclair3 天前
简单几步,安卓手机秒变服务器,安装 CMS 程序
android·服务器
木心月转码ing3 天前
WSL+Cpp开发环境配置
linux