Linux文件处理命令

命令格式

1、目录处理命令

ls命令
在这里插入图片描述
文件信息
在这里插入图片描述
mkdir命令
在这里插入图片描述

[root@localhost tmp]# mkdir -p dry1/dry2
[root@localhost tmp]# mkdir dry1/dry3 dry1/dry4

rmdir命令
在这里插入图片描述

[root@localhost tmp]# rmdir dry1/dry2/

cp命令
在这里插入图片描述

[root@localhost dry1]# cp -rp dry3/test1.txt dry4/
[root@localhost dry1]# ls dry4/
test1.txt  test2.txt
[root@localhost dry1]# mkdir dry5
[root@localhost dry1]# ls
dry3  dry4  dry5
[root@localhost dry1]# cp -rp dry5/ dry3/
[root@localhost dry1]# ls dry3
dry5  test1.txt
[root@localhost dry1]# 

复制的同时改名

[root@localhost dry1]# cp -r dry3/test1.txt dry4/test4.txt
[root@localhost dry1]# ls dry4/
test1.txt  test2.txt  test4.txt

Crtl+L清屏

mv命令
在这里插入图片描述

 [root@localhost dry1]# touch test.txt
[root@localhost dry1]# ls
dry3  dry4  dry5  test.txt
[root@localhost dry1]# mv test.txt test_copy.txt 
[root@localhost dry1]# ls
dry3  dry4  dry5  test_copy.txt
[root@localhost dry1]# mv dry3/test1.txt dry4/test5.txt
[root@localhost dry1]# ls dry3/
dry5
[root@localhost dry1]# ls dry4/
test1.txt  test2.txt  test4.txt  test5.txt
[root@localhost dry1]# 

rm命令
在这里插入图片描述

[root@localhost dry1]# ls
dry3  dry4  dry5  test_copy.txt
[root@localhost dry1]# rm -rf test_copy.txt 
[root@localhost dry1]# ls
dry3  dry4  dry5
[root@localhost dry1]# rm -rf dry5/
[root@localhost dry1]# ls
dry3  dry4
[root@localhost dry1]# 

touch命令
在这里插入图片描述

[root@localhost dry1]# touch test.txt
[root@localhost dry1]# ls
dry3  dry4  test.txt
[root@localhost dry1]# 

cat命令
在这里插入图片描述

[root@localhost dry1]# cat test.txt -n
     1	hello helli 
     2	
     3	
     4	hello
     5	bkshfka
     6	bfkabkja
[root@localhost dry1]# 

tac命令
在这里插入图片描述

[root@localhost dry1]# tac test.txt 
bfkabkja
bkshfka
hello


hello helli 
[root@localhost dry1]# 

more命令
在这里插入图片描述

[root@localhost dry1]# more /etc/services 

less命令
在这里插入图片描述

[root@localhost dry1]# less /etc/services 

head命令
在这里插入图片描述

[root@localhost dry1]# head -n 20 /etc/services 

tail命令
在这里插入图片描述

[root@localhost dry1]# tail -n 20 /etc/services 

ln命令
在这里插入图片描述
在这里插入图片描述

[root@localhost dry1]# ln -s /etc/issue /tmp/issue.sooft
[root@localhost dry1]# ls /tmp/issue.sooft 
/tmp/issue.sooft
[root@localhost dry1]# ln /etc/issue /tmp/issue.hard
[root@localhost dry1]# ls /tmp/issue.hard 
/tmp/issue.hard
[root@localhost dry1]# 

在这里插入图片描述

[root@localhost dry1]# ls
dry3  dry4  dry test  test.txt  test.txt1  test.txt_hard
[root@localhost dry1]# ls -i test.txt test.txt1 test.txt_hard 
262272 test.txt  262283 test.txt1  262272 test.txt_hard

chmod命令

在这里插入图片描述

[root@localhost dry1]# ll test.txt
-rw-r--r--. 2 root root 38 May 25 19:31 test.txt
[root@localhost dry1]# chmod u+x test.txt
[root@localhost dry1]# ll test.txt
-rwxr--r--. 2 root root 38 May 25 19:31 test.txt
[root@localhost dry1]# 

添加多个权限

