系统
查看当前系统架构
# 查看系统架构的简化信息
arch
# 查看系统架构的详细信息
uname -a
用户
创建用户
# 创建用户,-m不默认创建登录目录
useradd -m xxx
# 修改密码
passwd xxx
切换用户
su xxxx
查看用户
查看所有用户
cat /etc/passwd
查看当前用户
whoami
删除用户
userdel -f xxxx
网络
重启网络
- service network restart
- service network-manager restart
环境配置
export PATH="$PATH=/usr/local/bin/python"
进程
kill
- kill -9 pid:强制杀死进程
- killall <pname>:杀死所有同名进程
pkill
- pkill -u tom:杀死tom用户下的所有进程
ps
ps -t -x 1
列意义
- USER:进程当前所属用户
- PID:进程ID
- PPID:父进程ID
- VSIZE:进程的虚拟内存大小,单位为KB
- RSS:进程实际占用的内存大小,单位为KB
- WCHAN:进程正在睡眠的内核函数的名称
- ADDR:进程首地址
- NAME:进程名称
参数
- -ef:显示所有进程和命令行
- ps -u root:显示root用户下的进程信息
参数解释
- a:显示终端下所有进程,包括其他用户的
- u:以用户为主的格式显示进程
- x:显示所有进程,不以终端区分
top
- top -Hp pid:查看指定进程下的线程
pstree
- pstree -p | grep ssh:树状显示ssh会话的进程号和进程名
下载
apt
- apt-get update:更新配置文件里面的数据源,手动修改后使修改生效
- apt-get upgrade:更新已经安装的包
- apt-get dist-upgrade:更新系统
- apt-get install:下载
- apt-get install -f:修复安装
- apt-get remove xxx:卸载
- apt-get autoremove:卸载无用的安装包
- apt-get remove xxx --purge:卸载的同时删除配置文件
- apt-get clean:清除无用的包
- apt-get autoclean:自动清除无用的包
- apt-cache show xxx:显示包的信息
- apt-cache depends xxx:显示包的依赖
- apt-cache rdepends xxx:显示依赖本包的包
- apt-cache search xxx:模糊搜索,搜索apt可以下载安装的包
卸载
- 卸载包:sudo apt-get remove python3
- 卸载包以及依赖:sudo apt-get remove --auto-remove python3
- 清除配置:sudo apt-get purge --auto-remove python3
chmod
chmod u+x a.exe
- u:所有者user
- x:执行权限
curl
通过url进行文件传输
- curl -o index.html https://www.baidu.com:下载页面内容到index.html文件
- curl -O https://www.baidu.com/linux/index.html:下载index.html文件,O参数时需要具体到实际文件夹
- curl -c cookie.txt -O https://www.baidu.com/linux/index.html:下载的同时保存cookie信息到cookie.txt
- curl -b cookie.txt -O https://www.baidu.com/linux/index.html:使用cookie.txt内部的cookie信息
- curl -F login=tom -F pwd=123 -O https://www.baidu.com/linux/index.html:模拟表单登录
- curl -CO https://www.baidu.com/linux/index.html:断点续传
- curl -d pwd=123 -O https://www.baidu.com/linux/index.html:传送数据
- curl -fO https://www.baidu.com/linux/index.html:显示抓取错误
- curl -e https://www.yy.com -O https://www.baidu.com/linux/index.html:伪造来源地址
- curl -x 192.168.0.89 -O https://www.baidu.com/linux/index.html:使用代理网站
- curl -sO https://www.baidu.com/linux/index.html:显示下载进度信息
- curl -# https://www.baidu.com/linux/index.html:显示下载进度条
- curl -u user:pwd -O https://www.baidu.com/linux/index.html:使用ftp下载文件
- curl -LO https://baijiahao.baidu.com/a.html:自动重定向,某些网址可能需要自动重定向
- curl -vO https://www.baidu.com/linux/index.html:显示详细信息
wget
# 普通下载 wget [options] [url] #示例,默认下载目录当前目录下 wget https://down.sandai.net/thunder11/XunLeiWebSetup11.3.10.1912gw.exe
# 创建一个文本文件download_list.txt,将所有url添加到该文件,每个url必须单独一行
wget -i download_list.txt
wget ftp-url # 匿名ftp下载
wget --ftp-user=USERNAME --ftp-password=PASSWORD url # 使用wget用户名和密码认证的ftp下载
参数
- -c:断点续传,存在因网络断开未完全下载的文件时,不去重新下载
- -O:指定下载存储的路径,并对下载文件重命名
- -i:多个文件下载
文件
find
常用组合
- 模糊查找:find /path -type f -name "*.ini"
- 按权限查找:find /path -perm 777
- 10分钟内访问过:find /path -amin 10
- 10分钟内修改过:find /path -mmin 10
- 1天内访问过:find /path -atime 1
- 1天内修改过:find /path -mtime 1
- size大于10K/M/G/的:find /path +size 10K/M/G
- size小于10K/M/G/的:find /path -size 10K/M/G
- 属主是root的:find /path -user root
- 查找文件夹:find /path -type d
批量复制文件
cp --parent -rf /src-path /target-path
- --parent:保留原本的目录结构
- -r:递归复制文件,但是不保留时间戳等属性
- -a:递归复制文件,所有者以及时间戳等文件属性完全复制
- -u:只复制比目标文件夹中新的文件
- -s:创建软连接
- -l:创建硬连接
- -f:强行复制目录和文件,不管目标文件是否已经存在
grep
grep -rn "conetnt" file-path
- -r:迭代查找子文件。
- -n:显示字符串所在行号。
- -i:忽略大小写
压缩
对象
.tar.gz
命令
tar -zcvf to_name.tar.gz from_name
参数
- z:使用gzip工具
- c:压缩
- v:显示压缩过程
- f:制定压缩的文件名
解压
.tar.gz
tar -zxvf from_name.tar.gz to_name
.tar.zx
分两步
xz -d data.tar.xz
tar -xvf data.tar
一步直接解压
tar xvJf data.tar.xz
参考
Linux篇---解压tar.xz文件Linux 删除用户
linux 设置创建用户设置密码
Linux的linux aarch64和linux x86_64
wget常用命令详解
Linux:查看当前用户名的方法(linux当前用户名)
ubuntu重启网络服务的方法
https://blog.csdn.net/p1279030826/article/details/116564195
https://blog.csdn.net/qq_57788303/article/details/128180776
https://blog.csdn.net/weixin_42650954/article/details/117562457
https://blog.csdn.net/weixin_42515331/article/details/112042569
https://www.qycn.com/zx/fwq/xitongyunwei/8895.html
https://jingyan.baidu.com/article/63acb44a127d8220fcc17e9f.html
https://blog.csdn.net/qq_41571577/article/details/115284855
https://baijiahao.baidu.com/s?id=1728602230018821960&wfr=spider&for=pc
https://www.muzhuangnet.com/show/80214.html
https://blog.csdn.net/recher_He1107/article/details/123175582
https://zhuanlan.zhihu.com/p/447604518
https://blog.csdn.net/xiaozhuangyumaotao/article/details/105933420
https://m.php.cn/article/489901.html
https://blog.csdn.net/qq_29761395/article/details/123007041
https://baijiahao.baidu.com/s?id=1584730406677513659&wfr=spider&for=pc
浙公网安备 33010602011771号