What does the command mean in linux
在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可以是 一个或两个十六进制数字 退出状态: 返回成功除非有写错误发生。
--help (查看外部命令帮助)
[root@localhost ~]# ls --help
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 ~]#
info
[root@localhost ~]# info ls
二、目录操作
[root@localhost ~]# pwd //显示当前路径2 /root [root@localhost ~]# cd /bin [root@localhost bin]# pwd [-lp] // -p 显示真实路径 /bin [root@localhost bin]#
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 |
-i | indoe号 | 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
Symbol | Effect | ||||||||||||||||||
? | # 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:]] | ##A~Z (uppercase)|||||||||||||||||||
Any number among 123 | |||||||||||||||||||
Any lowercase letter# from a~z | |||||||||||||||||||
0~9 Any number | ##\ | ||||||||||||||||||
escape character (Indicates the original meaning) | [^zhao] | ||||||||||||||||||
Match all characters in the list except z, h, a, o (can be deduced by analogy) | ##[[:digit: ]] | ||||||||||||||||||
Any number is equivalent to 0~9 | 实操,列几个例子
[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 命令别名
[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)
du和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 UndressAI-powered app for creating realistic nude photos ![]() AI Clothes RemoverOnline AI tool for removing clothes from photos. ![]() Undress AI ToolUndress images for free ![]() Clothoff.ioAI clothes remover ![]() Video Face SwapSwap faces in any video effortlessly with our completely free AI face swap tool! ![]() Hot Article
Roblox: Grow A Garden - Complete Mutation Guide
3 weeks ago
By DDD
How to fix KB5055612 fails to install in Windows 10?
3 weeks ago
By DDD
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.1Easy-to-use and free code editor ![]() SublimeText3 Chinese versionChinese version, very easy to use ![]() Zend Studio 13.0.1Powerful PHP integrated development environment ![]() Dreamweaver CS6Visual web development tools ![]() SublimeText3 Mac versionGod-level code editing software (SublimeText3) ![]() Hot Topics
Java Tutorial
![]() ![]()
CakePHP Tutorial
![]() ![]()
Laravel Tutorial
![]() ![]()
PHP Tutorial
![]() ![]()
C# Tutorial
![]() ![]() ![]() 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. ![]() 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 → ![]() 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. ![]() 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. ![]() 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. ![]() 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. ![]() 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) ![]() 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) ![]() |