一、CentOS基础命令(1.文件和目录操作)

文章目录

  • 一、CentOS的由来
  • 二、CentOS的优点和缺点
  • 三、基础操作命令
    • 1、文件和目录操作
      • (1.)cd - 切换目录
      • (2.)ls - 列出目录内容
      • (3.)pwd - 显示当前目录
      • (4.)mkdir - 创建目录
      • (5.)rmdir - 删除空目录
      • (6.)touch - 创建文件
      • (7.)cp - 复制文件或目录
      • (8.)mv - 移动文件或目录
      • (9.)rm - 删除文件或目录
      • (10.)cat - 查看文件内容
      • (11.)stat - 显示文件或目录的详细信息
      • (12.)file - 确定文件类型
    • 2、命令参数总结


一、CentOS的由来

CentOS全称为(Community Enterprise Operating System),中文意思是社区企业操作系统;它是基于Red Hat Enterprise Linux (RHEL)的源代码构建的,因此与RHEL在功能上几乎相同。

二、CentOS的优点和缺点

优点
免费与开源CentOS是基于Linux的,因此它是免费且开源的。用户可以随时获取其源代码,并根据需求进行定制,这对于程序开发人员尤其重要。
跨平台硬件支持CentOS支持广泛的硬件平台,这使得它能在多种不同的物理或虚拟环境中运行。
系统稳定CentOS的稳定性是其主要优势之一,它基于Red Hat Enterprise Linux (RHEL)的源代码构建,因此继承了RHEL的稳定性和可靠性。
企业级部署许多公司选择使用CentOS来代替商业版的Red Hat Linux,因为它提供了企业级的服务和支持。
社区支持CentOS拥有一个活跃的社区,用户可以从社区中获得帮助和支持。
兼容性良好CentOS与RHEL的兼容性良好,这为企业级部署提供了便利。
新特性和改进CentOS 8引入了许多新特性和改进,如更快的更新、更好的安全性和应用支持,以及更好的图形界面和工具。
缺点
更新速度CentOS的软件包更新速度相对较慢,可能不满足某些应用程序对最新软件版本的需求。
硬件和软件支持CentOS可能不支持最新的硬件型号和应用程序版本,这可能会限制在一些先进硬件上的应用。
发展方向自从Red Hat宣布停止支持CentOS后,CentOS的未来发展方向变得不太明确,这可能会影响用户对其长期使用的信心。

三、基础操作命令

1、文件和目录操作

(1.)cd - 切换目录

cd命令用于改变当前目录路径,如windows一样,只不过是鼠标变成了命令

# 使用cd /可以进入系统的根目录
[root@localhost ~]# cd /
[root@localhost /]#
# cd后不加任何参数,将用户带回主目录(这里通常对应于/home/用户名的路径)
[root@localhost /]# cd
[root@localhost ~]#
# 相对路径(目标目录位于当前工作目录下,可以直接使用cd 目录名来进入)
[root@localhost ~]# cd /bin
[root@localhost bin]#
# 绝对路径(指定完整的目录路径来切换到目标目录,不论当前位置在哪里)
[root@localhost /]# cd /usr/bin/
[root@localhost bin]#
# 使用..表示上级目录,连续使用多个..可以回到更高级的目录
[root@localhost bin]# cd ../../
[root@localhost /]#
# 使用~符号可以快速切换到当前用户的主目录
[root@localhost /]# cd ~
[root@localhost ~]#

(2.)ls - 列出目录内容

列出目录内容,可以使用多种参数来定制输出

