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 3 years have passed since last update.

LinuC合格用 1週間でLPICの基礎が学べる本 3日目まとめ

Last updated at Posted at 2021-04-06

圧縮・解凍・アーカイブについて

3日目まとめ-圧縮・アーカイブについて.png

実行結果

gzipによる圧縮
root@1c3df5ff4615:~# ls -l
total 12
drwxr-xr-x 2 root root 4096 Apr  6 15:34 sample_dir
-rw-r--r-- 1 root root 7644 Apr  6 15:38 sample_file
root@1c3df5ff4615:~# gzip sample_file 
root@1c3df5ff4615:~# ls -l
total 8
drwxr-xr-x 2 root root 4096 Apr  6 15:34 sample_dir
-rw-r--r-- 1 root root 2777 Apr  6 15:38 sample_file.gz
gunzipによる解凍
root@1c3df5ff4615:~# ls -l
total 8
drwxr-xr-x 2 root root 4096 Apr  6 15:34 sample_dir
-rw-r--r-- 1 root root 2777 Apr  6 15:38 sample_file.gz
root@1c3df5ff4615:~# gunzip sample_file.gz 
root@1c3df5ff4615:~# ls -l
total 12
drwxr-xr-x 2 root root 4096 Apr  6 15:34 sample_dir
-rw-r--r-- 1 root root 7644 Apr  6 15:38 sample_file
zipによる圧縮
nekonisi@nekonisi-mbp hoge % ls -l
total 40
drwxr-xr-x  4 nekonisi  staff    128  4  7 00:43 sample_dir
-rw-r--r--  1 nekonisi  staff  18747  4  7 00:42 sample_file
nekonisi@nekonisi-mbp hoge % zip sample_dir.zip sample_dir
  adding: sample_dir/ (stored 0%)
nekonisi@nekonisi-mbp hoge % ls -l
total 48
drwxr-xr-x  4 nekonisi  staff    128  4  7 00:43 sample_dir
-rw-r--r--  1 nekonisi  staff    172  4  7 00:43 sample_dir.zip
-rw-r--r--  1 nekonisi  staff  18747  4  7 00:42 sample_file
unzipによる解凍
nekonisi@nekonisi-mbp hoge % ls -l 
total 48
-rw-r--r--  1 nekonisi  staff    172  4  7 00:43 sample_dir.zip
-rw-r--r--  1 nekonisi  staff  18747  4  7 00:42 sample_file
nekonisi@nekonisi-mbp hoge % unzip sample_dir.zip 
Archive:  sample_dir.zip
   creating: sample_dir/
