Linux 常用命令

老是忘记一些命令。于是便记了下来:)

SSH常用命令

1. 不带端口号的连接:
$ ssh -l username ip
$ ssh -l ubuntu0 192.168.123.100

2. 带端口号的链接:
$ ssh -l username ip -p port
$ ssh -l root 224.217.33.111 -p 8888

SCP常用命令

1. 从远端拷贝单个文件到本地,带端口号(-P 为大写):
$ scp -P port root@ip:path_remote path_local
$ scp -P 8888 root@224.217.33.111:/home/aku/www/weekphp/sql.txt /home/david/

2. 从远端拷贝整个文件目录到本地,带端口号(-P 为大写):
$ scp -r -p port username@ip:path_remote path_local
$ scp -r -P 8888 root@224.217.33.111:/home/aku/www/weekphp/ /tmp/

3. 从本地拷贝单个文件到远端,不带端口号:
$ scp path_local username@ip:path_remote
$ scp index.html ubuntu0@192.168.123.100:/tmp/

查找文件内容

1. 在某一目录下查找是否有包含指定内容的文件
$ grep STRING PATH -r
$ grep “function render(” icampus/ -r

2. 使用find在某一目录下查找某一文件
$ find <指定目录> <指定条件> <指定动作>
$ find / -name “mysql.h” -ls
搜索根目录中,所有文件名以mysql.h开头的文件,并显示它们的详细信息。

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.