[关闭]
@big-bear 2018-01-22T08:30:16.000000Z 字数 929 阅读 901

linux命令

linux


常用

作用 命令 解释 备注
更改用户用户组 usermod -g group user
查看用户用户组 groups user

权限问题:

命令:

chmod 777 tt.htm

参考链接:http://www.cnblogs.com/sipher/articles/2429772.html

copy整个文件夹

命令:

cp -R ./work ./work0525

查看端口占用

netstat –apn | grep 8080

解压zip到当前目录

unzip xxxx.zip(压缩文件名称) 会在当前目录下新建一个xxxx目录,然后文件解压进去

常用shell命令

删除n天的文件

  1. #!/bin/sh
  2. location="/root/sqlbak/"
  3. find $location -mtime +30 -type f |xargs rm -f

shell获取时间日期

  1. today=$(date +%Y%m%d)
  2. time=$(date +%H%M%S)
  3. if [ ! -d "$today" ]; then
  4. mkdir "$today"
  5. fi
  6. mysqldump -utnbadmin -ptnb_5120 -h rm-2ze4s2eb30i6p83dv.mysql.rds.aliyuncs.com tnbdb >/home/tiannianbao/mysql-backup/$today/$time.sql

字符串输入文件

  1. echo "aaa" > a.txt
  2. echo aaa > a.txt
  1. echo "aaa" >> a.txt
  2. echo aaa >> a.txt

查看文件大小

du -sm aaa.txt

vi异常退出后修改

1.

  1. vi -r {your file name}
  2. rm .{your file name}.swp

2.

在网上搜到了一个类似的提示,不同的Linux提示可能不一样

  1. “.xorg.conf.swp already exists!
  2. [O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit:

当然可以用R键恢复。

后台运行

  1. command & : 后台运行,你关掉终端会停止运行
  2. nohup command & : 后台运行,你关掉终端也会继续运行

查看日志

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注