Common Linux commands. File processing commands

1. File processing command

command format

命令 选项 参数	

illustrate

  1. Individual command usage does not follow this format

  2. When there are multiple options, they can be written together

  3. Simplified vs Full Options

    For example: -a=–all

Directory processing command: ls

grammar:

ls 选项 文件或目录
   -a   #显示所有文件,包括影藏文件
   -l   #详细信息显示
   -d   #查看目录属性
   -i   #查看识别号

illustrate:

Original English meaning: list

Function description: display user directory

example:

[root@localhost ~]# ls -a  #或-all,查看带“."的隐藏文件
.                .bash_logout   .cshrc              .tcshrc
..               .bash_profile  install.log         .viminfo
anaconda-ks.cfg  .bashrc        install.log.syslog  .Xauthority
[root@localhost ~]# ls -l  # 显示文件详细信息
总用量 44
-rw-------. 1 root root  1240 3月  15 06:26 anaconda-ks.cfg
-rw-r--r--. 1 root root 27338 3月  15 06:26 install.log
-rw-r--r--. 1 root root  7572 3月  15 06:25 install.log.syslog
[root@localhost ~]# ls -lh  #显示详细信息,并计算大小加单位。
总用量 44K
-rw-------. 1 root root 1.3K 3月  15 06:26 anaconda-ks.cfg
-rw-r--r--. 1 root root  27K 3月  15 06:26 install.log
-rw-r--r--. 1 root root 7.4K 3月  15 06:25 install.log.syslog
[root@localhost /]# ls -ld /root/  #查看目录本身而不展开目录
dr-xr-x---. 2 root root 4096 3月  17 01:03 /root/
[root@localhost /]# ls -i /root/  #查看系统用来识别文件的序号
720 anaconda-ks.cfg   53 install.log   69 install.log.syslog

File Permissions:

dr-xr-xr-x.   2 root root  4096 3月  15 07:22 bin

The above is the permission of the bin directory

  1. The first 'd' at the beginning is the file type (-binary file d directory l soft link)

  2. The last 9 digits are file permissions

r-x r-x r-x

u g o

u owner g group o others

r read w write x execute

Directory processing command: mkdir

grammar:

mkdir -p 目录名   #创建新目录
                 #递归创建

illustrate:

English original meaning of the command: make directories

Function: create directory

example:

[root@localhost tmp]# mkdir -p /root/tzc/bk/  #加-p 连续创建多个目录
[root@localhost tmp]# 

Directory processing command: cd

grammar:

cd 目录

illustrate:

Original English meaning: change directory

Function: switch directory

example:

[root@localhost tmp]# cd /root/tzc/bk/   #进入目录
[root@localhost bk]# cd ..               #退回上一级
[root@localhost tzc]#                    #这里已经到达了上级目录  

File processing command: rmdir

grammar:

rmdir 目录名

English willing: remove empty directories

Function: delete empty directory

example:

[root@localhost ~]# rmdir /tzc/wj/     #删除空目录/tzc/wj/

Directory processing command: cp

grammar

cp -rp 【源文件或目录】 【目标目录】
   -r   #复制目录
   -p   #保留文件属性

Original English meaning: copy

Function: Copy files or directories

example:

[root@localhost ~]# cp -rp tzc /tmp/ #把当前目录下的tzc 复制到/tmp,并  
[root@localhost ~]#                                      保留相关属性

You can also copy multiple directories or files at the same time, with spaces between files

[root@localhost ~]# cp -rp tzc zct /tmp/

Directory processing command: mv

grammar

mv 【原文件或目录】 【目标目录】

Original English meaning: move

Function description: move file to rename

example:

move

[root@localhost ~]# mv /root/tzc/ /tmp/   #移动目录tzc到/tmp
[root@localhost ~]# ls /tmp/              #查看tmp
tzc  yum.log  zct

Renamed:

[root@localhost ~]# mv zct ttt     #把当前目录的zct 改为ttt
[root@localhost ~]# ls
anaconda-ks.cfg  install.log  install.log.syslog  ttt

Directory processing command: rm

grammar:

rm -rf 【文件或目录】
   -r   #删除目录
   -f   #强制执行

illustrate:

Original English meaning: remove

Function: delete file

example:

delete

[root@localhost ~]# rm -r ttt/   #删目录文件
rm:是否删除目录 "ttt"?           #确认删除 

force delete

[root@localhost ~]# rm -rf ttt   #直接删除无需确认
[root@localhost ~]# 

Guess you like

Origin blog.csdn.net/xrgzky/article/details/123533572