Linux note0x00

  • 2017-12-24
  • 120
  • 0


x: get in dir. r: browse dir.

File Special Authorization

  1. SUID
    • chmod u+s bin

    • For binary file

    • Equal: (tempUser) execute file

  2. SGID

    • chmod g+s dir

    • For binary file

    • Equal: (tempGroup) execute file

    • IF u create a file, the file will be belong to u,

    but not for sgid, it belongs to sgid directory which it located on.

  3. SBIT

    • chmod -R o+t dir

    • Make sure user only can delete their files

    • Others x authorization(The third x) will be t or T

Hidden attribute

  1. Chattr command

    • chattr +a file
    a仅允许补充(追加)内容,无法覆盖/删除内容(Append Only)
  2. Lsattr command
    • lsattr file

Access File Control Table

ACL: The file inherit parent directoryby default.

  1. Setfacl command
    • setfacl -Rm u:username:rwx /dir

    • serfacl -b /dir delete the acl

    • The last symbol of drwxrwxrwx. will be + instead of .

  2. Getfacl command

    • getfacl dir


  1. SU SUDO
    • su - user important
  2. Option command
    -u用户名或UID值 以指定的用户身份执行命令
    • Explanation :
      • limit user execute command

      • record every user executed command

      • config(/etc/sudoers) provide concentrated user management, authoization and so on.

  3. visudo

    • Forbidden multi users edit sudoers

    • Syntax check style

    • Use whereis command to find location

    • Edit the visudo 99 line: whoCouldUse AllowedHost=(Identifier) commandList

    • NoPasswd config: whoCouldUse AllowedHost=NOPASSWD: commandList

Storage structure and disk partition


  • Structure


/lib开机时用到的函数库,以及 |/bin与/sbin下面的命令要调用的函数
/usr/sbinLinux系统开机时不会使用到的软件 |/命令/脚本

Physics device name rules

udev manage service will monitor kernal signal to manage /dev directory dev file as daemon process.

Note issue:

  • /dev/sd{a-z} not depend on slot, but kernal recognize sequence.

  • sda[0-9] not order but could be manully

The first sector is the most important one.

[byte] 446:Master Boot Recorder, 64(16*4):partition, 2:end symbol

File system and data information

Ext3: log system. Track to recover or fix the crash issue.

Ext4: support: 1EB, batch blocks effectively

XFS: support: 18EB, advantage special after crash

  • partition, formatting file system, mount then could be used.
  1. every file occupies undepend inode table(128 byte)
    • authorization

    • owner and group

    • size

    • ctime (create, last edit)

    • atime (last access)

    • mtime file edited


    • point (file real data address)

  2. file real content saved in block, there will be a master block to note and connect others slaver block

inode default size: 128B(Ext3), block size: 4KB


  1. Mount hard dev

    Mount:The process associated dev or partition’s data with an existed dir, when user wanna to use them.

  • a option: mount all file system defined from /etc/fstab

  • t option: assign file system type

example: mount /dev/sdb2 /backup lose effect when restart system, umount /dev/sdb2

real ex: devFile mountDir type authorization selfInspect priority

# /etc/fstab

devFileUUID, devPath+devName
mountDirmount directory, should be created before mount
typeExt3, xfs, swap, iso9660(CD) and so on
Authorizationdefaults:rw, suid, exec, auto, nouser, async
selfInspection1: self-check disk when power on
priorityif selfInspection is 1, could be used

Add disk dev

  1. Fdisk command

    Type fdisk /dev/sdb

    • p: disk dev partition info(size, sectors)

    • n: add new partition

      • p new; e, extend

      • Main partition number: 1~4(default 1)

      • start position: default, sys will calc it

      • size: +2G 2GB disk partition

      • p check above, type w: really create it

    Type partprobe to synchro partitions info to kernal(Or restart sys)

    Mkfs command

    • mkfs tab twice will get command files like mkfs.type

    • mkfs.xfs /dev/sdb1

    Mout it mount /dev/sdb1 /aimDir/(real need /etc/fstab) and check df -h

  2. Du command, check file usage size

Add swap partition

Swap partition: 1.5~2 times than real physics memory

Usage: Stoage uncommonly using memory data to make memory more active for serving process well.

Quota to limit

  1. xfs_quota [args] size fileSys
  • c: args config command

  • x: expert mode

example: xfs_quota -x -c 'limit bsoft=3m bhard=6m isoft=3 ihard=6 tom' /boot disk hard & soft, file hard & soft

Hard & Symbolic link

  1. ln command

-s: symbolic link(default hard link)