Windows だとあーやったけど, Linux だとどーやるの? の簡易まとめ。
フォルダー (ディレクトリー) を作りたい。
mkdir <ディレクトリー名>
で作れます。
Make Directories の略ですね。
$ mkdir test10
$ ls -l
total 0
drwxrwxr-x. 2 vagrant vagrant 6 Apr 16 00:07 test10
フォルダー (ディレクトリー) を移動したい。
cd <ディレクトリー名>
で移動できます。
Change the current Directory の略ですね。
$ cd test10
$ pwd
/home/vagrant/hoge/test10
空のファイルを作りたい。
$ touch test1.txt
$ ls -l test1.txt
-rw-rw-r--. 1 vagrant vagrant 0 Apr 16 00:07 test1.txt
ファイルを切り取って貼り付けたい。(ファイルの移動)
mv <ファイル名> <ディレクトリー名>
で移動できます。
MoVe の略ですね。
$ mv test1.txt test10
$ ls -l test10/test1.txt
-rw-rw-r--. 1 vagrant vagrant 0 Apr 16 00:07 test10/test1.txt
ファイルをコピーしたい。
cp <コピー元> <コピー先>
でコピーできます。
CoPy の略ですね。
$ cp test1.txt test2.txt
$ ls -l test*.txt
-rw-rw-r--. 1 vagrant vagrant 0 Apr 16 00:07 test1.txt
-rw-rw-r--. 1 vagrant vagrant 0 Apr 16 00:09 test2.txt
ショートカット (シンボリックリンク) を作りたい。
ln -s <リンク元> <リンク先>
でリンクを作れます。
LiNk の略ですね。
-s
はおまじない。
$ ln -s test2.txt test3.txt
$ ls -l test*.txt
-rw-rw-r--. 1 vagrant vagrant 0 Apr 16 00:07 test1.txt
-rw-rw-r--. 1 vagrant vagrant 0 Apr 16 00:09 test2.txt
lrwxrwxrwx. 1 vagrant vagrant 9 Apr 16 00:10 test3.txt -> test2.txt
ファイルを削除したい。
rm <ファイル名>
で削除できます。
ReMove の略ですね。
ただし, ゴミ箱に入るわけではなく, 完全に削除されます。
$ rm test4.txt
ファイル名を変更したい。
mv <変更前ファイル名> <変更後ファイル名>
で変更できます。
$ mv test2.txt test4.txt
$ ls -l test*.txt
lrwxrwxrwx. 1 vagrant vagrant 9 Apr 16 00:10 test3.txt -> test2.txt
-rw-rw-r--. 1 vagrant vagrant 0 Apr 16 00:09 test4.txt
ファイルのプロパティ (詳細) を見たい。
$ stat test1.txt
File: test1.txt
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 801h/2049d Inode: 16802907 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ vagrant) Gid: ( 1000/ vagrant)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2021-04-16 00:09:49.374640772 +0900
Modify: 2021-04-16 00:07:31.435894824 +0900
Change: 2021-04-16 00:07:31.435894824 +0900
Birth: -
どっとはらい。