# 显示当前所在路径下的所有目录及文件
[root@httpsl /]# ls
bin   dev  home  lib64       media  opt   root  sbin  sys  usr
boot  etc  lib   lost+found  mnt    proc  run   srv   tmp  var
[root@httpsl /]# 
# 显示所有文件及目录,包括以点(.)开头的隐藏文件
[root@httpsl /]# ls -a
.   .autorelabel  boot  etc   lib    lost+found  mnt  proc  run   srv  tmp  var
..  bin           dev   home  lib64  media       opt  root  sbin  sys  usr
[root@httpsl /]# 
# 以长格式显示文件和目录信息,包括权限、所有者、大小、创建时间等
[root@httpsl network-scripts]# ls -l
total 232
-rw-r--r--  1 root root   338 Mar 25 12:30 ifcfg-eth0
-rw-r--r--. 1 root root   254 Aug 19  2019 ifcfg-lo
lrwxrwxrwx. 1 root root    24 Sep 14  2020 ifdown -> ../../../usr/sbin/ifdown
-rwxr-xr-x. 1 root root   654 Aug 19  2019 ifdown-bnep
-rwxr-xr-x. 1 root root  6532 Aug 19  2019 ifdown-eth
[root@httpsl network-scripts]# 
# 倒序显示文件和目录,即最新的文件或目录将显示在最前面
[root@httpsl network-scripts]# ls -r
network-functions-ipv6  ifup-sit     ifup-ipv6      ifdown-TeamPort  ifdown-ipv6
network-functions       ifup-routes  ifup-ippp      ifdown-Team      ifdown-ippp
init.ipv6-global        ifup-ppp     ifup-eth       ifdown-sit       ifdown-eth
ifup-wireless           ifup-post    ifup-bnep      ifdown-routes    ifdown-bnep
ifup-tunnel             ifup-plusb   ifup-aliases   ifdown-ppp       ifdown
ifup-TeamPort           ifup-plip    ifup           ifdown-post      ifcfg-lo
ifup-Team               ifup-isdn    ifdown-tunnel  ifdown-isdn      ifcfg-eth0
[root@httpsl network-scripts]# 
# 按修改时间排序,最新的文件在最前面
[root@httpsl /]# ls -t
sys  root  run  proc  usr   lib    bin         var   media  opt
tmp  dev   etc  boot  sbin  lib64  lost+found  home  mnt    srv
[root@httpsl /]# 
# 以长格式列出所有文件,包括隐藏文件,并在文件名后添加类型标识符
[root@httpsl ~]# ls -alF
total 48
dr-xr-x---.  5 root root 4096 Mar 25 12:32 ./
dr-xr-xr-x. 18 root root 4096 Mar 25 12:30 ../
-rw-------   1 root root  768 Mar 25 21:31 .bash_history
-rw-r--r--.  1 root root   18 Dec 29  2013 .bash_logout
-rw-r--r--.  1 root root  176 Dec 29  2013 .bash_profile
-rw-r--r--.  1 root root  176 Dec 29  2013 .bashrc
drwx------   3 root root 4096 Sep 14  2020 .cache/
-rw-r--r--.  1 root root  100 Dec 29  2013 .cshrc
drwxr-xr-x   2 root root 4096 Nov 30  2021 .pip/
-rw-r--r--   1 root root  206 Mar 25 12:30 .pydistutils.cfg
drwx------   2 root root 4096 Sep 14  2020 .ssh/
-rw-r--r--.  1 root root  129 Dec 29  2013 .tcshrc
[root@httpsl ~]# 

(3.)pwd - 显示当前目录

pwd命令用于显示当前工作目录的完整路径

# 显示当前所在目录的绝对路径
[root@httpsl network-scripts]# pwd
/etc/sysconfig/network-scripts
# 显示出物理路径,即实际的路径,而不是符号链接指向的路径
[root@httpsl network-scripts]# pwd -P
/etc/sysconfig/network-scripts
# 显示逻辑路径;当有符号链接时,会直接显示链接文件的路径,而不是链接所指向的文件或目录的实际路径
[root@httpsl network-scripts]# pwd -L
/etc/sysconfig/network-scripts

(4.)mkdir - 创建目录

mkdir命令用于创建目录,其参数可以指定不同的操作行为

# 创建单一目录
[root@httpsl opt]# mkdir test
[root@httpsl opt]# ls
test
[root@httpsl opt]# 
# 递归创建目录,在一个目录内创建另一个目录,套娃模式
[root@httpsl /]# mkdir -p a/b/c
[root@httpsl /]# ls
a    boot  etc   lib    lost+found  mnt  proc  run   srv  tmp  var
bin  dev   home  lib64  media       opt  root  sbin  sys  usr
[root@httpsl /]# cd /a/b/c/
[root@httpsl c]# pwd
/a/b/c
[root@httpsl c]# 
# 创建目录返回创建结果,创建有反馈
[root@httpsl a]# mkdir -v c
mkdir: created directory ‘c’
[root@httpsl a]# ls
b  c
[root@httpsl a]# 
# 创建目录时自定义权限
[root@httpsl a]# mkdir -m 555 d
[root@httpsl a]# ls -l
total 12
drwxr-xr-x 3 root root 4096 Mar 25 21:51 b
drwxr-xr-x 2 root root 4096 Mar 25 21:56 c
dr-xr-xr-x 2 root root 4096 Mar 25 22:00 d
[root@httpsl a]# 

(5.)rmdir - 删除空目录

rmdir命令用于删除空目录,其常用参数包括-p和-v

