0
点赞
收藏
分享

微信扫一扫

rhcsa第四天

kolibreath 2022-02-17 阅读 71

day04

文件查找4种方式

whereis 查询范围通过系统环境变量路径搜索文件$PATH,所有的文件

which 查询范围通过系统环境变量路径搜索文件$PATH,找的是可执行文件(查找命令文件)

locate 全局搜索,但是需要在搜素前将系统文件导入数据库updatedb;查找速度快

*find 全局搜索文件。

注意事项: 1)-prune 必须和 -path,-o 一起使用 2)-prune -o 的顺序不 能调换 3)-name等必须放在-prune -o后面才能使用

! -a -o

eg: find . -path ./tmp -prune -o -name "*.txt"

[root@localhost test]# find . ! -name "out" -a -name ".txt"

find / -name FILENAME -type f

find -name FILENAME

find ../.. -name FILENAME

-exec -ok

#-exec -ok find 查找文件的结果通过 可以将前面命令的结果默认通过换 行识别为多个文件参数通过后面命令进行处理

find / -type f -exec cp -p {} /test \;

find / -type f -ok cp -p {} /test \;

[root@localhost test]# find . -type f |xargs -I {} cp {} /test

-I 将xargs的每项名称,一般是一行一行赋值给 {},可以用 {} 代替。

文件压缩解压缩

tar

-c

-x

-t

-v

-f

-j

-J

-z

-C

文件传输:

window --linux xftp实现文件传送

rz FILENAME 接收 sz 传送 ---lrzsz包

linux--linux

文件发送: scp mima root@192.168.220.154:/root

文件接收: scp root@192.168.220.154:/root/mima /passwd

scp -r

[root@162 ~]# sftp 192.168.220.154 发起sftp的远程连接

sftp> put file

sftp> get filename

文件管理名

touch > >> vi/vim nano

mkdir

rm -rf

cp

mv

wget

cat tac more less head tail (vim nano) grep

vim nano > >>

echo this is test > a.txt

cat <<EOF > file

grep wc cut sort uniq tr

whereis

which

locate

find

tar

bash 特性

alias 定义命令别名

alias 别名="命令本身"

l临时别名,仅在当前终端运行状态下生效

vim /etc/bashrc 1--exit 2--bash 3--source /etc/bashrc

永久别名对系统所有用户都生效

vim ~/.bashrc

永久别名仅对当前用生效

命令缓存

1.建立命令缓存

执行命令自动在缓存建立

hash -p /usr/bin/touch touch

hash -p /usr/bin/touch chuangjian

2.删除缓存

hash -d chuangjian

hash -r 清空所有缓存

exit终端

缓存特点: 命令缓存---alias--名令文件

[root@162 ~]# hash
hits    command
   3    /usr/bin/vim
   1    /usr/bin/cat
   1    /usr/sbin/pidof
   2    /usr/bin/su
[root@162 ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@162 ~]# which touch
/usr/bin/touch
[root@162 ~]# touch a
[root@162 ~]# hash
hits    command
   3    /usr/bin/vim
   1    /usr/bin/cat
   1    /usr/bin/touch
   1    /usr/sbin/pidof
   2    /usr/bin/su
[root@162 ~]# touch /usr/bin/touch     ---=优先通过缓存匹配
[root@162 ~]# hash
hits    command
   3    /usr/bin/vim
   1    /usr/bin/cat
   2    /usr/bin/touch
   1    /usr/sbin/pidof
   2    /usr/bin/su
​
[root@162 ~]# mv /usr/bin/touch /usr/local/bin
[root@162 ~]# touch b
bash: /usr/bin/touch: No such file or directory
[root@162 ~]# hash -d touch 
[root@162 ~]# hash
hits    command
   3    /usr/bin/vim
   1    /usr/bin/cat
   1    /usr/sbin/pidof
   3    /usr/bin/mv
   2    /usr/bin/su
[root@162 ~]# touch b     ----不存在缓存以及别名执行环境变量路径下的命令文件
[root@162 ~]# hash -p /usr/bin/tac chakan    --别名

history

举报

相关推荐

Rhcsa第四天

RHCSA第四天

学习RHCSA第四天作业

学习RHCSA的第四天

RHCSA(第四天课后作业)

第四天 RHCSA 虚拟机

第四天 作业

第四天笔记

0 条评论