dedecms做网站怎么查看,品牌营销策划英文,分享一个网站能用的,电子商务网站开发规划0.vim命令
vim
gg 移动到文档第一行
G 移动到文档最后一行
:set nu 显示行号
:set noun 取消行号
nG 移动到指定n行,例如20G
$ 移动到行尾
0 移动到行头
clrtf 屏幕向下移动一页
clrtb 屏幕向上移动一页
:%sword1word2g 搜索文本#xff…0.vim命令
vim
gg 移动到文档第一行
G 移动到文档最后一行
:set nu 显示行号
:set noun 取消行号
nG 移动到指定n行,例如20G
$ 移动到行尾
0 移动到行头
clrtf 屏幕向下移动一页
clrtb 屏幕向上移动一页
:%sword1word2g 搜索文本将word1字符串替换成word2字符串
x 向后删除一个字符
X 向前删除一个字符shiftd 删除当前行光标后的字符
dd 删除游标所在整行
ndd 删除光比所在向下n列例如3dd
yy 复制游标所在行
p,P 小p将已复制的数据在光标下一行粘贴大P则为粘贴在游标上一行
u 复原前一个动作回退一步i 从当前光标插入
o, O 小写的o当前光标下一行插入 大写的O当前光标上一行插入
r, R 小写的r替换字符大写的R:q 强制退出不保存
:wq 保存ZZ 大写的ZZ保持后快速退出需要在esc退出编辑模式下操作ctrlv 光标移动到215.18前通过上下左右移动选择一块区域,选号后按y 复制p 粘贴想要的内容1 2 3 4 5 6
tcp 0 0 :::10302 :::* LISTEN
tcp 0 0 ::ffff:172.16.10.205:10302 ::ffff:215.18.157.74:5660 ESTABLISHED
tcp 0 0 ::ffff:172.16.10.205:10302 ::ffff:110.182.143.19:27490 TIME_WAIT
tcp 0 0 ::ffff:172.16.10.205:10302 ::ffff:110.182.143.19:27489 TIME_WAIT
tcp 0 0 ::ffff:172.16.10.205:10302 ::ffff:219.66.163.171:52754 ESTABLISHED
tcp 0 0 ::ffff:172.16.10.205:10302 ::ffff:59.39.132.243:30368 TIME_WAIT这样复制出来的结果就是
215.18.157.74:5660
110.182.143.19:27490
110.182.143.19:27489
219.66.163.171:52754
59.39.132.243:303681.生成指定文件
#使用ddif参数指定了输入文件/dev/zero表示一个无限的全零字节流
#of参数指定了输出文件的路径和名称/root/1.log
#bs参数指定了每次读取和写入的块大小这里是10MB
#count参数指定了要复制的块数这里是1
dd if/dev/zero of/root/1.log bs10M count1
2.shell压缩脚本
cat test.sh
#!/bin/bash#要压缩的目录或者文件
source_dir/mnt#压缩后输入的路径或者文件
output_file/root/mnt.tar.gz#使用tar 命令压缩,通过 --exclude 过滤目录或者文件
tar zcvf ${output_file} --exclude/mnt/test --exclude/mnt/1.log ${source_dir}#打包
#tar zcvf 2020.tar.gz *2020*.log#解压
#tar -zxvf ktgl20201207.tar.gz -C /data/webapp#不想解压查看压缩包内容
#tar ztvf ktgl20201207.tar.gz
3.自定义函数别名
#显示当前定义的所有别名
alias#打开当前用户的.bashrc文件自定义环境变量、别名和函数等设置
vim ~/.bashrc
#定义函数
testFunc(){ps -ef|grep nginx
}#使变量生效
source ~/.bashrc#定义别名
alias psnginxtestFunc4.查看命令cat
#显示行号
cat -n myfile.txt#显示特殊字符
cat -A myfile.txt在cat命令后面添加选项-A或-vET可以改变输出格式以显示一些特殊字符的可见表示。 具体来说-A选项会将以下特殊字符添加到输出中
非打印字符不包括换行符和制表符会以^后接对应的控制字符形式显示。例如ASCII 值为 1 的字符会显示为 ^A。行尾的 $ 符号会显示在每行的末尾。制表符会显示为 ^I。
这个选项通常用于显示一些看不见的特殊字符以便进行文本分析或调试。 $ cat -A myfile.txt This is a line of text.^M$ This is another line of text with a tab character. ^I$ #在上面的示例中^M 表示回车符^I 表示制表符$ 表示行尾。 5.find命令
#查找ceph-csi-3.2.0目录下所有的*log文件
find /ceph-csi-3.2.0/ -name *log#查看/ceph-csi-3.2.0目录下所有*.sh文件每个的大小
#注xargs组合多个命令的一个工具
find /ceph-csi-3.2.0/ -type f -name *.sh | xargs du -sh#复制/ceph-csi-3.2.0目录下所有*.sh文件到/root/test下
find /ceph-csi-3.2.0/ -type f -name *.sh -exec cp -a {} /root/test \;#/ceph-csi-3.2.0目录开始搜索文件,排除目录/ceph-csi-3.2.0/scripts/*,排除文件/ceph-csi-3.2.0/deploy.sh查找*.sh文件
find /ceph-csi-3.2.0/ -type f -path /ceph-csi-3.2.0/scripts/* -o -path /ceph-csi-3.2.0/deploy.sh -o -type f -name *.sh -print#比较下面两个打包的区别
#第一个是打包成一个文件
find /ceph-csi-3.2.0/ -type f -path /ceph-csi-3.2.0/scripts/* -o -path /ceph-csi-3.2.0/deploy.sh -o -type f -name *.sh -print | xargs tar zcvf allSh.tar.gz#第二个是打包成多个文件
find /ceph-csi-3.2.0/ -type f -path /ceph-csi-3.2.0/scripts/* -o -path /ceph-csi-3.2.0/deploy.sh -o -type f -name *.sh -print -exec tar zcvf {}.tar.gz {} \;
6.ln 软链接和硬链接
#软链接
ln -svf /ceph-csi-3.2.0/allSh.tar.gz /root/
● -s创建软链接Symbolic Link而不是创建硬链接。
● -v显示详细的输出即在创建链接时显示正在进行的操作。
● -f强制执行操作即如果目标文件已存在则覆盖它。#硬链接
ln /ceph-csi-3.2.0/allSh.tar.gz /root/在Linux中ln命令用于创建链接link文件。其中有两种类型的链接软链接Symbolic Link和硬链接Hard Link。它们之间有以下区别 路径类型软链接是一个指向目标文件的路径名而硬链接是一个指向目标文件的物理副本。文件类型软链接被视为一个独立的文件它具有自己的 inode 和文件权限。硬链接是文件系统中原始文件的另一个名称实际上它们共享相同的 inode 和文件权限。跨文件系统软链接可以跨越不同的文件系统因为它们只是包含目标文件路径的文本文件。硬链接只能在同一文件系统内工作因为它们依赖于 inode。目标更新如果目标文件被重命名、删除或移动软链接将失效而硬链接仍然有效因为它们直接指向目标文件的物理副本。目录链接软链接可以链接到目录而硬链接不能链接到目录。多个链接对于硬链接可以有多个链接指向同一文件而软链接只能有一个链接指向目标文件。 总之软链接是指向目标文件路径的独立文件可以跨文件系统并且保留原始文件的路径和权限信息。硬链接是原始文件的另一个名称具有相同的inode和权限不能跨越文件系统并且在目标文件更改时仍然有效。 使用ln命令创建链接时如果不指定任何选项默认情况下会创建硬链接。要创建软链接可以使用ln -s选项。 7.文件和目录对比
diff 文件内容对比命令(案例diff 1.txt 2.txt)
du 查看文件或目录使用空间大小
basename 过滤出路径下面最后的文件名或目录
dirname 从文件名中删除最后一个组成部分
df 查看系统硬盘占用空间情况 案例df -TH
df -i 查看磁盘inode使用空间#查看目录下低于100K的文件数量
find /mnt -type f -size -100k | wc -l#删除低于100K,过多小文件
find /mnt -type f -size -100k | xargs rm -f[rootk8s-master01 jtpv]# basename /root/jtpv/pv.yaml
pv.yaml
[rootk8s-master01 jtpv]# dirname /root/jtpv/pv.yaml
/root/jtpv
8.目录或文件权限
[rootnews-static ~]# ls -l 1.html
-rw-r--r--. 1 root root 0 12月 25 2019 1.html[rootnews-static ~]# ls -ld nginx-1.23.2
drwxr-xr-x. 9 1001 1001 4096 11月 30 2022 nginx-1.23.2r w x
4 2 1
读 写 执or进入
0644/-rw-r--r-- #文件
0755/drwxr-xr-x #目录064400220666 文件最大权限666
075500220777 目录最大权限777umask0022 #第一位0: 表示这是一个八进制数[rootnews-static ~]# umask
0022
[rootnews-static ~]# ls -l 1.html
-rw-r--r--. 1 root root 0 12月 25 2019 1.html[rootk8s-master01 ~]# diff 1.txt 2.txt
12a13123chown 更改文件所有者以及所有组常用-R 是目录内所有文件都授权
chattr i 锁定文件
lsattr 显示文件或目录的扩展属性的命令
chattr a 只允许增加内容[rootnews-static ~]# lsattr 2.txt
-------------e- 2.txt
[rootnews-static ~]# chattr i 2.txt
[rootnews-static ~]# lsattr 2.txt
----i--------e- 2.txt
[rootnews-static ~]# chattr -i 2.txt
[rootnews-static ~]# lsattr 2.txt
-------------e- 2.txt
[rootnews-static ~]#[rootnews-static ~]# chattr a 2.txt
[rootnews-static ~]# lsattr 2.txt
-----a-------e- 2.txt
[rootnews-static ~]# echo 3 2.txt
-bash: 2.txt: 不允许的操作
[rootnews-static ~]# echo 3 2.txt
[rootnews-static ~]# cat 2.txt
123
3
[rootnews-static ~]#
9.遍历目录
[rootnews-static mydir]# cat test.sh
#!/bin/bashdirectory$1# 使用 find 命令递归遍历指定目录下的所有文件和子目录
find $directory -print | while read file; doif [[ -d $file ]]; then # 判断是否为目录echo Dire: $fileelif [[ -f $file ]]; then # 判断是否为文件echo File: $filefi
done[rootnews-static mydir]# /tmp/mydir/test.sh /tmp/mydir
Dire: /tmp/mydir
File: /tmp/mydir/boge.sh
File: /tmp/mydir/test.sh
Dire: /tmp/mydir/dir1
Dire: /tmp/mydir/dir1/dir2
Dire: /tmp/mydir/dir1/dir2/dir3
File: /tmp/mydir/dir1/dir2/dir3/file3.log
File: /tmp/mydir/dir1/dir2/file2.log
File: /tmp/mydir/dir1/file1.log
[rootnews-static mydir]#[rootnews-static mydir]# cat boge.sh
#!/bin/bashlistFile() {local tempDir$1# 使用 find 命令递归遍历指定目录下的所有文件和子目录find $tempDir -print | while read file; doif [[ -d $file ]]; then # 判断是否为目录echo Dir: $fileelif [[ -f $file ]]; then # 判断是否为文件echo Fil: $filefidone
}
#允许函数
listFile $1[rootnews-static mydir]# /tmp/mydir/test.sh /tmp/mydir
Dire: /tmp/mydir
File: /tmp/mydir/boge.sh
File: /tmp/mydir/test.sh
Dire: /tmp/mydir/dir1
Dire: /tmp/mydir/dir1/dir2
Dire: /tmp/mydir/dir1/dir2/dir3
File: /tmp/mydir/dir1/dir2/dir3/file3.log
File: /tmp/mydir/dir1/dir2/file2.log
File: /tmp/mydir/dir1/file1.log
[rootnews-static mydir]#
参考博客博哥爱运维 https://www.toutiao.com/article/7271959603280265739?wid1698656801777