重温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!
相关推荐
cui_win37 分钟前
【内存】Linux 内核优化实战 - net.ipv4.tcp_tw_reuse
linux·网络·tcp/ip
BD_Marathon2 小时前
Ubuntu:Mysql服务器
服务器·mysql·ubuntu
CodeWithMe4 小时前
【Note】《深入理解Linux内核》 Chapter 15 :深入理解 Linux 页缓存
linux·spring·缓存
0wioiw04 小时前
Ubuntu基础(监控重启和查找程序)
linux·服务器·ubuntu
Tipriest_4 小时前
Ubuntu常用的软件格式deb, rpm, dmg, AppImage等打包及使用方法
linux·运维·ubuntu
艾希逐月4 小时前
TCP数据的发送和接收
服务器·网络·tcp/ip
GBXLUO4 小时前
windows的vscode无法通过ssh连接ubuntu的解决办法
vscode·ubuntu
胡斌附体5 小时前
linux测试端口是否可被外部访问
linux·运维·服务器·python·测试·端口测试·临时服务器
愚润求学5 小时前
【Linux】自旋锁和读写锁
linux·运维
大锦终5 小时前
【Linux】常用基本指令
linux·运维·服务器·centos