Linux基本命令

在这里插入图片描述

1、
[root@localhost ~]# mkdir /ceshi/user -pv
[root@localhost ~]# cp  /etc/{passwd,shadow} /ceshi/user/
[root@localhost ~]# cd /ceshi/user/
[root@localhost user]# ln passwd passwd.bak
[root@localhost user]# ll -i
total 12
841652 -rw-r--r--. 2 root root 2655 Dec 26 02:36 passwd
841652 -rw-r--r--. 2 root root 2655 Dec 26 02:36 passwd.bak
841653 ----------. 1 root root 1358 Dec 26 02:36 shadow
[root@localhost user]# pwd
/ceshi/user
[root@localhost user]# ln -s shadow sh.link
[root@localhost user]# ll
total 12
-rw-r--r--. 2 root root 2655 Dec 26 02:36 passwd
-rw-r--r--. 2 root root 2655 Dec 26 02:36 passwd.bak
----------. 1 root root 1358 Dec 26 02:36 shadow
lrwxrwxrwx. 1 root root    6 Dec 26 02:39 sh.link -> shadow
[root@localhost user]# ll -i
total 12
841652 -rw-r--r--. 2 root root 2655 Dec 26 02:36 passwd
841652 -rw-r--r--. 2 root root 2655 Dec 26 02:36 passwd.bak
841653 ----------. 1 root root 1358 Dec 26 02:36 shadow
841650 lrwxrwxrwx. 1 root root    6 Dec 26 02:39 sh.link -> shadow
[root@localhost user]# 

2、
root@localhost user]# cd ..
[root@localhost ceshi]# pwd
/ceshi
[root@localhost ceshi]# cp /etc/ssh/sshd_config ./sshd
[root@localhost ceshi]# ll
total 8
-rw-------. 1 root root 4425 Dec 26 02:54 sshd
drwxr-xr-x. 2 root root   67 Dec 26 02:39 user

3、
root@localhost ceshi]# find /  -name passwd | tee /passwd.txt
/sys/fs/selinux/class/passwd
/sys/fs/selinux/class/passwd/perms/passwd
/etc/pam.d/passwd
/etc/passwd
/var/lib/sss/mc/passwd
/usr/bin/passwd
/usr/share/licenses/passwd
/usr/share/doc/passwd
/usr/share/bash-completion/completions/passwd
/ceshi/user/passwd
[root@localhost ceshi]# cat /passwd.txt
/sys/fs/selinux/class/passwd
/sys/fs/selinux/class/passwd/perms/passwd
/etc/pam.d/passwd
/etc/passwd
/var/lib/sss/mc/passwd
/usr/bin/passwd
/usr/share/licenses/passwd
/usr/share/doc/passwd
/usr/share/bash-completion/completions/passwd
/ceshi/user/passwd

4、
[root@localhost ceshi]# mkdir /root/test
[root@localhost ceshi]# cd /root/test/
[root@localhost test]# mv /ceshi/sshd   /ceshi/user/passwd.bak .
[root@localhost test]# tree .
.
├── passwd.bak
└── sshd

0 directories, 2 files
[root@localhost test]# pwd
/root/test

5、
[root@localhost test]# tar czvf /root/test/usshh.tar.gz /ceshi/user  /root/test/sshd
tar: Removing leading `/' from member names
/ceshi/user/
/ceshi/user/passwd
tar: Removing leading `/' from hard link targets
/ceshi/user/shadow
/ceshi/user/sh.link
/root/test/sshd
[root@localhost test]# ll
total 16
-rw-r--r--. 2 root root 2655 Dec 26 02:36 passwd.bak
-rw-------. 1 root root 4425 Dec 26 02:54 sshd
-rw-r--r--. 1 root root 3758 Dec 26 03:06 usshh.tar.gz

6、
[root@localhost test]# tar xfv usshh.tar.gz  -C /home/us1/
ceshi/user/
ceshi/user/passwd
ceshi/user/shadow
ceshi/user/sh.link
root/test/sshd
[root@localhost test]# cd  /home/us1
[root@localhost us1]# ll
total 0
drwxr-xr-x. 3 root root 18 Dec 26 03:13 ceshi
drwxr-xr-x. 3 root root 18 Dec 26 03:13 root
[root@localhost us1]# tree .
.
├── ceshi
│   └── user
│       ├── passwd
│       ├── shadow
│       └── sh.link -> shadow
└── root
    └── test
        └── sshd

4 directories, 4 files
[root@localhost us1]# grep ^[bc] -r ./*
./ceshi/user/passwd:bin:x:1:1:bin:/bin:/sbin/nologin
./ceshi/user/passwd:chrony:x:993:988::/var/lib/chrony:/sbin/nologin
./ceshi/user/passwd:clevis:x:983:982:Clevis Decryption Framework unprivileged user:/var/cache/clevis:/sbin/nologin
./ceshi/user/passwd:cockpit-ws:x:982:980:User for cockpit web service:/nonexisting:/sbin/nologin
./ceshi/user/passwd:cockpit-wsinstance:x:981:979:User for cockpit-ws instances:/nonexisting:/sbin/nologin
./ceshi/user/passwd:colord:x:978:976:User for colord:/var/lib/colord:/sbin/nologin
./ceshi/user/shadow:bin:*:18199:0:99999:7:::
./ceshi/user/shadow:chrony:!!:18613::::::
./ceshi/user/shadow:clevis:!!:18613::::::
./ceshi/user/shadow:cockpit-ws:!!:18613::::::
./ceshi/user/shadow:cockpit-wsinstance:!!:18613::::::
./ceshi/user/shadow:colord:!!:18613::::::
[root@localhost us1]# grep ^[bc] -r ./* > file
[root@localhost us1]# 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值