# 删除一个目录
[root@httpsl a]# rmdir d
[root@httpsl a]# ls
b  c
[root@httpsl a]# 
# 删除目录时有反馈
[root@httpsl a]# rmdir -v c
rmdir: removing directory, ‘c’
[root@httpsl a]# ls
b
[root@httpsl a]# 
# 递归删除目录
[root@httpsl /]# ls
a    boot  etc   lib    lost+found  mnt  proc  run   srv  tmp  var
bin  dev   home  lib64  media       opt  root  sbin  sys  usr
[root@httpsl /]# rmdir -p a/b/c/
[root@httpsl /]# ls
bin   dev  home  lib64       media  opt   root  sbin  sys  usr
boot  etc  lib   lost+found  mnt    proc  run   srv   tmp  var
[root@httpsl /]# 

(6.)touch - 创建文件

touch命令是一个用于更新文件时间戳的实用工具,也可以用来创建新的空文件或设置特定的时间戳

# 创建一个文件
[root@httpsl test]# touch test
[root@httpsl test]# ls
test
[root@httpsl test]# 
# 更新文件的访问时间(atime)
[root@httpsl test]# touch -a test
[root@httpsl test]# ls -lu
total 0
-rw-r--r-- 1 root root 0 Mar 25 22:10 test
[root@httpsl test]# 
# 更新文件的修改时间(mtime)
[root@httpsl test]# touch -m test
[root@httpsl test]# ls -ll
total 0
-rw-r--r-- 1 root root 0 Mar 25 22:11 test
[root@httpsl test]# 
# 将已有的文件更改到指定的时间戳(修改文件和访问时间同时修改)
[root@httpsl test]# touch -d "2023-01-01 12:00" test
[root@httpsl test]# stat testFile: ‘test’Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: fd01h/64769d    Inode: 1441794     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2023-01-01 12:00:00.000000000 +0800
Modify: 2023-01-01 12:00:00.000000000 +0800
Change: 2024-03-25 22:15:24.244612743 +0800Birth: -
[root@httpsl test]# 
# 创建一个文件,并指定时间戳(修改文件和访问时间同时修改)
[root@httpsl test]# touch -d "2023-01-01 12:00" test1.txt
[root@httpsl test]# stat testFile: ‘test’Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: fd01h/64769d    Inode: 1441794     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2023-01-01 12:00:00.000000000 +0800
Modify: 2023-01-01 12:00:00.000000000 +0800
Change: 2024-03-25 22:15:24.244612743 +0800Birth: -
[root@httpsl test]# 

(7.)cp - 复制文件或目录

Linux中的cp命令用于复制文件或目录,其参数可以指定不同的复制行为

# -a在复制目录时经常使用,它会保留链接、文件属性,并复制目录下的所有内容
[root@httpsl test]# cp -a test kong/
[root@httpsl test]# ls
kong  test  test1.txt
[root@httpsl test]# ll kong/test 
-rw-r--r-- 1 root root 0 Jan  1  2023 kong/test
[root@httpsl test]# 
# 目录与文件同时复制
[root@httpsl test]# cp -r he/ kong/
[root@httpsl test]# ls
he  kong  test  test1.txt
[root@httpsl test]# ll kong/
he/     he.txt  test    
[root@httpsl test]# ll kong/he
he/     he.txt  
[root@httpsl test]# ll kong/he/he.txt 
-rw-r--r-- 1 root root 0 Mar 25 22:26 kong/he/he.txt
[root@httpsl test]# 
# 如果目标目录中存在该文件,则提醒是否要覆盖该文件
[root@httpsl test]# cp -ri he/ kong/
cp: overwrite ‘kong/he/he.txt’? 
# 仅复制源文件中更新时间较新的文件
[root@httpsl test]# cp -u he/he.txt kong/
[root@httpsl test]# ll kong/
total 4
drwxr-xr-x 2 root root 4096 Mar 25 22:26 he
-rw-r--r-- 1 root root    0 Mar 25 22:25 he.txt
-rw-r--r-- 1 root root    0 Jan  1  2023 test
[root@httpsl test]# 
# 显示复制过程
[root@httpsl test]# cp -v he/he.txt kong/
cp: overwrite ‘kong/he.txt’? y
‘he/he.txt’ -> ‘kong/he.txt’
[root@httpsl test]# ll kong/
total 4
drwxr-xr-x 2 root root 4096 Mar 25 22:26 he
-rw-r--r-- 1 root root    0 Mar 25 22:30 he.txt
-rw-r--r-- 1 root root    0 Jan  1  2023 test
[root@httpsl test]# 
# 保留源文件的权限、所有者和时间戳信息
[root@httpsl test]# cp -p he/he.txt kong/
cp: overwrite ‘kong/he.txt’? y
[root@httpsl test]# ll kong/
total 4
drwxr-xr-x 2 root root 4096 Mar 25 22:26 he
-rw-r--r-- 1 root root    0 Mar 25 22:25 he.txt
-rw-r--r-- 1 root root    0 Jan  1  2023 test
[root@httpsl test]#
# (这里没有显示出来硬链接的浅蓝色标识) 
# 只生成链接文件
[root@httpsl test]# cp -l he/he.txt nan
[root@httpsl test]# ll nan
total 0
-rw-r--r-- 2 root root 0 Mar 25 22:25 he.txt
[root@httpsl test]# 

