linux学习笔记 常用命令记录

1、linux查看系统版本lsb_release -a

2、查看目录所在的磁盘卷的容量

df -h /usr

 3、在Ubuntu 20.04中将时间设置为24小时制

        可以通过编辑 /etc/default/locale 文件来实现

#  File generated by update-locale
LANG="zh_CN.UTF-8"
LANGUAGE="zh_CN:zh"

 4、服务器间copy文件

 scp /home/zyh/app_inference/*  root@目标服务器ip:/home/zyh/app_inference/

5、supervisor的常见配置

[program:txwxh-mh.lw-i.com.cn.5117]
command=dotnet WxApp.dll --urls http://0.0.0.0:5117 ;#要执行的命令
directory=/home/wwwroot/txwxh-mh.lw-i.com.cn/ ;#命令执行的目录
environment=ASPNETCORE_ENVIRONMENT=Production ;#环境变量
user=root ;#进程执行的用户身份
stopsignal=INT
autostart=true ;#是否自动启动
autorestart=true ;#是否自动重启
startsecs=1 ;#自动重启间隔
stderr_logfile=/var/log/supervisor/txwxh-mh.lw-i.com.cn.err.log ;#标准错误日志
stdout_logfile=/var/log/supervisor/txwxh-mh.lw-i.com.cn.log ;#标准输出日志

6、supervisor命令

supervisorctl -u user -p 123 -c /etc/supervisor/supervisord.conf shutdown

supervisord -c /etc/supervisor/supervisord.conf

7、ubuntu允许端口通过防火墙

sudo ufw allow 端口号

8、ubuntu系统安装字体

        ubuntu的系统字体放在目录:/usr/share/fonts/truetype下,到这个文件夹下创建一个文件夹,然后将字体放在刚创建的目录下,然后更新字体缓存,以便系统能够识别新安装的字体。

fc-cache -fv

9、ubuntu设置免密码sudo操作

        使用sudo visudo命令编辑sudoers文件可以确保语法正确,避免编辑错误导致的问题。

# Members of the admin group may gain root privileges
%admin ALL=(ALL) NOPASSWD: ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) NOPASSWD:ALL

10、nginx部署vue

        安装nginx

sudo apt update
sudo apt install nginx

        编辑配置文件, 这里是直接编辑主配置文件/etc/nginx/nginx.conf

        下面是一个基本示例,需要添加到http块内使用

server {
    listen 80;
    server_name your_domain.com; # 替换为你的域名或IP地址

    location / {
        root /usr/share/nginx/html; # 根据你的dist目录位置进行调整
        try_files $uri $uri/ /index.html; # 处理前端路由
    }

    # 根据你的后台服务进行反向代理配置
    location /prod-api/{
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header REMOTE-HOST $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://192.168.10.111:8080; #设置后端服务的地址和端口
    }

    error_page 404 /404.html;
    location = /404.html {
        internal;
    }
}

11、ubuntu更换源

        首先备份

sudo cp  /etc/apt/sources.list /etc/apt/sources.list.bak

        编辑文件

sudo vim /etc/apt/sources.list

        这里用清华的源为例

ubuntu | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

        在里面选择符合你自己的Ubuntu版本,这里以20.04为例:

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse

        将上面这段全部复制到sources.list中,然后

sudo apt update

        如果还是有问题,可以尝试把https全部改成http。

12、查看Nvidia驱动

nvidia-smi

13、WSL2:NAT 模式下的 WSL 不支持 localhost 代理

        在你的windows的C:\Users\<your_username>目录下面创建一个.wslconfig文件

[experimental]
autoMemoryReclaim=gradual  
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true

        然后关闭wsl

wsl --shutdown

        然后重启wsl

14、centos7 更换源

备份当前的CentOS-Base.repo文件:

sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

下载阿里云的源配置文件:

sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

清除缓存并生成新的缓存:

sudo yum clean all
sudo yum makecache

15、centos7安装.net6的运行时

安装.NET的官方仓库:
sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm

安装.NET运行时:
sudo yum install dotnet-runtime-6.0

16、centos7 允许端口通过防火墙

在CentOS中,您可以使用firewall-cmd工具来开放端口。以下是开放特定端口的步骤:

打开终端。

确认firewalld正在运行,使用以下命令:

systemctl status firewalld

如果firewalld没有运行,使用以下命令启动它:

systemctl start firewalld

永久开放端口,例如开放TCP端口8080:

firewall-cmd --permanent --add-port=8080/tcp

重新加载firewalld配置以应用更改:

firewall-cmd --reload

(可选)检查端口是否已开放:

firewall-cmd --list-ports

请根据实际需要替换上述命令中的端口号和协议。如果需要开放UDP端口,将tcp替换为udp。

16、centos7 安装ffmpeg

# 安装 EPEL 仓库
sudo yum install epel-release

# 安装 RPM Fusion 仓库
sudo yum localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm

# 更新包列表
sudo yum update

# 安装 ffmpeg
sudo yum install ffmpeg ffmpeg-devel

#上面安装完成没有完整安装,按照提醒运行 才完整安装完成
 yum load-transaction /tmp/yum_save_tx.2024-07-11.00-07.DqO5NY.yumtx


输入以下命令来安装EPEL仓库,这是一个额外的软件包仓库,提供了许多在默认CentOS仓库中不可用的软件包:
sudo yum install epel-release

更新YUM包管理器的缓存:

sudo yum update

安装FFmpeg和FFmpeg开发包。FFmpeg开发包包含了头文件和开发库,如果你需要编译使用FFmpeg的程序,可能会需要它:

sudo yum install ffmpeg ffmpeg-devel

安装完成后,你可以通过运行以下命令来检查FFmpeg是否正确安装:

ffmpeg -version

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

坐望云起

如果觉得有用,请不吝打赏

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值