网络相关

Categories: Linux
arp -a 搜索同一网段机器 iptables -L -n -v 查看已添加的iptables规则 清空日志文件: cat /dev/null>/var/log/messages

crontab

Categories: Linux
1. 用法: 1.cat /etc/crontab 系统级 2./etc/cron.deny 所列用户不允许使用 3./etc/cron.allow 所列用户允许使用 4./var/spool/cron/ 下存储以用户名存储的文件 5.minute hour day month week command 6.crontab [-u user] -l 显示当前用户任务 7.crontab -l > z 备份当前用户的任务到z文件 8.crontab [-u user] -e 编辑当前用户的任务 9.crontab [-u user] -r 删除 10.crontab <filename> 从文件恢复 11.service crond start/stop/restart/reload 2. 例子: * * * * * command 每分钟执行 3,15 * * * * command 每小时第3,15分钟执行 3,15 8-11 */2 * * command 每2天的8-11点的第3,15分钟执行 30 21 * * 0,6 command 每周日、周六21:30分执行 * */2 * * * command 每2小时执行

dbf读写

Categories: Linux
新建一个dbf并写入数据 import dbf table = dbf.Table('temptable', 'name C(30); age N(3,0); birth D') print(table.field_names) table.open() for datum in (('John Doe', 31, dbf.Date(1979, 9, 13)), ('Ethan Furman', 102, dbf.Date(1909, 4, 1)), ('Jane Smith', 57, dbf.Date(1954, 7, 2)), ('John Adams', 44, dbf.Date(1967, 1, 9)),): table.append(datum) for record in table: print(record) table.close() 读取一个dbf并写入数据 table = dbf.Table('1.DBF') print(table.field_names) table.open() for data in (('1000', '10000001', '1', '1', '1', '1', '2', '1'), ): table.append(data) table.close()

sed

Categories: Linux
语法 sed [-hnV][-e<script>][-f<script文件>][文本文件] 参数 -e<script>或--expression=<script> 以选项中指定的script来处理输入的文本文件 -f<script文件>或--file=<script文件> 以选项中指定的script文件来处理输入的文本文件 -h或--help 显示帮助 -n或--quiet或--silent 仅显示script处理后的结果 -V或--version 显示版本信息 动作 a: 新增,在匹配的下一行新增一行 i: 插入,转匹配的上一行新增一行 c: 取代,c后面是将替换的值 d: 删除,删除指定行 p: 打印,通常与sed -n一起使用 s: 取代,进行搜索 例子 sed -e 4a\zx zx.txt:在第四行后面加zx,输出到标准输出,macOS语法错误 nl zx.txt |sed ‘2,5d’:列出内容并列出行号,同时删除2-5行 nl zx.txt |sed ‘2,$d’:删除2到最后一行 nl zx.txt |sed ‘2a zx’:第二行后增加zx,行前使用2i,macOS不可 nl zx.txt |sed ‘2a zx\按enter键xz’:第二行后加zx,xz2行数据,macOS不可 nl zx.txt |sed ‘2,3c kol’:2到3行替换为kol

Read More →

查看机器重启时间

Categories: Linux
who -b 上次启动时间 last reboot 系统启动记录 last reboot |head -1 最后一次启动时间 w 可查看系统已经运行时间 top 也可查看

输出重定向到文件

Categories: Linux
ls > log.log ls >> log.log --不覆盖log.log,追加 cat 1.txt 2> log.log --错误输出到log.log cat 1.txt > log.log 2>&1 --stderr也输出到stdout stdin 0 < stdout 1 1> stderr 2 2>

ubuntu server通过vnc连接(xrdp亦可)

Categories: Linux
1.安装 apt-get install vnc4server 2.设置密码 vncpasswd 或者 vncserver 创建一个 3.启动vnc vncserver:1 4.启动vnc客户端 输入IP地址加:1,例如192.168.1.104:1 5.配置文件 进入/root/.vnc vi xstartup #!/bin/sh # Uncomment the following two lines for normal desktop: # unset SESSION_MANAGER # exec /etc/X11/xinit/xinitrc [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic & #x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & #x-window-manager & sesion-manager & xfdesktop & xfce4-panel & xfce4-menu-plugin & xfsettingsd & xfconfd & xfwm4 & 6.

Read More →