重温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!
相关推荐
MrZhangBaby6 分钟前
SQL-leetcode—3374. 首字母大写 II
linux·sql·leetcode
bianshaopeng26 分钟前
ubuntu go 环境变量配置
开发语言·ubuntu·golang
czhc114007566331 分钟前
LINUX 820 shell:shift,expect
linux·运维·excel
元清加油37 分钟前
【Goland】:协程和通道
服务器·开发语言·后端·网络协议·golang
望获linux1 小时前
【实时Linux实战系列】基于实时Linux的物联网系统设计
linux·运维·服务器·chrome·php
yuxb732 小时前
Linux 文本处理与 Shell 编程笔记:正则表达式、sed、awk 与变量脚本
linux·笔记·正则表达式
刘一说2 小时前
CentOS 系统 Java 开发测试环境搭建手册
java·linux·运维·服务器·centos
wdxylb7 小时前
云原生俱乐部-shell知识点归纳(1)
linux·云原生
飞雪20079 小时前
Alibaba Cloud Linux 3 在 Apple M 芯片 Mac 的 VMware Fusion 上部署的完整密码重置教程(二)
linux·macos·阿里云·vmware·虚拟机·aliyun·alibaba cloud
路溪非溪9 小时前
关于Linux内核中头文件问题相关总结
linux