(8.)mv - 移动文件或目录

mv命令在Linux系统中非常常用,主要用于移动或重命名文件和目录

# 在覆盖目标文件或目录前,在不确定是否需要覆盖时先为其创建一个备份
[root@httpsl test]# touch test
[root@httpsl test]# ll kong/
total 4
drwxr-xr-x 2 root root 4096 Mar 25 22:26 he
-rw-r--r-- 1 root root    0 Mar 25 22:32 he.txt
-rw-r--r-- 1 root root    0 Jan  1  2023 test
-rw-r--r-- 1 root root    0 Mar 25 22:33 test.txt
[root@httpsl test]# mv -b test kong/
mv: overwrite ‘kong/test’? y
[root@httpsl test]# ll kong/
total 4
drwxr-xr-x 2 root root 4096 Mar 25 22:26 he
-rw-r--r-- 1 root root    0 Mar 25 22:32 he.txt
-rw-r--r-- 1 root root    0 Mar 25 22:47 test
-rw-r--r-- 1 root root    0 Jan  1  2023 test~
-rw-r--r-- 1 root root    0 Mar 25 22:33 test.txt
[root@httpsl test]# 
# 强制移动或重命名文件。如果目标位置已存在同名文件或目录,使用此参数会直接覆盖,而不会提示用户确认
[root@httpsl test]# ls
he  kong  nan  test1.txt
[root@httpsl test]# ls kong/
he  he.txt  test  test~  test.txt
[root@httpsl test]# touch test
[root@httpsl test]# ls
he  kong  nan  test  test1.txt
[root@httpsl test]# mv -f test kong/
[root@httpsl test]# ls kong/
he  he.txt  test  test~  test.txt
[root@httpsl test]# 
# 在目标文件已存在时,会提示用户是否覆盖
[root@httpsl test]# touch test
[root@httpsl test]# mv -i test kong/
mv: overwrite ‘kong/test’? y
[root@httpsl test]# ls kong/
he  he.txt  test  test~  test.txt
[root@httpsl test]# 

(9.)rm - 删除文件或目录

rm命令用于删除文件和目录

# -i会让rm在删除前逐一询问用户确认,这样可以避免意外删除文件
[root@httpsl test]# ls
he  kong  nan  test1.txt
[root@httpsl test]# rm -i test1.txt 
rm: remove regular empty file ‘test1.txt’? y
[root@httpsl test]# ls
he  kong  nan
[root@httpsl test]# 
# 一般用于强制删除
[root@httpsl nan]# ls
he.txt
[root@httpsl nan]# rm -f he.txt 
[root@httpsl nan]# ls
[root@httpsl nan]# 
# 递归删除目录以及目录下的文件,会让用户确认一遍
[root@httpsl test]# ls he/
1.txt  he.txt
[root@httpsl test]# rm -r he
rm: descend into directory ‘he’? y
rm: remove regular empty file ‘he/1.txt’? y
rm: remove regular empty file ‘he/he.txt’? y
rm: remove directory ‘he’? y
[root@httpsl test]# ls
kong  nan
[root@httpsl test]# 
# 详细显示删除的步骤
[root@httpsl test]# ls kong/he
he.txt
[root@httpsl test]# rm -v kong/he/he.txt 
rm: remove regular empty file ‘kong/he/he.txt’? y
removed ‘kong/he/he.txt’
[root@httpsl test]# 

(10.)cat - 查看文件内容

cat命令是一个非常实用的工具,它不仅可以用于查看文件内容,还可以用于创建文件、连接文件以及重定向输出等操作

