Linux
目录结构
/ ->
bin 普通用户使用的命令
sbin 管理员使用的命令
dev 设备文件
root 用户的home
home 存储普通用户家目录
proc 虚拟文件系统
usr 系统文件 /local软件安装目录 /bin普通用户使用的程序 /
boot 系统启动相关文件
etc 配置文件
网络/etc/sysconfig/network /etc/hostname
应用配置文件/etc/ssh/sshd_config…
tmp 临时文件
var 存放一些变化文件 日志
mysql /var/mysql
vsftp /var/vdftp
log日志
文件或目录的创建,查看,删除,移动,压缩,查找
创建文件 touck
创建目录 mkdir
复制 cp
-r 递归
移动 mv
删除 rm
-r 递归
-f 强制
查看文件内容
文本文件cat
-n 显示行号
-A 显示控制字符(换行符/制表符)
grep 针对文件内容进行过滤
grep ‘password’ /etc/test/txt 过滤出文件中的password
vi编辑操作
文本编辑 y 复制 d 删除 x删除光标所在字符
i进入插入模式 :进入末行模式 v 进入可视模式
:10 进入第10行
:q 退出
:w 保存
:wq 保存退出
:w! 强制保存
:q! 不保存退出
:wq! 强制保存并退出
:x保存退出
:r /etc/1.txt 写入1.txt
扩展-文件时间
文件类型
ls -l
-普通文件
d目录文件
b设备文件
c设备文件
s套接字文件
p管道文件
l链接文件
id 查看当前登录的用户信息
用户管理
管理员 uid 0
系统用户 1-499
普通用户 500-60000
管理组 gid 0
系统组 1-499
普通用户组 500-60000
添加账户 useradd test
用户信息文件 /etc/passwd
用户名
密码占位符
uid
gid
描述
家目录
用户shell
用户管理:组成员管理
权限对象
属主 u
属组 g
其他人 o
基本权限类型
r 读 4
w 写 2
x 执行1
设置权限
更改文件的属主,属组
chown user.group file 更改属主,属组
chown user file 更改属主
chown .group file 更改属组
更改权限
chmod 对象 赋值符号 权限类型
alc基本权限
ugo设置基本权限只能一个用户一个组和其他人
acl设置基本权限 r,w,x
设置
getfacl /file
setfacl -m u:user:rw /file 增加用户user权限
setfacl -m u:user1:- /fiel 增加用户user1权限
查看/删除
getfacl
setfacl -x
-b 删除所有权限
chown更改 chmod赋予
netstat
-t 指名tcp端口
-u 指名udp端口
-a 显示所有连接端口
-p 程序名称
关闭进程
kill
打包 压缩
tar -czf test1.tar.gz test
-z调用gzip
-j调用bzip2
-J调用xz
-f 压缩后名字
解压,解包
tar -tf tar.xz
tar -xzvf tar.gz
tar -xvf tar.gz 无需指定解压工具,tar会自动判断
tar -xvf tar.gz -C /tmp指定解压到tmp
tar xf tar.xz 自动寻找 记住-推荐
解压zip
unzip .zip
安装/查询/卸载
软件类型
a源码包 需要编译 .tar.gz
b二进制包 rpm包
常见二进制包
rpm包管理
uname -a 查看系统架构
yum官方源
/etc/yum.repos.d/ 位置
yum repolist 列出源(默认国外源)
yum clear all 清除原来旧的yum数据库信息
yum makecache 重新构建源
EPEL源 :红帽企业版源
国外源 或者 阿里源
yum -y install repo直接安装源
使用yum管理rpm包
查看可用仓库
yum clear all 清空缓存以及其他文件
yum makecache 重建缓存
yum repolist 查询可用的仓库
安装
yum -y install
yum -y reinstall 重装
yum -y update 更新
yum -y groupinstall
查询(本地rpm数据库 从yum源中查询)
查询是否以安装 yum installed
yum list |grep mys
yum list mys*
卸载
yum -y remove
yum -y groupremove
查找软件包
yum provides
tar源码包管理
环境准备:gcc,make
下载tar.gz
make install //按Makefile定义的文件路径安装
报错
源码安装错误:
error1:
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using –without-http_gzip_module option, or install the zlib library into the system, or build the zlib library statically from the source with nginx by using –with-zlib=<path> option. 解决方案:
yum -y install zlib-devel
error2:
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library into the system, or build the OpenSSL library statically from the source with nginx by using –with-openssl=<path> option.
解决方案:
yum -y install openssl-devel
error3
checking for C compiler … not found ./configure: error: C compiler cc is not found
解决方案:
yum -y install gcc gcc-c++ make
error4:
./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using –without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using –with-pcre=<path> option. 解决方案:
yum -y install pcre-devel
- 原文作者:徐同学的博客
- 原文链接:https://blogs.xwnlearn.cn/post/2021/Linux/
- 版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议. 进行许可,非商业转载请注明出处(作者,原文链接),商业转载请联系作者获得授权。