Linux Daily Notes 3
I. Management authority and ownership
1. Permission overview
Document ownership
Owner (u): The user who owns this file/directory-user
Belonging group (g): The group that owns this file/directory-group
Other Users (o): Users other than the owner and the group to which they belong-other
access
Read (r): Allow content to be viewed-read
Write (w): Allow content modification-write
Executable (x): Allow run and toggle-excute
2. View permissions ls -l
# ls -l /etc/passwd
-|rw-|r--|r--. 1 root root 2481 Feb 23 09:37 /etc/passwd
① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩
Order of authority interpretation: ① ① ② ③④
① Document type
- file
D directory
l Links
Authority of the owner.
r = 4 Read
w = 2 write
x = 1 Executable
- no
③ Permission of the group to which it belongs
r = 4 Read
w = 2 write
x = 1 Executable
- no
④ Other users 'rights
r = 4 Read
w = 2 write
x = 1 Executable
- no
5 Number of links
File: Number of links
Directory: How many subdirectories (. ..)
6 Owner
Group 7
File size
File creation time
File/directory name
3. Change file ownership
# chown owner: file/directory change owner of file/directory
# chown : group files/directories Change the group to which a file/directory belongs
# chown Owner: Belongs to group files/directories Change the owner and group of files/directories
-R recursion
eg:
[root@ntd1711 ~]# rm -rf /tmp/*
[root@ntd1711 ~]# ls -ld /tmp/studir
[root@ntd1711 ~]# mkdir /tmp/studir
[root@ntd1711 ~]# ls -ld /tmp/studir
[root@ntd1711 ~]# chown student /tmp/studir/
[root@ntd1711 ~]# id student
[root@ntd1711 ~]# useradd student
[root@ntd1711 ~]# id student
[root@ntd1711 ~]# chown student /tmp/studir/
[root@ntd1711 ~]# ls -ld /tmp/studir
[root@ntd1711 ~]# chown :users /tmp/studir/
[root@ntd1711 ~]# ls -ld /tmp/studir
[root@ntd1711 ~]# chown root:root /tmp/studir/
[root@ntd1711 ~]# ls -ld /tmp/studir
4. Change file/directory permissions
chmod command
Format: chmod [ugoa][+-=][rwx] Document path...
-R: Recursive modification (including all subdirectories and documents in subdirectories)
[root@ntd1711 ~]# ls -ld /tmp/studir
[root@ntd1711 ~]# chmod g-rx,o-rx /tmp/studir/
[root@ntd1711 ~]# ls -ld /tmp/studir
[root@ntd1711 ~]# chmod u-w,g=rx /tmp/studir/
[root@ntd1711 ~]# ls -ld /tmp/studir
[root@ntd1711 ~]# chmod a=rwx /tmp/studir/
[root@ntd1711 ~]# ls -ld /tmp/studir
II. Backup and Recovery
1. Create/release zip packs
a. compressed zip
Format: zip [-ry] Backup file.zip File path...
eg:
[root@ntd1711 ~]# ls -ld /boot/
[root@ntd1711 ~]# ls /opt/
[root@ntd1711 ~]# zip -ry /opt/boot_bak.zip /boot/
[root@ntd1711 ~]# ls /opt
b. Decompression
Format: unzip backup file.zip [-d destination folder]
Format: unzip backup file.zip
eg:
[root@ntd1711 ~]# ls /tmp/todir
[root@ntd1711 ~]# unzip -d /tmp/todir /opt/boot_bak.zip
[root@ntd1711 ~]# ls /tmp/todir
2. Create/release. tarpack
a. Create.tar package and compress
basic usage
Format: tar -zcPf Backup file.tar.gz Document path...
Format: tar -jcPf Backup file.tar.bz2 Document path...
Format: tar -JcPf Backup File.tar.xz Document Path...
eg:
[root@ntd1711 ~]# ls -ld /var/log/
[root@ntd1711 ~]# du -sh /var/log/
[root@ntd1711 ~]# mkdir -p /tmp/day03
[root@ntd1711 ~]# tar -zcPf /tmp/day03/log.tar.gz /var/log/
[root@ntd1711 ~]# tar -jcPf /tmp/day03/log.tar.bz2 /var/log/
[root@ntd1711 ~]# tar -JcPf /tmp/day03/log.tar.xz /var/log/
[root@ntd1711 ~]# du -sh /tmp/day03/*
b. Decompress the.tar package
basic usage
Format: tar-xPf backup file.tar.gz
Format: tar -xf backup file.tar.bz2
Format: tar -xf backup file.tar.xz [-C destination folder]
eg:
[root@ntd1711 ~]# cd /tmp/day03/
[root@ntd1711 day03]# ls
[root@ntd1711 day03]# tar -xf log.tar.gz
[root@ntd1711 day03]# ls
[root@ntd1711 day03]# rm -rf var
[root@ntd1711 day03]# ls
[root@ntd1711 day03]# tar -xf log.tar.bz2
[root@ntd1711 day03]# ls
[root@ntd1711 day03]# rm -rf var
[root@ntd1711 day03]# ls
[root@ntd1711 day03]# tar -xf log.tar.xz
[root@ntd1711 day03]# ls
[root@ntd1711 day03]# rm -rf var
[root@ntd1711 day03]# ls
III. Access to CD-ROM and ISO image
1. Mount
mount device mount point (must be directory)
2. uninstall
umount equipment
mount mount point
3. Optical drive devices under Linux
/dev/sr0
/dev/cdrom
Lab: Access to CD-ROM Files
1. Put in the CD
Put iso files in optical drive
2. Mount
[root@ntd1711 ~]# ls /mnt/dvd
[root@ntd1711 ~]# mkdir -p /mnt/dvd
[root@ntd1711 ~]# ls /mnt/dvd/
[root@ntd1711 ~]# mount /dev/cdrom /mnt/dvd/
3. Access to CD content
[root@ntd1711 ~]# ls /mnt/dvd/
4. uninstall
[root@ntd1711 ~]# umount /mnt/dvd
[root@ntd1711 ~]# ls /mnt/dvd/