首页 > 技术文章 > linux常用命令

houstao 2018-01-14 23:30 原文

常用命令

  1、ls 查看目录下文件

  2、cd改变目录

  3、pwd查看当前目录

  4、service iptables status查看防火墙状态

  5.、永久性生效

  开启:chkconfig iptables on

  关闭:chkconfig iptables off

  6、 即时生效,重启后失效

  开启:service iptables start

  关闭:service iptables stop

  7、hostname # 查看计算机名

     [root@master /]# hostname     master 

  8、ps -ef # 查看所有进程 

  9、crontab -l # 查看当前用户的计划任务服务 

   [root@master /]# crontab -l     no crontab for root 

  10、 top # 实时显示进程状态用户 

  11、 netstat -lntp # 查看所有监听端口 

  12、netstat -antup|grep 9999 查看某个监听端口

  13、ifconfig # 查看所有网络接口的属性

  14、iptables -L # 查看防火墙设置 

  15、du -sh <目录名> # 查看指定目录的大小 

   [root@master /]# du -sh var 114M var 

  16、 uname -a # 查看内核/操作系统/CPU信息 

   [root@master /]# uname -a Linux master 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux 

  17、head -n 1 /etc/issue # 查看操作系统版本 

  18、cat /proc/cpuinfo # 查看CPU信息

 1 [root@master /]# cat /proc/cpuinfo
 2 processor       : 0
 3 vendor_id       : GenuineIntel
 4 cpu family      : 6
 5 model           : 69
 6 model name      : Intel(R) Core(TM) i3-4005U CPU @ 1.70GHz
 7 stepping        : 1
 8 microcode       : 0x17
 9 cpu MHz         : 1695.455
10 cache size      : 3072 KB
11 physical id     : 0
12 siblings        : 1
13 core id         : 0
14 cpu cores       : 1
15 apicid          : 0
16 initial apicid  : 0
17 fpu             : yes
18 fpu_exception   : yes
19 cpuid level     : 13
20 wp              : yes
21 flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm arat epb pln pts dtherm fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid xsaveopt
22 bogomips        : 3392.17
23 clflush size    : 64
24 cache_alignment : 64
25 address sizes   : 42 bits physical, 48 bits virtual
26 power management:

·  19、free -m # 查看内存使用量和交换区使用量 

1 [root@master /]# free -m
2 \              total        used        free      shared  buff/cache   available
3 Mem:            976         339         493           2         143         476
4 Swap:          1023         169         854

  20、mount | column -t # 查看挂接的分区状态 

  21、route -n # 查看路由表 

1 [root@master /]# route -n
2 Kernel IP routing table
3 Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
4 0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 ens33
5 192.168.1.0     0.0.0.0         255.255.255.0   U     100    0        0 ens33

  22、last # 查看用户登录日志 

  23、cat 查看文件

  24、vi或vim编辑

  25、mkdir 创建

  26、rm -rf 删除包括文件中的子文件

  27、chmod -r 777 权限

  28、quit退出

  29、cp 文件位置  拷贝到的位置

  30、scp -cp 远程拷贝

推荐阅读