Skip to content

Instantly share code, notes, and snippets.

View ibreathebsb's full-sized avatar
🤠

Isaac Young ibreathebsb

🤠
View GitHub Profile
@ibreathebsb
ibreathebsb / Reverse Nodes in k-Group.go
Created October 5, 2018 14:15
Leetcode 25. Reverse Nodes in k-Group
func reverseKGroup(head *ListNode, k int) *ListNode {
if nil == head || k <= 1 {
return head
}
dummy := &ListNode{-1, head}
stack := make([]*ListNode, k)
pointer := 0
start, last := head, dummy
for nil != start {
stack[pointer] = start
@ibreathebsb
ibreathebsb / Swap Nodes in Pairs.go
Last active October 5, 2018 11:28
LeetCode 24. Swap Nodes in Pairs
func swapPairs(head *ListNode) *ListNode {
if head == nil {
return head
}
dummy := &ListNode{-1, head}
previous, current := dummy, head
for current != nil {
// adjust
next := current.Next
if next == nil {
import * as qs from 'qs'
import {env} from 'src/env'
import {timestamp} from './timestamp'
// 用于配置不同环境api地址
interface IAPIURL {
development: string
test: string
production: string
}

netstat

参数

  • -a 列出所有连接数据
  • -t tcp
  • -u udp
  • -n 列出端口号
  • -p 列出PID

at

只在某个时间点只执行一次的任务:

at now + 1minutes

crontab

quota

磁盘配额工具,针对不同的用户,群组设置不同的配额,quota支队文件系统有效,可以按照inode数量或者总的block容量来限制,支持soft和hard两个配额,当用户的磁盘配额 超过soft容量时,系统给予警告,超出hard配额时,多余的无法写入

  1. 将文件系统挂载为支持quota: mount -o remount,usrquota,grpquota /mountpoint
  2. 初始化quota配置,quotacheck -ugv -f/mountpoint 其中u和v分别代表检查用户配额和群组配额
  3. 启用或者禁用quota quotaon -ug /mountpoint quotaoff -ug /file-system
  4. 配置用户或者群组的限额edquota -u user edquota -g group 也可以复制某个用户/群组的配置edquota -p source -u target 或者使用直接配置命令setquota user/group blocksoft blockhard inodesoft inodehard /mountpoint
  1. su - user 只能切换到能够登录的用户,并且需要输入user的密码
  2. su 直接使用su,切换到root但是$PATH等环境变量不会改变,因此不推荐此方式
  3. sudo -u user command 输入当前用户自己的密码,并以user的身份执行命令

sudo

  1. 配置文件 /etc/sudoers,文件格式:用户 登录主机(可切换的用户) 可使用的绝对路径命令

shell脚本基础

test

判断常用命令,也可用[空格 条件 空格]代替

文件相关-f -e -d -l

权限相关 -r -w -x

awk

行内文本编辑,行内默认以空格或者Tab分割

awk 'condition1 {command1} condition2 {command2} ...'

# awk命令中的变量使用时不需要加$符号
# NF 当前行的列数

sed

stream editor