# -n会从1开始对所有输出的行进行编号,常用于显示文件内容时,方便查看行数
[root@httpsl network-scripts]# cat -n ifcfg-eth0 1  # Created by cloud-init on instance boot automatically, do not edit.2  # If you don't want cloud-init genrated automatically,you can disable it in /etc/cloud/cloud.cfg3  # For more information, please refer to: https://help.aliyun.com/document_detail/57803.html4  #5  BOOTPROTO=dhcp6  DEVICE=eth07  ONBOOT=yes8  STARTMODE=auto9  TYPE=Ethernet10  USERCTL=no
[root@httpsl network-scripts]# 
# 与-n一样,但是不会对空行进行编号
[root@httpsl network-scripts]# cat -b ifcfg-eth0 1  # Created by cloud-init on instance boot automatically, do not edit.2  # If you don't want cloud-init genrated automatically,you can disable it in /etc/cloud/cloud.cfg3  # For more information, please refer to: https://help.aliyun.com/document_detail/57803.html4  #5  BOOTPROTO=dhcp6  DEVICE=eth07  ONBOOT=yes8  STARTMODE=auto9  TYPE=Ethernet10  USERCTL=no
[root@httpsl network-scripts]# 
# 当遇到连续两行以上的空白行时,只输出一行空白行,这样可以压缩多余的空白行
[root@httpsl network-scripts]# cat test.txt 1  # Created by cloud-init on instance boot automatically, do not edit.2  # If you don't want cloud-init genrated automatically,you can disable it in /etc/cloud/cloud.cfg3  # For more information, please refer to: https://help.aliyun.com/document_detail/57803.html4  #5  BOOTPROTO=dhcp6  DEVICE=eth07  ONBOOT=yes8  STARTMODE=auto9  TYPE=Ethernet10  USERCTL=no
[root@httpsl network-scripts]# cat -s test.txt 1  # Created by cloud-init on instance boot automatically, do not edit.2  # If you don't want cloud-init genrated automatically,you can disable it in /etc/cloud/cloud.cfg3  # For more information, please refer to: https://help.aliyun.com/document_detail/57803.html4  #5  BOOTPROTO=dhcp6  DEVICE=eth07  ONBOOT=yes8  STARTMODE=auto9  TYPE=Ethernet10  USERCTL=no
[root@httpsl network-scripts]# 
# 使用^和M-符号显示文件中的不可打印字符,除了LFD和TAB之外
[root@httpsl network-scripts]# cat -v test.txt 1  # Created by cloud-init on instance boot automatically, do not edit.2  # If you don't want cloud-init genrated automatically,you can disable it in /etc/cloud/cloud.cfg3  # For more information, please refer to: https://help.aliyun.com/document_detail/57803.html4  #5  BOOTPROTO=dhcp6  DEVICE=eth07  ONBOOT=yes8  STARTMODE=auto9  TYPE=Ethernet10  USERCTL=no
[root@httpsl network-scripts]# 
# 在每行结束处显示$符号,以显示行尾
[root@httpsl network-scripts]# cat -e ifcfg-eth0 
# Created by cloud-init on instance boot automatically, do not edit.$
# If you don't want cloud-init genrated automatically,you can disable it in /etc/cloud/cloud.cfg$
# For more information, please refer to: https://help.aliyun.com/document_detail/57803.html$
#$
BOOTPROTO=dhcp$
DEVICE=eth0$
ONBOOT=yes$
STARTMODE=auto$
TYPE=Ethernet$
USERCTL=no$
[root@httpsl network-scripts]# 
# 将TAB字符显示为^I,以便更清楚地看到文本中的制表符
[root@httpsl network-scripts]# cat -t ifcfg-eth0 
# Created by cloud-init on instance boot automatically, do not edit.
# If you don't want cloud-init genrated automatically,you can disable it in /etc/cloud/cloud.cfg
# For more information, please refer to: https://help.aliyun.com/document_detail/57803.html
#
BOOTPROTO=dhcp
DEVICE=eth0
ONBOOT=yes
STARTMODE=auto
TYPE=Ethernet
USERCTL=no
[root@httpsl network-scripts]# 

(11.)stat - 显示文件或目录的详细信息

stat命令是一个非常强大的工具,它能够提供比ls命令更详细的文件状态信息,包括文件的访问时间、修改时间、状态改变时间、设备号、Inode号等