nekonisi@nekonisi-mbp hoge % ls -l
total 48
drwxr-xr-x  2 nekonisi  staff     64  4  7 00:43 sample_dir
-rw-r--r--  1 nekonisi  staff    172  4  7 00:43 sample_dir.zip
-rw-r--r--  1 nekonisi  staff  18747  4  7 00:42 sample_file
tarによるアーカイブ
nekonisi@nekonisi-mbp hoge % ls -l
total 48
drwxr-xr-x  2 nekonisi  staff     64  4  7 00:43 sample_dir
-rw-r--r--  1 nekonisi  staff    172  4  7 00:43 sample_dir.zip
-rw-r--r--  1 nekonisi  staff  18747  4  7 00:42 sample_file
nekonisi@nekonisi-mbp hoge % tar cvf sample_dir.tar sample_dir
a sample_dir
nekonisi@nekonisi-mbp hoge % ls -l
total 56
drwxr-xr-x  2 nekonisi  staff     64  4  7 00:43 sample_dir
-rw-r--r--  1 nekonisi  staff   1536  4  7 00:46 sample_dir.tar
-rw-r--r--  1 nekonisi  staff    172  4  7 00:43 sample_dir.zip
-rw-r--r--  1 nekonisi  staff  18747  4  7 00:42 sample_file
tarによるアーカイブの展開
nekonisi@nekonisi-mbp hoge % ls -l
total 56
-rw-r--r--  1 nekonisi  staff   1536  4  7 00:46 sample_dir.tar
-rw-r--r--  1 nekonisi  staff    172  4  7 00:43 sample_dir.zip
-rw-r--r--  1 nekonisi  staff  18747  4  7 00:42 sample_file
nekonisi@nekonisi-mbp hoge % tar xvf sample_dir.tar
x sample_dir/
nekonisi@nekonisi-mbp hoge % ls -l
total 56
drwxr-xr-x  2 nekonisi  staff     64  4  7 00:43 sample_dir
-rw-r--r--  1 nekonisi  staff   1536  4  7 00:46 sample_dir.tar
-rw-r--r--  1 nekonisi  staff    172  4  7 00:43 sample_dir.zip
-rw-r--r--  1 nekonisi  staff  18747  4  7 00:42 sample_file
tarによる圧縮アーカイブ
nekonisi@nekonisi-mbp hoge % ls -l
total 0
drwxr-xr-x  2 nekonisi  staff  64  4  7 00:43 sample_dir
nekonisi@nekonisi-mbp hoge % tar czvf sample_dir.tar.gz sample_dir 
a sample_dir
nekonisi@nekonisi-mbp hoge % ls -l
total 8
drwxr-xr-x  2 nekonisi  staff   64  4  7 00:43 sample_dir
-rw-r--r--  1 nekonisi  staff  114  4  7 00:49 sample_dir.tar.gz
tarによる圧縮アーカイブ解凍
nekonisi@nekonisi-mbp hoge % ls -l
total 8
-rw-r--r--  1 nekonisi  staff  114  4  7 00:49 sample_dir.tar.gz
nekonisi@nekonisi-mbp hoge % tar xzvf sample_dir.tar.gz 
x sample_dir/
nekonisi@nekonisi-mbp hoge % ls -l
total 8
drwxr-xr-x  2 nekonisi  staff   64  4  7 00:43 sample_dir
-rw-r--r--  1 nekonisi  staff  114  4  7 00:49 sample_dir.tar.gz

ユーザとグループについて

3日目まとめ-ユーザとグループ.png

実行結果

ユーザ追加
[root@69523716df27 /]# useradd nekonisi
# nekonisiでログイン
[root@69523716df27 /]# su - nekonisi
[nekonisi@69523716df27 ~]$ pwd
/home/nekonisi

suは環境変数が読み込まれない、su -は環境変数が読み込まれる

パスワード変更
# rootによる初回変更
[root@69523716df27 /]# passwd nekonisi
Changing password for user nekonisi.
New password: 
BAD PASSWORD: The password fails the dictionary check - it does not contain enough DIFFERENT characters
Retype new password: 
passwd: all authentication tokens updated successfully.

# 自分でも変更
[root@69523716df27 /]# su - nekonisi
Last login: Tue Apr  6 16:03:33 UTC 2021 on pts/1
[nekonisi@69523716df27 ~]$ passwd
Changing password for user nekonisi.
Changing password for nekonisi.
(current) UNIX password: 
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.
グループ追加
[root@69523716df27 /]# groupadd ginnan-boyz
[root@69523716df27 /]# cat /etc/group
root:x:0:
(省略)
nekonisi:x:1000:
ginnan-boyz:x:1001:
グループ参加
[root@69523716df27 /]# usermod -G ginnan-boyz nekonisi
[root@69523716df27 /]# cat /etc/group
root:x:0:
(省略)
nekonisi:x:1000:
ginnan-boyz:x:1001:nekonisi

[root@69523716df27 /]# su - nekonisi
Last login: Tue Apr  6 16:06:28 UTC 2021 on pts/1
[nekonisi@69523716df27 ~]$ groups
nekonisi ginnan-boyz
[nekonisi@69523716df27 ~]$ id
uid=1000(nekonisi) gid=1000(nekonisi) groups=1000(nekonisi),1001(ginnan-boyz)
グループ削除
[root@69523716df27 /]# groupdel ginnan-boyz
[root@69523716df27 /]# cat /etc/gruop
cat: /etc/gruop: No such file or directory
[root@69523716df27 /]# cat /etc/group
root:x:0:
(省略)
nekonisi:x:1000:

※ 銀杏BOYZは峯田がいる限りいなくならないです。

ユーザ削除
[root@69523716df27 /]# userdel nekonisi
[root@69523716df27 /]# ls /home/
nekonisi
# homeディレクトリも削除したい場合は
[root@69523716df27 /]# userdel -r nekonisi
[root@69523716df27 /]# ls /home/
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?