Table of Contents
一、命令行格式
1.1、何为命令?" >1.1、何为命令?
1.2、获得命令帮助" >1.2、获得命令帮助
二、目录操作
2.1、cd
2.2、ls
2.3. Wildcards
2.4、alias    命令别名   " >2.4、alias    命令别名   
2.5、du(disk usage)
Home Operation and Maintenance Linux Operation and Maintenance What does the command mean in linux

What does the command mean in linux

Mar 16, 2023 am 11:30 AM
linux

在linux中,凡是在字符操作界面中输入能够完成特定操作和任务的字符串都可以称为命令;命令通常只代表实现某一类功能的程序的名称。命令格式为“命令字 选项 参数”,选项包含段格式选项和长格式选项,段格式选项使用“-”符号引导后面通常跟一个字母,长格式选项使用“--”符号引导通常后面接完整单词。

What does the command mean in linux

本教程操作环境:linux7.3系统、Dell G3电脑。

一、命令行格式

1.1、何为命令?

  • 在Linux操作系统中,凡是在字符操作界面中输入能够完成特定操作和任务的字符串都可以称为命令
  • 命令通常只代表实现某一类功能的程序的名称

命令的格式:命令字 +选项+参数(中间用空格隔开)

选项包含段格式选项和长格式选项,段格式选项使用“-”符号引导后面通常跟一个字母,长格式选项使用“--”符号引导通常后面接完整单词

1.2、获得命令帮助

help:

