linux常见命令til
-
一、常见的Linux命令及其用途
1. pwd (Print Working Directory)
用途:显示当前所在的工作目录。2. ls (List)
用途:列出当前目录下的文件和子目录。3. cd (Change Directory)
用途:切换工作目录到指定目录。4. mkdir (Make Directory)
用途:创建新的目录。5. rmdir (Remove Directory)
用途:删除空的目录。6. touch
用途:创建新的空文件或更新文件的访问和修改时间。7. cp (Copy)
用途:复制文件或目录。8. mv (Move)
用途:移动文件或目录,或用于重命名文件或目录。9. rm (Remove)
用途:删除文件或目录。使用rm命令要谨慎,因为删除后无法恢复。10. cat (Concatenate)
用途:连接文件并打印到标准输出。11. grep (Global Regular Expression Print)
用途:在文件中查找匹配指定模式的文本。12. find
用途:在指定目录下递归搜索满足条件的文件。13. chmod (Change Mode)
用途:改变文件或目录的权限。14. chown (Change Owner)
用途:改变文件或目录的所有者。15. chgrp (Change Group)
用途:改变文件或目录的所属组。16. tar (Tape Archive)
用途:创建、压缩、解压tar存档文件。17. unzip
用途:解压缩zip格式的压缩文件。18. top
用途:动态地显示系统进程信息。19. ps (Process Status)
用途:显示当前正在运行的进程信息。20. kill
用途:向进程发送信号,以终止或修改其行为。21. ping
用途:向指定的IP地址或域名发送ICMP Echo请求。22. ifconfig (Interface Configuration)
用途:查看或配置网络接口的信息。23. netstat (Network Statistics)
用途:显示网络连接、路由表和网络接口统计信息。24. ssh (Secure Shell)
用途:远程登录到其他计算机并执行命令。25. scp (Secure Copy)
用途:在本地主机和远程主机之间复制文件。以上只是Linux中的常见命令,还有其他更多命令,可以根据具体的需求学习和使用。通过熟练掌握这些命令,可以更高效地管理和操作Linux系统。
2年前 -
1. ls命令:用于列出当前目录中的文件和子目录。执行“ls -l”可以显示详细信息,如文件权限、所有者、大小和修改日期等。
2. cd命令:用于改变当前工作目录。执行“cd /path/to/directory”可以进入指定路径的目录,执行“cd ..”可以返回上一级目录。
3. rm命令:用于删除文件或目录。执行“rm file”可以删除指定的文件,执行“rm -r directory”可以删除指定的目录及其中的所有文件和子目录。
4. mv命令:用于移动或重命名文件或目录。执行“mv file1 file2”可以将file1重命名为file2,执行“mv file directory”可以将file移动到指定的目录。
5. cp命令:用于复制文件或目录。执行“cp file1 file2”可以复制file1为file2,执行“cp -r directory1 directory2”可以复制directory1及其内容到directory2。6. mkdir命令:用于创建新的目录。执行“mkdir directory”可以在当前目录下创建一个名为directory的新目录。
7. pwd命令:用于显示当前工作目录的路径。执行“pwd”可以显示当前所在的路径。
8. touch命令:用于创建新的空文件或更新已有文件的修改时间。执行“touch file”可以创建一个名为file的新文件,执行“touch -t time file”可以修改文件的修改时间。
9. cat命令:用于查看和连接文件内容。执行“cat file”可以将file的内容输出到屏幕上,执行“cat file1 file2 > file3”可以将file1和file2的内容合并到file3中。
10. grep命令:用于在文件中查找指定的字符串。执行“grep pattern file”可以在file中查找包含pattern的所有行,并将结果输出到屏幕上。总结:以上所列举的是Linux中常见的一些命令,其中包括文件和目录的操作、内容显示和搜索等功能。熟悉这些命令可以提高在Linux系统下的操作效率和便利性。
2年前 -
1. Introduction
In this article, we will discuss some common Linux commands. Linux is a powerful operating system that offers a command-line interface for executing various tasks. Understanding and using these commands will help you navigate and manage your Linux system more efficiently.2. File and Directory Operations
2.1. ls
The “ls” command is used to list the files and directories in a directory. It provides information such as permissions, ownership, size, and timestamps.2.2. cd
The “cd” command is used to change the current directory. To move up one level in the directory hierarchy, type “cd ..”. To go back to your home directory, simply type “cd” or “cd ~”.2.3. mkdir
The “mkdir” command is used to create a new directory. For example, to create a directory named “docs”, type “mkdir docs”.2.4. cp
The “cp” command is used to copy files and directories. To copy a file named “file.txt” to a directory named “backup”, type “cp file.txt backup”.2.5. mv
The “mv” command is used to move or rename files and directories. To move a file named “file.txt” to a directory named “target”, type “mv file.txt target”. To rename a file, simply provide the new name as the second argument.2.6. rm
The “rm” command is used to remove files and directories. To remove a file named “file.txt”, type “rm file.txt”. To remove a directory and its contents, use the “-r” option. For example, “rm -r directory”.3. File Manipulation
3.1. cat
The “cat” command is used to display the contents of a file. For example, to display the contents of a file named “file.txt”, type “cat file.txt”.3.2. grep
The “grep” command is used to search for a specific pattern in a file or a stream of text. For example, to search for the word “hello” in a file named “file.txt”, type “grep hello file.txt”.3.3. head
The “head” command is used to display the first few lines of a file. By default, it displays the first 10 lines. For example, to display the first 5 lines of a file named “file.txt”, type “head -n 5 file.txt”.3.4. tail
The “tail” command is used to display the last few lines of a file. By default, it displays the last 10 lines. For example, to display the last 5 lines of a file named “file.txt”, type “tail -n 5 file.txt”.3.5. touch
The “touch” command is used to create an empty file or update the timestamp of an existing file. For example, to create a file named “newfile.txt”, type “touch newfile.txt”.4. System Information
4.1. df
The “df” command is used to display the disk usage of the file system. It provides information such as the total size, used space, available space, and the mount point of each file system.4.2. free
The “free” command is used to display the amount of free and used memory in the system. It provides information such as the total memory, used memory, free memory, and the memory used by buffers and cache.4.3. top
The “top” command is used to display real-time information about the system’s processes. It shows information such as CPU usage, memory usage, and running processes. Press “q” to exit the “top” command.4.4. uname
The “uname” command is used to display information about the system’s kernel and operating system. For example, to display the kernel version, type “uname -r”.5. User Management
5.1. whoami
The “whoami” command is used to display the username of the current user.5.2. passwd
The “passwd” command is used to change the password for the current user. For example, to change the password, type “passwd”.5.3. useradd
The “useradd” command is used to create a new user account. For example, to create a user named “johndoe”, type “useradd johndoe”.5.4. userdel
The “userdel” command is used to delete a user account. For example, to delete a user named “johndoe”, type “userdel johndoe”.6. Network Management
6.1. ifconfig
The “ifconfig” command is used to display or configure the network interfaces on the system. For example, to display the IP address of an interface named “eth0”, type “ifconfig eth0”.6.2. ping
The “ping” command is used to test the connectivity between two hosts. For example, to ping a host named “example.com”, type “ping example.com”.6.3. netstat
The “netstat” command is used to display information about the network connections, routing tables, and network interface statistics.6.4. ssh
The “ssh” command is used to securely connect to a remote system over the network. For example, to connect to a remote system with the IP address “192.168.1.100”, type “ssh 192.168.1.100”.7. Conclusion
In this article, we discussed some common Linux commands that are used for file and directory operations, file manipulation, system information, user management, and network management. Understanding and using these commands will help you navigate and manage your Linux system effectively.2年前