WenJunjie Blog

sysadmin

Linux Details

| Comments

  1. 文件隐藏属性 lsattr chattr [+-=][ASacdistu] FileName +: Add one attribute -: Remove one attribute =: Set to be the only attributes that the files have import/useful option a: 只能追加文件内容,不能修改或删除内容 i: 文件不能被删除、改名、不能创建指向它的链接、不能向文件写内容

  2. 文件的特殊权限suid/sgid/sticky bit suid 以文件所有者的权限运行,不能对目录设置suid chmod u+s FileName chmod 4755 FileName sgid 以文件所属组的权限运行,目录里面的文件会继承目录的属性 chmod g+s FileName chmod 2771 FileName/Dir sticky 不能对文件设置sticky bit 对于该目录下的文件,只有它们的所有者才能删除它们 chmod o+t Dir chmod 1777 Dir

  3. ln option target linkname ln source_file target_file

  4. useradd -r -g GroupName -G Grp1 -G 加入另一组 -r 建立系统账号

  5. gdb gdb Program Program.core gdb -p PID gdb /usr/bin/httpd core (gdb) bt

  6. rsync rsync -avz /local/files -e “ssh -p $portNumber” user@remoteip:/path/to/files/ -n, –dry-run –bwlimit=KBPS –delete –existing –progress -d -u –include –exclude rsync -avzi file1 file2 –max-size -W –remove-source-files

rsync -ahvz

–exclude={/dev/,/proc/,/sys/,/tmp/,/run/,/mnt/} –link-dest=comparison_backup_folder

crontab 0 3 * * * Command

^ ^ ^ ^ ^ ^ | | | | | | Minute Hour Day of Month Month Weekday Shell command

  1. scp
  2. grep grep -rin xxx Files gzip -dc myfile.gz | grep abc -A2 -B2 gzip -9 grep -H xxx file grep -h xxx file

  3. netstat netstat -ntlp

  4. lsof 删除文件,文件句柄没释放 lsof |grep REG|awk ‘{if ($7 > 0) print $7, $9, $10)’|sort -rn | head -n 10 deleted

  5. dig 检查根服务和授权域服务器 DNS劫持检查 dig domain.com +trace dig domain.com @8.8.8.8 dig MX domain.com

  6. rpm rpm -ql fail2ban

  7. ps ps -C nginx -o pid,cmd

  8. find find -regex ‘.back\/def\/123..jpg’ find -regextype posix-egrep -regex ‘.abc\/def\/123..(jpg|png)’ find -regextype posix-egrep -regex ‘.abc\/def\/123..(jpg|png)’ -ctime -24 find -regextype posix-egrep -regex ‘.abc\/def\/123..(jpg|png)’ -ctime -24 -exec cp {} ~/yesterday \; find -regextype posix-egrep -regex ‘.abc\/def\/123..(jpg|png)’ -ctime -24 | while read line; do eog $line &; done; eog=eye of gnome

  9. tail tail -f file.txt | grep something –line-buffered

–build=x86_64-linux-gnu

lokkit –selinux=disabled

  1. tar

tar zcvf tar pczvf

mysql

mysqladmin -uroot -p processlist | awk -F “|” ‘{print $2}’|xargs -n 1 mysqladmin -uroot -p kill mysqladmin -uroot -p processlist|awk -F “|” ‘{if($3 == “wordpress”)print $2}’|xargs -n 1 mysqladmin -uroot -p kill

Comments