---
title: "linux命令"
author: "mistbow"
date: "2013-07-09T22:07:11Z"
tags: []
categories: ["企业架构"]
slug: "linux"
draft: false
lastmod: "2013-08-27T14:01:43Z"
id: 1902242
url: "https://mistbow.iteye.com/blog/1902242"
---

去掉windows结束符号 dos2unix -k -n NaapiVipPrice.php

ls -al

date

date +%Y/%m/%d

man date 查看用法

drwxr-xr-x 4 root root 4096 Jul  1 21:52 download

d是目录 -是文件 |表示连接文件
rwxr-xr-x权限 4连接数 root文件所有者 root文件所属用户组 4096 Jul  1 21:52 最后被修改时间

改变用户组：-R参数表示进行递归更改
chgrp users install.log

改变文件所有者：chown
chown bin install.log

拷贝文件：
cp 源文件 目标文件

改变文件权限：
chmod

切换身份：
su root

切换路径：cd
显示目前所在目录：pwd
新建新目录：mkdir
删除目录：rmdir

如果想让/root下面的命令可以在其他目录执行，那么可以：
PATH = "$PATH":/root

basename /etc/sysconfig/network    返回：network
dirname /etc/sysconfig/network   返回：/etc/sysconfig

touch 创建文件

file:查看文件的基本数据类型：ASCII data binary

which寻找执行文件

查找文件：
whereis ifconfig

find查找的时候有点慢

locate  keyword
-i忽略大小写的差异
-r后面可接正则表达式

find /etc -name '*httpd*'

查看目录容量：
df -h

连接文件：ln
ln -s /etc/crontab crontab2

vim下打开另一个窗口：
:sp /etc/hosts

ctrl + w + k
ctrl + w + j

:set nu
:set nonu

给组合命令设置一个别名：alias lm = 'ls -al'

type cd
cd is a shell builtin

hostname -i

errExit()
{
    echo "error $1"
    exit 1
}
for i in seq 100
do
    sql="insert into table_a(id)values(${i})"
    mysql -uroot -proot dbname <<<`echo ${sql}` || errExit "error in exec ${sql}"
done;

netstat -anp | grep 8080
ps -ef | grep pid