0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Linuxの基本コマンド集①2018/04/03

Last updated at Posted at 2018-04-03

2018年4月3日スタート
40歳からスタートするLinux 1日目
基本コマンドを利用してディレクトリ作成、コピー、移動などを実行する。

mkdir newDir1 %ディレクトリを作る

[root@ik1-331-25935 home]# mkdir newDir1
[root@ik1-331-25935 home]# ls -l
total 4
drwx------ 4 kho       kho       4096 Apr  3 14:32 kho
drwx------ 2 lee       lee         80 Apr  3 13:30 lee
drwx------ 2 mizukoshi mizukoshi   80 Apr  3 13:30 mizukoshi
drwx------ 4 nam       nam        127 Apr  3 13:30 nam
drwxr-xr-x 2 root      root         6 Apr  3 18:14 newDir1
drwx------ 2      1001      1001   80 Apr  3 13:28 okuno
drwxr-xr-x 3 root      root        35 Apr  3 15:29 test
drwxr-xr-x 3 root      root        53 Apr  3 15:20 test2

cd newDir1 %newDir1ディレクトリに移動する

[root@ik1-331-25935 home]# cd newDir1
[root@ik1-331-25935 newDir1]# ls -l
total 0

mkdir subNewDir1 %ディレクトリを作る

[root@ik1-331-25935 newDir1]# mkdir subNewDir1
[root@ik1-331-25935 newDir1]# ls -l
total 0
drwxr-xr-x 2 root root 6 Apr  3 18:16 subNewDir1

mkdir -p newDir2/subNewDir2 %一発でディレクトリが作られる

[root@ik1-331-25935 home]# mkdir -p newDir2/subNewDir2
[root@ik1-331-25935 home]# ls -l
total 4
drwx------ 4 kho       kho       4096 Apr  3 14:32 kho
drwx------ 2 lee       lee         80 Apr  3 13:30 lee
drwx------ 2 mizukoshi mizukoshi   80 Apr  3 13:30 mizukoshi
drwx------ 4 nam       nam        127 Apr  3 13:30 nam
drwxr-xr-x 3 root      root        23 Apr  3 18:16 newDir1
drwxr-xr-x 3 root      root        23 Apr  3 18:19 newDir2
drwx------ 2      1001      1001   80 Apr  3 13:28 okuno
drwxr-xr-x 3 root      root        35 Apr  3 15:29 test
drwxr-xr-x 3 root      root        53 Apr  3 15:20 test2
[root@ik1-331-25935 home]#

cd newDir1 %移動
cal > cal1.txt %カレンダーファイルを作成

[root@ik1-331-25935 home]# cd newDir1
[root@ik1-331-25935 newDir1]# cal > cal1.txt
[root@ik1-331-25935 newDir1]# ls -l
total 4
-rw-r--r-- 1 root root 133 Apr  3 18:21 cal1.txt
drwxr-xr-x 2 root root   6 Apr  3 18:16 subNewDir1
[root@ik1-331-25935 newDir1]# cat cal1.txt
     April 2018
Su Mo Tu We Th Fr Sa
 1  2  3  4  5  6  7
 8  9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30

cp cal1.txt cal2.txt %cal1.txtコピーしてcal2.txtを作成
cat cal2.txt %内容を確認

[root@ik1-331-25935 newDir1]# cp cal1.txt cal2.txt
[root@ik1-331-25935 newDir1]# cat cal2.txt
     April 2018
Su Mo Tu We Th Fr Sa
 1  2  3  4  5  6  7
 8  9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30

cp cal2.txt cal1.txt %コピー
mv cal2.txt subNewDir1 %subNewDir1に移動させる
cd subNewDir1 %subNewDir1ディレクトリで確認

[root@ik1-331-25935 newDir1]# cp cal2.txt cal1.txt
[root@ik1-331-25935 newDir1]# mv cal2.txt subNewDir1
[root@ik1-331-25935 newDir1]# cd subNewDir1
[root@ik1-331-25935 subNewDir1]# ls
cal2.txt
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?