[root@localhost dry1]# ll test.txt
-rwxr--r--. 2 root root 38 May 25 19:31 test.txt
[root@localhost dry1]# chmod g+w,o-r test.txt
[root@localhost dry1]# ll test.txt
-rwxrw----. 2 root root 38 May 25 19:31 test.txt
[root@localhost dry1]# chmod o=rwx test.txt
[root@localhost dry1]# ll test.txt
-rwxrw-rwx. 2 root root 38 May 25 19:31 test.txt
[root@localhost dry1]# 

在这里插入图片描述

[root@localhost dry1]# chmod 777 test.txt
[root@localhost dry1]# ll test.txt
-rwxrwxrwx. 2 root root 38 May 25 19:31 test.txt
[root@localhost dry1]# 

在这里插入图片描述
chown命令
在这里插入图片描述

  [root@localhost ~]# touch test
[root@localhost ~]# ls 
1.sh            abc              Desktop    hello.sh            Pictures   test
2020-05-23.log  abc1             Documents  install.log         Public     test.txt
2.sh            access_log.2020  Downloads  install.log.syslog  shtest     Videos
3.sh            anaconda-ks.cfg  dry        Music               Templates
[root@localhost ~]# ll test
-rw-r--r--. 1 root root 0 May 26 02:25 test
[root@localhost ~]# useradd test
[root@localhost ~]# chown test test
[root@localhost ~]# ll test
-rw-r--r--. 1 test root 0 May 26 02:25 test
[root@localhost ~]# 

chgrp命令
在这里插入图片描述

[root@localhost ~]# ll test
-rw-r--r--. 1 test root 0 May 26 02:25 test
[root@localhost ~]# groupadd dry1
[root@localhost ~]# chgrp dry1 test
[root@localhost ~]# ll test
-rw-r--r--. 1 test dry1 0 May 26 02:25 test
[root@localhost ~]# 

umask命令
在这里插入图片描述

[root@localhost ~]# mkdir dd
[root@localhost ~]# ls -ld dd
drwxr-xr-x. 2 root root 4096 May 26 02:34 dd
[root@localhost ~]#  touch dd.txt
[root@localhost ~]# ll dd.txt 
-rw-r--r--. 1 root root 0 May 26 02:35 dd.txt

find命令
在这里插入图片描述

在这里插入图片描述

[root@localhost ~]# find /etc -name init
/etc/kdump-adv-conf/kdump_initscripts/init
/etc/init
/etc/sysconfig/init
[root@localhost ~]# find /etc -name *init*
/etc/selinux/targeted/contexts/initrc_context
/etc/rc.sysinit
/etc/festival/siteinit.scm
/etc/init.conf
[root@localhost ~]# find /etc -name init*
[root@localhost ~]# find /etc -name init???
/etc/inittab
[root@localhost ~]# 
[root@localhost ~]# find -user test
./test
[root@localhost ~]# 
[root@localhost ~]# find / -size +204800

在这里插入图片描述

[root@localhost ~]# find /etc -cmin -6

在这里插入图片描述

[root@localhost ~]# find /etc/ -size +163840 -a -size -204800
[root@localhost ~]# find /etc/ -size +163840 -o -size -204800
[root@localhost ~]# find /etc/ -name inittab -exec ls -l {} \;

在这里插入图片描述

[root@localhost ~]# find /etc/ -name init* -a -type d
/etc/init
/etc/rc.d/init.d
[root@localhost ~]# 
[root@localhost ~]# ls -i 
144158 1.sh             144592 anaconda-ks.cfg  144170 dry                 144092 shtest
144118 2020-05-23.log   144249 dd               144136 hello.sh            144653 Templates
144157 2.sh             144117 dd dd            131075 install.log         144169 test
144174 3.sh             144263 dd.txt           131076 install.log.syslog  144139 test.txt
144119 abc              144651 Desktop          144656 Music               272526 Videos
144125 abc1             144655 Documents        272525 Pictures
136757 access_log.2020  144652 Downloads        144654 Public
[root@localhost ~]# find . -inum 144117 -exec rm {} \;
[root@localhost ~]# ls -i 
144158 1.sh             144592 anaconda-ks.cfg  144136 hello.sh            144653 Templates
144118 2020-05-23.log   144249 dd               131075 install.log         144169 test
144157 2.sh             144263 dd.txt           131076 install.log.syslog  144139 test.txt
144174 3.sh             144651 Desktop          144656 Music               272526 Videos
144119 abc              144655 Documents        272525 Pictures
144125 abc1             144652 Downloads        144654 Public
136757 access_log.2020  144170 dry              144092 shtest
[root@localhost ~]# 

