Linux文件查找丶压缩丶用户管理

 文件查找:(1)

[root@localhost ~]# find $HOME -mtime +1 | $HOME/*
-bash: /root/anaconda-ks.cfg: Permission denied

        (2)

[root@localhost ~]# find /etc -name "host*" -print
/etc/host.conf
/etc/hosts
/etc/hostname
/etc/avahi/hosts
/etc/nvme/hostnqn
/etc/nvme/hostid

        (3)

[root@localhost ~]# ll /test
total 0
drwxr-xr-x. 2 root root 6 Aug  2 22:29 1abc
drwxr-xr-x. 2 root root 6 Aug  2 22:29 2abc
drwxr-xr-x. 2 root root 6 Aug  2 22:29 3abc
drwxr-xr-x. 2 root root 6 Aug  2 22:29 4abc
drwxr-xr-x. 2 root root 6 Aug  2 22:29 5abc
[root@localhost ~]# find /test -type d -print
/test
/test/1abc
/test/2abc
/test/3abc
/test/4abc
/test/5abc

        (4)

[root@localhost ~]# cp -ap /usr/lib/firmware/phanfw.bin /test/1abc
[root@localhost ~]# find /test -size +2k
/test/1abc/phanfw.bin

打包压缩:(1)

[root@localhost ~]# zip myfile.zip /test/
updating: test/ (stored 0%)
[root@localhost ~]# ll
total 1396
-rw-------. 1 root root    1145 Jul 29 12:05 anaconda-ks.cfg
-rw-r--r--. 1 root root    1483 Jul 29 14:19 initial-setup-ks.cfg
-rw-r--r--. 1 root root 1418769 Aug  2 23:16 myfile.zip

                (2)

[root@localhost ~]# unzip myfile.zip -d /opt
Archive:  myfile.zip
   creating: /opt/test/
   creating: /opt/test/1abc/
  inflating: /opt/test/1abc/phanfw.bin  
   creating: /opt/test/2abc/
   creating: /opt/test/3abc/
   creating: /opt/test/4abc/
   creating: /opt/test/5abc/
 extracting: /opt/test/1a.txt        
 extracting: /opt/test/2a.txt        
 extracting: /opt/test/3a.txt        
 extracting: /opt/test/4a.txt        
 extracting: /opt/test/5a.txt        
   creating: /opt/test/dir1/

(3)

[root@localhost ~]# gzip -r /opt > /test/newfile.tar.gz
[root@localhost ~]# ll /test
total 0
-rw-r--r--. 1 root root 0 Aug  2 23:10 1a.txt
-rw-r--r--. 1 root root 0 Aug  2 23:10 2a.txt
-rw-r--r--. 1 root root 0 Aug  2 23:10 3a.txt
-rw-r--r--. 1 root root 0 Aug  2 23:10 4a.txt
-rw-r--r--. 1 root root 0 Aug  2 23:10 5a.txt
drwxr-xr-x. 2 root root 6 Aug  2 23:11 dir1
-rw-r--r--. 1 root root 0 Aug  2 23:25 newfile.tar.gz

(4)

[root@localhost test]# stat newfile.tar.gz
  File: newfile.tar.gz
  Size: 0         	Blocks: 0          IO Block: 4096   regular empty file
Device: fd00h/64768d	Inode: 37198317    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:default_t:s0
Access: 2022-08-02 23:27:56.728116252 +0800
Modify: 2022-08-02 23:25:58.416113916 +0800
Change: 2022-08-02 23:25:58.416113916 +0800
 Birth: 2022-08-02 23:25:58.416113916 +0800

(5)

[root@localhost test]# tar -cvf beifen.tar /etc 

别名:(1)

[root@localhost ~]# alias hello='touch /file.txt | echo 'hello,everyone' > /file.txt'
[root@localhost ~]# hello
[root@localhost ~]# cat /file.txt
hello,everyone

(2)

[root@localhost ~]# alias shaxin='touch /file.txt'
[root@localhost ~]# shaxin
[root@localhost ~]# ll /file.txt
-rw-r--r--. 1 root root 15 Aug  3 00:10 /file.txt

2.

[root@localhost ~]# vim /etc/bashrc
[root@localhost ~]# source /etc/bashrc
[root@localhost ~]# alias
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias haha='touch /file1'
alias hello='touch /file.txt | echo hello,everyone > /file.txt'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias shaxin='touch /file.txt'
alias xzegrep='xzegrep --color=auto'
alias xzfgrep='xzfgrep --color=auto'
alias xzgrep='xzgrep --color=auto'
alias zegrep='zegrep --color=auto'
alias zfgrep='zfgrep --color=auto'
alias zgrep='zgrep --color=auto'
[root@localhost ~]# haha
[root@localhost ~]# cat /file1
[root@localhost ~]# ll /file1
-rw-r--r--. 1 root root 0 Aug  3 00:23 /file1

用户管理:1.

[root@localhost ~]# useradd sarah -s /sbin/nologin
[root@localhost ~]# id sarah
uid=1001(sarah) gid=1001(sarah) groups=1001(sarah)

2.

[root@localhost ~]# useradd -u 3456 -c "alian" alex
[root@localhost ~]# echo glegunge | passwd --stdin alex
Changing password for user alex.
passwd: all authentication tokens updated successfully.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值