在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 |
-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 表示显示隐藏文件,和通配符 * 一起使用后表示不显示隐藏文件 ls [[:digit:]] [root@localhost ~]# touch 1 2 3 #创建 1 2 3 [root@localhost ~]# ls [[:digit:]] #显示0-9任意的数字 1 2 3 #1 2 3 被显示 2.4、alias 命令别名
[root@localhost dev]# alias myvim=vim # 设置vim的别名myvim [root@localhost dev]# unalias myvim # 删除别名 [root@localhost dev]# myvim bash: myvim: 未找到命令... 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!

The five core components of the Linux operating system are: 1. Kernel, 2. System libraries, 3. System tools, 4. System services, 5. File system. These components work together to ensure the stable and efficient operation of the system, and together form a powerful and flexible operating system.

The five core elements of Linux are: 1. Kernel, 2. Command line interface, 3. File system, 4. Package management, 5. Community and open source. Together, these elements define the nature and functionality of Linux.

Linux user management and security can be achieved through the following steps: 1. Create users and groups, using commands such as sudouseradd-m-gdevelopers-s/bin/bashjohn. 2. Bulkly create users and set password policies, using the for loop and chpasswd commands. 3. Check and fix common errors, home directory and shell settings. 4. Implement best practices such as strong cryptographic policies, regular audits and the principle of minimum authority. 5. Optimize performance, use sudo and adjust PAM module configuration. Through these methods, users can be effectively managed and system security can be improved.

The core operations of Linux file system and process management include file system management and process control. 1) File system operations include creating, deleting, copying and moving files or directories, using commands such as mkdir, rmdir, cp and mv. 2) Process management involves starting, monitoring and killing processes, using commands such as ./my_script.sh&, top and kill.

Shell scripts are powerful tools for automated execution of commands in Linux systems. 1) The shell script executes commands line by line through the interpreter to process variable substitution and conditional judgment. 2) The basic usage includes backup operations, such as using the tar command to back up the directory. 3) Advanced usage involves the use of functions and case statements to manage services. 4) Debugging skills include using set-x to enable debugging mode and set-e to exit when the command fails. 5) Performance optimization is recommended to avoid subshells, use arrays and optimization loops.

Linux is a Unix-based multi-user, multi-tasking operating system that emphasizes simplicity, modularity and openness. Its core functions include: file system: organized in a tree structure, supports multiple file systems such as ext4, XFS, Btrfs, and use df-T to view file system types. Process management: View the process through the ps command, manage the process using PID, involving priority settings and signal processing. Network configuration: Flexible setting of IP addresses and managing network services, and use sudoipaddradd to configure IP. These features are applied in real-life operations through basic commands and advanced script automation, improving efficiency and reducing errors.

The methods to enter Linux maintenance mode include: 1. Edit the GRUB configuration file, add "single" or "1" parameters and update the GRUB configuration; 2. Edit the startup parameters in the GRUB menu, add "single" or "1". Exit maintenance mode only requires restarting the system. With these steps, you can quickly enter maintenance mode when needed and exit safely, ensuring system stability and security.

The core components of Linux include kernel, shell, file system, process management and memory management. 1) Kernel management system resources, 2) shell provides user interaction interface, 3) file system supports multiple formats, 4) Process management is implemented through system calls such as fork, and 5) memory management uses virtual memory technology.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version
Visual web development tools

Dreamweaver CS6
Visual web development tools

SublimeText3 Chinese version
Chinese version, very easy to use