locate命令
在这里插入图片描述

[root@localhost ~]# locate inittab
/etc/inittab
/usr/share/augeas/lenses/dist/inittab.aug
/usr/share/man/man5/inittab.5.gz
/usr/share/vim/vim74/syntax/inittab.vim
[root@localhost ~]# 
[root@localhost ~]# updatedb  更新文件资料库

which命令
在这里插入图片描述

[root@localhost ~]# which ls
alias ls='ls --color=auto'
	/bin/ls
[root@localhost ~]#  

whereis命令
在这里插入图片描述

[root@localhost ~]# whereis ls
ls: /bin/ls /usr/share/man/man1p/ls.1p.gz /usr/share/man/man1/ls.1.gz
[root@localhost ~]# whereis useradd
useradd: /usr/sbin/useradd /usr/share/man/man8/useradd.8.gz
[root@localhost ~]# 

grep命令
在这里插入图片描述

[root@localhost ~]# more /etc/inittab 
[root@localhost ~]# grep reboot /etc/inittab 
#   6 - reboot (Do NOT set initdefault to this)
[root@localhost ~]# 
[root@localhost ~]# grep -v ^# /etc/inittab 
id:5:initdefault:
[root@localhost ~]# 

man命令

在这里插入图片描述

[root@localhost ~]# man ls
[root@localhost ~]# man services

help命令
在这里插入图片描述

[root@localhost ~]# help umask

useradd命令
在这里插入图片描述

passwd命令
在这里插入图片描述

[root@localhost ~]# useradd xiaocui
[root@localhost ~]# passwd xiaocui
Changing password for user xiaocui.
New password: 
BAD PASSWORD: it is based on a dictionary word
BAD PASSWORD: is too simple
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@localhost ~]# 
[xiaocui@localhost root]$ passwd 修改用户密码

who命令
在这里插入图片描述
w命令
在这里插入图片描述

 [root@localhost ~]# w
 04:02:42 up 4 days, 18:56,  5 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     tty1     :0               Thu09    4days 28.28s 28.28s /usr/bin/Xorg :0 -br -verbose
root     pts/0    192.168.137.1    18:48    7:50m  0.23s  0.23s -bash
root     pts/1    :0.0             Thu09    4days  0.02s  0.02s bash
root     pts/2    192.168.137.1    02:23    0.00s  0.63s  0.21s w
root     pts/3    192.168.137.1    02:24    2:40   0.02s  0.02s -bash
[root@localhost ~]# uptime
 04:03:56 up 4 days, 18:57,  5 users,  load average: 0.00, 0.00, 0.00
[root@localhost ~]# 

gzip命令
在这里插入图片描述

[root@localhost tmp]# touch test.txt
[root@localhost tmp]# gzip test.txt 

gunzip命令
在这里插入图片描述

[root@localhost tmp]# gunzip test.txt.gz 

tar命令
在这里插入图片描述

[root@localhost tmp]# tar -zcf test1.tar test.txt 
[root@localhost tmp]# tar -zcf test1.tar.gz test.txt

在这里插入图片描述

[root@localhost tmp]# tar -zxvf test1.tar.gz 
test.txt

zip命令
在这里插入图片描述

 [root@localhost tmp]# zip test.zip test.txt 
 [root@localhost tmp]# zip -r test.zip test

unzip命令
在这里插入图片描述

[root@localhost tmp]# unzip test.zip 

bzip2命令
在这里插入图片描述
bunzip命令
在这里插入图片描述
write命令
在这里插入图片描述
last命令
在这里插入图片描述
lastlog命令在这里插入图片描述

[root@localhost tmp]# lastlog

traceroute命令
在这里插入图片描述

[root@localhost tmp]# traceroute www.baidu.com

netstat命令
在这里插入图片描述
在这里插入图片描述

setup命令
在这里插入图片描述
mount命令
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值