python linux 命令行_Python基础课程-Linux常用的命令行

PS1控制默认命令行提示符的格式

PS2控制后续命令行提示符的格式

50个常用命令

一,Basic Bash Shell

1. ls  列出目录和文件

-F 用颜色区分目录和文件

-a 列出所有文件包括隐藏文件

-R 遍历目录下的所有文件和目录

-l  长格式输出,显示更多信息。

2. 创建文件

touch

3.复制文件

cp source destination

-a 归档文件,并保留现有的属性。

-b 创建目标文件备份,而非覆盖文件

-r 递归复制文件

-R 递归复制目录

4.链接文件

ln file1 file2

-s soft link

5. mv 重命名文件,移动文件和目录

mv file1 file2

6. rm 删除文件

-i 互动删除

-r 递归删除文件和目录

-f 强制删除,不提示

7. mkdir 创建目录

-p

8.rmdir 删除目录,删除非空目录

9.stat 查看文件统计,列出所有文件相关信息

stat test10

10. file 查看文件类型

文本文件:包含可打印字符的文件

可执行文件:可在系统上运行的文件。

数据文件:包含不可打印二进制字符。

11. cat 查看整个文件

-n 加行号

-b 给有文本的行加行号。

-s 压缩多个空白行到单个空白行

12.more查看文件

13.less 查看文件

14.tail 查看部分文件,文件末尾显示。

-f 让tail保持活动,监控文件末尾的新内容

-n 显示文件最后的行数

15. head 查看文件头部

-n 显示开头的行数

16. kill 结束进程

1  HUP 挂起

2  INT 中断

3  QUIT 结束运行

9   KILL 无条件终止

15 TERM 尽可能终止

17 STOP 无条件停止运行

二,监测磁盘空间

17. mount -t type device directory 挂载媒体

-t  文件类型

ro 只读

rw  读写

loop 挂载一个文件

mount -t iso9660 -o loop DVD.iso mnt

-L label

-U uuid

18. df  查看磁盘空间使用量

-h 以人类可读形式显示M 代替兆字节,G替代吉字节

19. du 显示特定目录的磁盘使用情况

-c 显示所有已列出文件的总大小

-h 以人类可读格式显示

-s 显示每个输出参数的总计。

三,处理数据文件

20. sort 排序数据

-r 反序排序

-k 排序从POS1位置开始,如果指定了POS2的话,到POS2位置结束。

-t 指定一个用来区分键位置的字符

21.grep 过滤数据

-n 显示行号

-v 输出不匹配该模式的行

22. bzip2 压缩数据

bzip2 压缩文件

bzacat显示压缩文本文件内容

bunzip2解压压缩后的.bz2文件

bzip2recover 尝试恢复损毁的压缩文件

22. gzip 压缩工具

gzip 压缩文件

gzcat 查看压缩的文本文件内容

gunzip 解压文件

23. zip 工具

zip 压缩文件

zipcloak 创建加密压缩文件

zipsplit 分割zip文件为更小的固定大小文件

unzip 从压缩的zip文件中提取文件和目录

24. tar 归档数据

tar function 【options】object1 object2

-c 创建新归档

-A 将已有的tar归档文件追加到另一个已有的tar归档文件中

-t 列出已有tar归档文件的内容

-x 从归档中提取文件

-f 输出结果到文件

-j 输出结果重定向给bzip2压缩

-v 显示互动结果

-z 输出gzip压缩内容

25. alias 别名命令

alias li=‘ls -il’

-p 查看已有别名

文件权限

26. useradd 添加新用户

27.userdel 删除用户

28.usermod 修改用户

29.passwd 和 chpasswd 更改用户密码

30.groupadd 创建新组

31. groupmod 修改组

32. touch 创建文件

33. chmod 改变文件权限

34.chown 改变属主

35. chgrp 改变属组

四,管理文件系统

36.fdisk 分区工具

37. mkfs.ext4 创建文件系统工具

38.fsck 检查和修复文件系统错误

fsck options filesystem

逻辑卷管理器

39. pvcreate 定义物理卷

40. vgcreate 创建卷组

41. lvcreate  创建逻辑卷

42. 修改逻辑卷

vgchange     激活和禁用卷组

vgremove     删除卷组

vgextend      将物理卷加到卷组中

vgreduce       从卷组中删除物理卷

lvextend        增加逻辑卷大小

lvreduce         见效逻辑卷大小

五,系统性能监控

43.top process activity

PID     process identification

USER  Name of the user who owns(and perhaps started) the process.

PRI     Priority of the process

NI       Niceness level

SIZE   Amount of memory

RSS   Amount of physical RAM used, in kilobytes.

SHARE  State of the porcess shared with other processes, in Kilobytes.

44.vmstat system activity. hardware and system information

Processes

r: The number of processes waiting for runtime

b:The number of processes in uninterruptable sleep

Memory

swpd: The amount of virtual memory used(KB)

free:  The amount of idle memory (KB)

buff: the amount of memory used as buffers(KB)

cache: The amount of memory used as cache(KB)

Swap

si: Amount of memory swapped from the disk (KBps)

so: Amount of memory swapped to the disk (KBps)

IO

bi: Blocks sent to block device (blocks/s)

bo: Blocks received from a block device (blocks/s)

System

in:The number of interrupts per second , including the clock

cs:The number of context switches per second

CPU (% of total CPU time)

us:

sy:

id:

wa:

45.uptime  average system load  (KB)

46.ps pstree Displays the processes

-e display all process

-f display full format

free Memory usage

47.iostate Average CPU load, disk activity

48.sar Collect and report system activity

49.mpstat Multiprocessor usage

50.numastat   NUMA-related statistics

51.pmap      Process memory usage

52.netstat   Network statistics

53.iptraf      Real-time network statistics

54.tcpdump,ethereal  Detailed network traffic analysis

55.nmon      Collect and report system activity

56.strace      Systems call

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值