LoginSignup
179
132

More than 3 years have passed since last update.

scpコマンドでディレクトリ(フォルダ)をコピーしました

Last updated at Posted at 2014-12-19

サーバーにあるファイルをコピーするためにscpコマンドを使用しました。

ちなみにscpは ssh + cp の意味らしいです。

scpでディレクトリをコピー

-rとオプションをつけるとディレクトリをコピーすることができます。

サーバーからディレクトリをコピーする書き方
scp -r pugiemonn@example.com:/home/pugiemonn/hoge
 ~/Desktop/

example.comのhogeディレクトリをローカルのデスクトップに持ってきました。

ローカルのディレクトリをサーバーにコピーする場合です。

ディレクトリをサーバーへコピーする書き方
scp -r ~/Desktop/piyo pugiemonn@example.com:/home/pugiemonn/

piyoディレクトリをサーバーへコピーしています。

ディレクトリやファイルの権限に注意

上記の例では、pugiemonnユーザーのサーバー側の権限がある場所やファイルしかコピーできません。もしファイルのコピーが失敗したら権限を確認するといいです。

179
132
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
179
132