[root@localhost ~]# help echo
#内部命令查看帮助
echo: echo [-neE] [参数 ...]
    将参数写到标准输出。

    在标准输出上显示 ARG 参数后跟一个换行。

    选项:
      -n    不要追加换行
      -e    启用下列反斜杠转义的解释
      -E    显式地抑制对于反斜杠转义的解释

    `echo' 对下列反斜杠字符进行转义:
      \a    警告(响铃)
      \b    退格
      \c    抑制更多的输出
      \e    转义字符
      \f    格式提供
      \n    换行
      \r    回车
      \t    横向制表符
      \v    纵向制表符
      \\    反斜杠
      \0nnn    以 NNN (八进制)为 ASCII 码的字符。 NNN 可以是
        0到3个八进制数字
      \xHH    以 HH (十六进制)为值的八比特字符。HH可以是
        一个或两个十六进制数字

    退出状态:
    返回成功除非有写错误发生。
Copy after login

--help (查看外部命令帮助)

[root@localhost ~]# ls --help
Copy after login

man

[root@localhost ~]# whatis ls
ls (1)               - 列目录内容
ls (1p)              - list directory contents
[root@localhost ~]# whatis passwd# 可以查看命令的章节
passwd (5)           - (未知的主题)
sslpasswd (1ssl)     - compute password hashes
passwd (1)           - update user's authentication tokens
[root@localhost ~]#
Copy after login

info

[root@localhost
 ~]# info ls
Copy after login

二、目录操作

 [root@localhost ~]# pwd                 //显示当前路径2 /root
 [root@localhost ~]# cd /bin
 [root@localhost bin]# pwd [-lp]        // -p 显示真实路径
 /bin
 [root@localhost bin]#
Copy after login

2.1、cd

命令(cd)效果
~切换到当前用户的宿主目录(家目录)
-到前一次目录
.(一个点号)以当前工作目录为起点
.. (两个点号)以当前目录的上一级目录为起点

2.2、ls

格式:ls [选项] [文件或目录]

选项效果实操
-l以长格式显示文件和目录列表
 1 [root@localhost ~]# ls -l
Copy after login

-a

显示全部包括隐藏文件 1 [root@localhost ~]# ls -a
-A显示全部文件或隐藏文件,但不包括 . 和 .. 1 [root@localhost ~]# ls -A
-d仅列出目录本身,而不是列出目录内的文件数据

1 [root@localhost ~]# ls -d

-h人性化显示 1 [root@localhost ~]# ls -h
-R递归显示该目录及该目录的子目录下的所有内容 1 [root@localhost ~]# ls -R
--color显示颜色 1 [root@localhost ~]# ls --color
-S以文件容量大小排序 1 [root@localhost ~]# ls -S
-iindoe号 1 [root@localhost ~]# ls -i

Note:

ls is generally not used alone. Options must be added, otherwise all files in the current folder will be displayed. Excessive number of files may cause a crash

ls can be used with wildcards to filter the required files

2.3. Wildcards

The role of wildcards: match names in files and fuzzy search files

##A~Z (uppercase) [123]Any number among 123[a-z]Any lowercase letter# from a~z #[0-9]##\[^zhao]
SymbolEffect
? # Matches one character Example: f? .txt (file starting with f)
*Match all non-hidden characters, but not hidden files
##{1....10}1~10
##{a...z}or [[:lower:]]a~z (lowercase)
{A....Z} or [[:upper:]]
0~9 Any number
escape character (Indicates the original meaning)
Match all characters in the list except z, h, a, o (can be deduced by analogy) ##[[:digit: ]]
Any number is equivalent to 0~9

实操,列几个例子

ls -a *

[root@localhost ~]# ls -a *
{1...10}.txt  anaconda-ks.cfg  elsfk.sh  initial-setup-ks.cfg
# 本来ls -a 表示显示隐藏文件,和通配符 * 一起使用后表示不显示隐藏文件
Copy after login
ls [[:digit:]]
[root@localhost ~]# touch 1 2 3             #创建 1 2 3
 [root@localhost ~]# ls [[:digit:]]          #显示0-9任意的数字
1 2 3                                       #1 2 3 被显示
Copy after login

2.4、alias 命令别名

  • alias 命令别名="命令"
  • unalias 删除别名
  • \+别名命令 显示原始命令
  • alias 直接显示所有别名

[root@localhost dev]# alias myvim=vim
# 设置vim的别名myvim
[root@localhost dev]# unalias myvim
# 删除别名
[root@localhost dev]# myvim
bash: myvim: 未找到命令...
Copy after login

2.5、du(disk usage)

选项 说明 效果
-a 统计占用时的所有文件

 

 

-h 人性化显示(以kb计数不显示单位)

 

 

-s 只统计所占用空间总的大小

 

 

--max-depth=n 最大显示到第n层

 

 

--exclude 不计入统计

 

 

du和ls

  • du:统计的当前文件占磁盘的大小,不足4k按4k算

  • ls:看到的是真是大小

相关推荐:《Linux视频教程

The above is the detailed content of What does the command mean in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1668
14
PHP Tutorial
1273
29
C# Tutorial
1256
24
Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

vscode Previous Next Shortcut Key vscode Previous Next Shortcut Key Apr 15, 2025 pm 10:51 PM

VS Code One-step/Next step shortcut key usage: One-step (backward): Windows/Linux: Ctrl ←; macOS: Cmd ←Next step (forward): Windows/Linux: Ctrl →; macOS: Cmd →

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

How to run sublime after writing the code How to run sublime after writing the code Apr 16, 2025 am 08:51 AM

There are six ways to run code in Sublime: through hotkeys, menus, build systems, command lines, set default build systems, and custom build commands, and run individual files/projects by right-clicking on projects/files. The build system availability depends on the installation of Sublime Text.

What is the main purpose of Linux? What is the main purpose of Linux? Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

laravel installation code laravel installation code Apr 18, 2025 pm 12:30 PM

To install Laravel, follow these steps in sequence: Install Composer (for macOS/Linux and Windows) Install Laravel Installer Create a new project Start Service Access Application (URL: http://127.0.0.1:8000) Set up the database connection (if required)

git software installation git software installation Apr 17, 2025 am 11:57 AM

Installing Git software includes the following steps: Download the installation package and run the installation package to verify the installation configuration Git installation Git Bash (Windows only)

See all articles