# stat跟随符号链接,显示链接所指向文件的信息
[root@httpsl /]# stat -L /sbin/File: ‘/sbin/’Size: 12288           Blocks: 24         IO Block: 4096   directory
Device: fd01h/64769d    Inode: 655368      Links: 2
Access: (0555/dr-xr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2024-03-25 12:31:32.547487172 +0800
Modify: 2024-03-25 12:30:54.155090531 +0800
Change: 2024-03-25 12:30:54.155090531 +0800Birth: -
# 显示文件所在文件系统的信息,而不是文件本身的信息
[root@httpsl /]# stat -f /sbin/File: "/sbin/"ID: 703fa81c59373c13 Namelen: 255     Type: ext2/ext3
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 10288203   Free: 9764230    Available: 9288303
Inodes: Total: 2621440    Free: 2560795
# stat以简洁的方式输出信息,只显示摘要信息
[root@httpsl /]# stat -t /sbin/
/sbin/ 12288 24 416d 0 0 fd01 655368 2 0 0 1711341092 1711341054 1711341054 0 4096

(12.)file - 确定文件类型

使用file命令时,你可以根据需要选择适当的参数来获取你想要的信息

# 在输出结果时不显示文件名,仅显示文件类型描述
[root@httpsl bin]# file -b bash
ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=85e3da5a087950e7aaeb7893c056218a8874d2e5, stripped
[root@httpsl bin]# 
# 显示指令执行的详细过程
[root@httpsl network-scripts]# file -c ifcfg-eth0 
cont    offset  type    opcode  mask    value   desc
# 显示file的版本信息
[root@httpsl network-scripts]# file -v
file-5.11
magic file from /etc/magic:/usr/share/misc/magic
# 后面跟名称文件,可以指定一个包含多个文件名的文本文件,file命令会依次识别这些文件
[root@httpsl test]# file -f 1.txt 
/etc/passwd: ASCII text
/etc/shadow: ASCII text
/etc/group:  ASCII text
/etc/fstab:  ASCII text
[root@httpsl test]# cat 1.txt 
/etc/passwd
/etc/shadow
/etc/group
/etc/fstab
[root@httpsl test]# 
# 查看符号链接指向的文件类型
[root@httpsl /]# file -L /test/1.txt 
/test/1.txt: ASCII text
[root@httpsl /]# 

2、命令参数总结

命令参数注释
cdcd /使用cd /可以进入系统的根目录
cdcd后不加任何参数,将用户带回主目录(这里通常对应于/home/用户名的路径)
cd /目录相对路径(目标目录位于当前工作目录下,可以直接使用cd 目录名来进入)
cd /目录/目录绝对路径(指定完整的目录路径来切换到目标目录,不论当前位置在哪里)
cd …/…/使用…表示上级目录,连续使用多个…可以回到更高级的目录
cd ~使用~符号可以快速切换到当前用户的主目录
lsls -a显示所有文件及目录,包括以点(.)开头的隐藏文件
ls -l以长格式显示文件和目录信息,包括权限、所有者、大小、创建时间等
ls -r倒序显示文件和目录,即最新的文件或目录将显示在最前面
ls -t按修改时间排序,最新的文件在最前面
ls -alF以长格式列出所有文件,包括隐藏文件,并在文件名后添加类型标识符
pwdpwd -p显示当前所在目录的绝对路径
pwd -L显示逻辑路径;当有符号链接时,会直接显示链接文件的路径,而不是链接所指向的文件或目录的实际路径
mkdirmkdir -p递归创建目录,在一个目录内创建另一个目录,套娃模式
mkdir -v创建目录返回创建结果,创建有反馈
mkdir -m创建目录时自定义权限
rmdirrmdir -v删除目录时有反馈
rmdir -p递归删除目录
touchtouch -a更新文件的访问时间(atime)
touch -m更新文件的修改时间(mtime)
touch -d将已有的文件更改到指定的时间戳(修改文件和访问时间同时修改)
touch -d创建一个文件,并指定时间戳(修改文件和访问时间同时修改)
cpcp -a-a在复制目录时经常使用,它会保留链接、文件属性,并复制目录下的所有内容
cp -r目录与文件同时复制
cp -ri如果目标目录中存在该文件,则提醒是否要覆盖该文件
cp -u仅复制源文件中更新时间较新的文件
cp -v显示复制过程
cp -p保留源文件的权限、所有者和时间戳信息
cp -l只生成链接文件
mvmv -b在覆盖目标文件或目录前,在不确定是否需要覆盖时先为其创建一个备份
mv -f强制移动或重命名文件。如果目标位置已存在同名文件或目录,使用此参数会直接覆盖,而不会提示用户确认
mv -i在目标文件已存在时,会提示用户是否覆盖
rmrm -i-i会让rm在删除前逐一询问用户确认,这样可以避免意外删除文件
rm -f一般用于强制删除
rm -r递归删除目录以及目录下的文件,会让用户确认一遍
rm -v详细显示删除的步骤
catcat -n-n会从1开始对所有输出的行进行编号,常用于显示文件内容时,方便查看行数
cat -b与-n一样,但是不会对空行进行编号
cat -s当遇到连续两行以上的空白行时,只输出一行空白行,这样可以压缩多余的空白行
cat -v使用^和M-符号显示文件中的不可打印字符,除了LFD和TAB之外
cat -e在每行结束处显示$符号,以显示行尾
cat -t将TAB字符显示为^I,以便更清楚地看到文本中的制表符
statstat -Lstat跟随符号链接,显示链接所指向文件的信息
stat -f显示文件所在文件系统的信息,而不是文件本身的信息
stat -tstat以简洁的方式输出信息,只显示摘要信息
filefile -b在输出结果时不显示文件名,仅显示文件类型描述
file -c显示指令执行的详细过程
file -v显示file的版本信息
file -f后面跟名称文件,可以指定一个包含多个文件名的文本文件,file命令会依次识别这些文件
file -L查看符号链接指向的文件类型

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/773122.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

智能媒体api调用

简单介绍一下 使用阿里智能媒体管理的api, 阿里云智能媒体管理(Intelligent Media Management,简称IMM),场景化封装数据智能分析管理,为云上文档、图片、视频数据,提供一站式数据处理、分析、检索等管控体验。 智能媒体管理针对不同行业的业务场景封装整合完整的处理能…

数学算法(算法竞赛、蓝桥杯)--最大公约数,欧几里得算法

1、B站视频链接&#xff1a;G05 最大公约数 欧几里得算法_哔哩哔哩_bilibili 题目链接&#xff1a;[NOIP2001 普及组] 最大公约数和最小公倍数问题 - 洛谷 #include <bits/stdc.h> using namespace std; typedef long long LL; LL x,y,ans;LL gcd(LL a,LL b){return b0?…

【P1328】[NOIP2014 提高组] 生活大爆炸版石头剪刀布

[NOIP2014 提高组] 生活大爆炸版石头剪刀布 题目背景 NOIP2014 提高组 D1T1 题目描述 石头剪刀布是常见的猜拳游戏&#xff1a;石头胜剪刀&#xff0c;剪刀胜布&#xff0c;布胜石头。如果两个人出拳一样&#xff0c;则不分胜负。在《生活大爆炸》第二季第 8 集中出现了一种…

linux用户管理命令2

useradd可以创建用户&#xff0c;其执行具体表现为在home文件夹下创建对应文件 那么有了useradd添加用户&#xff0c;自然有passwd添加用户密码 userdel可以删除用户&#xff0c;其中-r命令删除用户及其文件&#xff0c;-f命令可以强制删除用户&#xff0c;即使用户当前正在登录…

RN封装的底部向上弹出的弹出层组件

组件代码 import React from react; import { View, StyleSheet, Modal, TouchableOpacity, Text, TouchableWithoutFeedback } from react-native;const BottomPopup ({ visible, onClose, children, leftButtonTitle, rightButtonTitle, onLeftButtonPress, onRightButtonP…

Elasticsearch:语义搜索即服务处于卓越搜索的中心

作者&#xff1a;来自 Elastic Sherry Ger, Stephen Brown 对于许多企业来说&#xff0c;搜索卓越中心&#xff08;center of excellence - COE&#xff09;向其用户提供搜索服务&#xff0c;从不同的数据源中整理知识&#xff0c;并将搜索功能集成到其内部和外部应用程序中。…

IDEA或Pycharm设置Python环境报Cannot set up a python SDK的某种解决方案——更换IDEA或Pycharm的版本

一、问题 先用conda指令创建了python3.10的环境&#xff0c;然后在IDEA或Pycharm里添加Python解释器环境报Cannot set up a python SDK的错误&#xff0c; 二、解决方法 发现在默认创建新环境选择Python版本时只能选择&#xff1a;2.7&#xff0c;3.6&#xff0c;3.7&#xff…

“数据持久化”和“缓存与数据库不一致”到底有什么区别?

之前&#xff0c;我一直把“数据持久化”和“缓存与数据库不一致问题”给搞混了。我当时复习的时候基本上就没有思考&#xff0c;就是纯背诵&#xff0c;数据持久化是什么&#xff0c;数据持久化有两种方式&#xff0c;这两种方式特点是什么&#xff0c;然后巴拉巴拉一堆。缓存…

「09」媒体源:播放本地或在线的音视频GIF文件

「09」媒体源播放本地或在线的音视频GIF文件 通过媒体源功能&#xff0c;您可以添加自己想要展示的各种视频内容&#xff0c;例如自己的视频课程、电影或客户见证视频、以及GIF动画等。 &#xff08;图层叠加效果&#xff09; &#xff08;绿幕抠像叠加效果&#xff09; 缺点…

protobuf学习笔记(一):生成一个比较综合的message

一年前学过对应的知识&#xff0c;终究是太潦草了&#xff0c;这几天网上学习了一下&#xff0c;重新写一下笔记。这里是protobuf和golang的结合 一、protobuf protobuf实际上是一种类似json和gob之类的数据格式&#xff0c;也是grpc的御用格式吧&#xff08;有自己的优势&am…

[Android]创建Google Play内购aab白包

开发时需要调试Google内购&#xff0c;需要先往Google商店传一个白包上去。确定包名&#xff0c;然后进行内购产品创建。 1.创建一个空项目&#xff0c;填写正式名称和正式包名。 如果你只是为一个测试开发账号打白包&#xff0c;然后进行内购测试&#xff0c;这时包名随便写…

【idea快捷键】idea开发java过程中常用的快捷键

含义win快捷键mac快捷键复制当前行或选定的代码块Ctrl DCommand D通过类名快速查找类Ctrl NCommand N通过文件名快速查找文件Ctrl Shift NCommand Shift N通过符号名称快速查找符号&#xff08;类、方法等&#xff09;Ctrl Alt Shift NCommand Shift O跳转到声明C…

Flutter页面生命周期

基于StatefulWidget衍生出渲染页面层 基于StatelessWidget衍生出渲染普通(嵌入式小组件)层 StatelessWidget组件周期函数 : createElement/build函数 //StatefulWidget底层提供的周期事件(三阶段)&#xff1a; //①初始化期:createState,initState; //②更新期:didChangeDepe…

以太网PHY,MAC及其通信接口介绍

本文主要介绍以太网的 MAC 和 PHY&#xff0c;以及之间的 MII&#xff08;Media Independent Interface &#xff0c;媒体独立接口&#xff09;和 MII 的各种衍生版本——GMII、SGMII、RMII、RGMII等。 一&#xff1a;简介 从硬件的角度看&#xff0c;以太网接口电路主要由MA…

拌合楼管理软件开发(十一) 海康威视车牌识别摄像头安装调试,总算是跑通了。

前言&#xff1a;总算是调测通了 话接上回&#xff0c;车牌识别摄像头买回来了&#xff0c;卡在电源上了&#xff0c;今天抽时间把电源问题解决了&#xff0c;开始代码正式的调测。一切还算顺利了&#xff0c;没有再碰到打脸的事情了。 一、电源接线&#xff1a; 如同前面预想的…

masterGo 的设计网站介绍

https://mastergo.com/files/home 这个网站是一个设计图片的网站 ui设计方面的网站 有很多优秀的资源 比如App设计 可以直接用的图片 和设计模板 也可以像ps 一样 设计自己的图片或者ui图 适合前端和ui开发者使用 可以丰富自己的审美观

宝塔面板操作一个服务器域名部署多个网站

此处记录IP一样&#xff0c;端口不一样的操作方式&#xff1a; 宝塔面板操作&#xff1a; 1、创建第一个网站&#xff1a; 网站名用IP地址&#xff0c;默认80端口。 创建好后&#xff0c;直接IP访问就可以了。看到自带的默认首页 2、接下来部署第二个网站&#xff1a; 仍然是…

集成ES分组查询统计求平均值

前言 之前其实写过ES查询数据&#xff0c;进行分组聚合统计&#xff1a; 复杂聚合分组统计实现 一、目标场景 机房机柜的物联网设备上传环境数据&#xff0c;会存储到ES存到ES的温湿度数据需要查询&#xff0c;进行分组后&#xff0c;再聚合统计求平均值 二、使用步骤 1.引入…

docker快速安装Es和kibana

文章目录 概要一、Es二、kibana三、dcoker compose管理四、参考 概要 在工作过程中&#xff0c;经常需要测试环境搭建Es环境&#xff0c;本文基于Es V8.12.2来演示如何快速搭建单节点Es和kibana。 服务器默认已按装docker 一、Es 1&#xff1a;拉取镜像 docker pull elast…

课时76:流程控制_while循环_嵌套案例

1.2.3 嵌套案例 学习目标 这一节&#xff0c;我们从 基础知识、简单实践、小结 三个方面来学习。 基础知识 简介 这里的嵌套实践&#xff0c;与选择语句的嵌套实践基本一致&#xff0c;只不过组合的方式发生了一些变化。常见的组合样式如下&#xff1a;while嵌套while语句…