您的位置:首页 > 运维架构 > Linux

day04 - 02 linux简单的操作命令

2017-05-18 17:02 330 查看
man ls:查看ls的帮助文档
ls --help:查看ls的帮助文档,简单查看
help cd: 查看内置命令(man)不可以查看内置命令
touch [filename]:创建一个文件
pwd: 查看当前所在路径
ls: 查看当前路径下包含的内容
-l  查看详细信息
-a  查看全部文件信息,包含隐藏文件
-h  人性化的查看信息(大小标注单位等)
tty:查看当前的终端设备
cat filename: 查看文件内容
more filename: 查看文件部分内容
mkdir dir: 创建一个名字为dir的文件夹
-p  递归创建文件目录
mv file1 file2: 把file1移动到file2的位置
tree CN:查看目录树结构
cp: 复制
mv: 剪切
rm: 删除 -- 非常危险,Linux中没有回收站机制,通常将需要删除的文件单独放到一个目录中
tar zcvf demo.tar.gz [filename] [filename]: 打包压缩多个文件
du:查看但前目录大小(包含文件)
-sh 只看目录大小
free -m:    查看空闲内存
ip a: 查看ip地址
useradd oldboy: 添加用户
chown [用户].[用户组] [filename]: 修改文件用户权限
chmod 777 [filename or dir]:    更改权限

df: 查看盘符使用状态
[root@localhost ~]# df
Filesystem     1K-blocks    Used Available Use% Mounted on
注:分区                   已使用 可用    百分比   盘符
/dev/sda2       28528640 2433716  24639052   9% /
tmpfs             502172      80    502092   1% /dev/shm
/dev/sda1         289293   28455    245478  11% /boot

[root@localhost ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        28G  2.4G   24G   9% /
tmpfs           491M   80K  491M   1% /dev/shm
/dev/sda1       283M   28M  240M  11% /boot

top: 类似于windows的任务管理器,q退出
参数:
user:用户进程所占的cpu
system:操作系统本身所占的cpu
idle:cpu空闲率
iowait:cpu等待io的时间比,每执行一次需要等io操作的时间
mem(Memory):
total:总内存量
usage:内存使用
free:内存空闲
cached(缓存):以后可能会用到的内存,目前并没有使用
buffered(缓冲区中):正在准备使用的内存
真正空闲空间 = free + cached + buffered

kill PID(进程号), 杀掉进程

find 目录名: 查找文件
-name bubble  ,精确查询
-name *bubble*  ,文件名中包含bubble
-size n[cwbkMG]
File uses n units of space.  The following suffixes can be used:

‘b’    for 512-byte blocks (this is the default if no suffix is used)

‘c’    for bytes

‘w’    for two-byte words

‘k’    for Kilobytes (units of 1024 bytes)

‘M’    for Megabytes (units of 1048576 bytes)

‘G’    for Gigabytes (units of 1073741824 bytes)

The size does not count indirect blocks, but it does count blocks in  sparse
files  that are not actually allocated.  Bear in mind that the ‘%k’ and ‘%b’
format specifiers of -printf handle sparse files differently.  The ‘b’  suf-
fix  always  denotes  512-byte  blocks and never 1 Kilobyte blocks, which is
different to the behaviour of -ls.

find / -size +90M |xargs ls -lh
| 管道符,找出大小为90+的数据后,执行后面的命令

r   read    读       4
w   write   写       2
x   excute  执行     1

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: