linux不可不知的几个常用命令

dafenqi
2023-12-29 / 0 评论 / 15 阅读 / 正在检测是否收录...

linux不可不知的几个常用命令

  1. cd:进入目录,并切换当前工作目录

示例:cd /var/www/html
进入/var/www/html目录

  1. ls:列出当前目录下的文件和目录

示例:ls /var/www/html
列出/var/www/html目录下的文件和目录

  1. touch:创建空文件

示例:touch test.php
创建一个名为test.php的空文件

  1. mkdir:创建一个新目录

示例:mkdir images
创建一个名为images的新目录

  1. cp:复制文件或目录

示例:cp index.php /var/www/html
将index.php文件复制到/var/www/html目录下

  1. mv:移动文件或目录

示例:mv index.php /var/www/html
将index.php文件移动到/var/www/html目录下

  1. rm:删除一个文件或目录

示例:rm index.php
删除名为index.php的文件

  1. chmod:更改文件或目录的权限

示例:chmod 755 index.php
将index.php文件的权限更改为755

  1. chown:更改文件或目录的所有者

示例:chown www-data:www-data index.php
将index.php文件的所有者更改为www-data用户和www-data组

  1. ps:查看当前正在运行的进程

示例:ps aux
列出当前所有进程的详细信息

  1. top:实时查看系统的进程状态和资源占用情况

示例:top
实时查看系统进程和资源占用情况

  1. tar:打包和压缩文件或目录

示例:tar -czvf backup.tar.gz /var/www/html
将/var/www/html目录打包并压缩为backup.tar.gz文件

  1. grep:搜索文件中匹配的字符串

示例:grep "hello" test.txt
在test.txt文件中搜索包含"hello"的字符串

  1. sed:编辑文本文件并执行替换、删除和插入等操作

示例:sed 's/hello/world/g' test.txt
将test.txt文件中所有出现的"hello"替换为"world"

  1. find:查找文件或目录

示例:find /var/www/html -name "*.php"
在/var/www/html目录下查找所有以.php结尾的文件

  1. ssh:连接远程服务器

示例:ssh user@10.0.0.1
使用用户名user连接到IP地址为10.0.0.1的远程服务器

  1. scp:从本地主机复制文件到远程主机或从远程主机复制文件到本地主机

示例:scp local_file remote_user@remote_host:/remote/dir
将本地文件复制到远程主机的/remote/dir目录

  1. ping:测试服务器的连通性

示例:ping google.com
测试连接到google.com的响应时间和连通性

  1. netstat:显示当前网络连接、开放端口和正在进行的进程

示例:netstat -an
列出所有网络连接和开放端口

  1. ifconfig:显示网络接口的配置信息

示例:ifconfig eth0
列出名为eth0的网络接口的配置信息

0

Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /www/wwwroot/testblog.58heshihu.com/var/Widget/Archive.php on line 1032

评论 (0)

取消