1.2.linux.传智.命令过程学习

1.文件切换操作

[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#ll————显示当前路径下的所有文件
total 92
-rw——-. 1 root root 3330 Feb 3 07:52 anaconda-ks.cfg
drwxr-xr-x. 2 root root 4096 Feb 3 08:16 Desktop
drwxr-xr-x. 2 root root 4096 Feb 3 07:57 Documents
drwxr-xr-x. 2 root root 4096 Feb 3 07:57 Downloads
-rw-r–r–. 1 root root 40279 Feb 3 07:52 install.log
-rw-r–r–. 1 root root 9272 Feb 3 07:50 install.log.syslog
drwxr-xr-x. 2 root root 4096 Feb 3 07:57 Music
drwxr-xr-x. 2 root root 4096 Feb 3 07:57 Pictures
drwxr-xr-x. 2 root root 4096 Feb 3 07:57 Public
drwxr-xr-x. 2 root root 4096 Feb 3 07:57 Templates
drwxr-xr-x. 2 root root 4096 Feb 3 07:57 Videos
[root@localhost ~]# pwd———-显示当前用户所处的路径
/root
[root@localhost ~]# cd /———–进入根目录
[root@localhost /]# ll—————显示根目录的所有内容
total 90
dr-xr-xr-x. 2 root root 4096 Feb 3 08:18 bin
dr-xr-xr-x. 5 root root 1024 Feb 3 07:52 boot
drwxr-xr-x. 18 root root 3920 Feb 3 07:56 dev
drwxr-xr-x. 98 root root 4096 Feb 3 08:18 etc
drwxr-xr-x. 3 root root 4096 Feb 3 07:52 home
dr-xr-xr-x. 10 root root 4096 Feb 3 07:48 lib
dr-xr-xr-x. 9 root root 12288 Feb 3 08:18 lib64
drwx——. 2 root root 16384 Feb 3 07:45 lost+found
drwxr-xr-x. 2 root root 4096 Sep 23 2011 media
drwxr-xr-x. 2 root root 4096 Sep 23 2011 mnt
drwxr-xr-x. 3 root root 4096 Feb 3 07:53 opt
dr-xr-xr-x. 159 root root 0 Feb 3 07:53 proc
dr-xr-x—. 27 root root 4096 Feb 3 08:16 root
dr-xr-xr-x. 2 root root 12288 Feb 3 08:18 sbin
drwxr-xr-x. 7 root root 0 Feb 3 07:53 selinux
drwxr-xr-x. 2 root root 4096 Sep 23 2011 srv
drwxr-xr-x. 13 root root 0 Feb 3 07:53 sys

  1. 16 root root 4096 Feb 3 08:17 tmp
    drwxr-xr-x. 13 root root 4096 Feb 3 07:45 usr

drwxr-xr-x. 21 root root 4096 Feb 3 07:50 var
[root@localhost /]# cd——–进入主用户目录下,此处是root主用户
[root@localhost ~]# ll
total 92
-rw——-. 1 root root 3330 Feb 3 07:52 anaconda-ks.cfg
drwxr-xr-x. 2 root root 4096 Feb 3 08:16 Desktop
drwxr-xr-x. 2 root root 4096 Feb 3 07:57 Documents
drwxr-xr-x. 2 root root 4096 Feb 3 07:57 Downloads
-rw-r–r–. 1 root root 40279 Feb 3 07:52 install.log
-rw-r–r–. 1 root root 9272 Feb 3 07:50 install.log.syslog
drwxr-xr-x. 2 root root 4096 Feb 3 07:57 Music
drwxr-xr-x. 2 root root 4096 Feb 3 07:57 Pictures
drwxr-xr-x. 2 root root 4096 Feb 3 07:57 Public
drwxr-xr-x. 2 root root 4096 Feb 3 07:57 Templates
drwxr-xr-x. 2 root root 4096 Feb 3 07:57 Videos
[root@localhost ~]# pwd
/root

2.网络配置操作

[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# ifconfig——查看所有网卡的配置

eth0

     Link encap:Ethernet  HWaddr 00:0C:29:52:C5:AF 
     inet addr:192.168.145.128  Bcast:192.168.145.255  Mask:255.255.255.0
     inet6 addr: fe80::20c:29ff:fe52:c5af/64 Scope:Link
     UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
     RX packets:100089 errors:0 dropped:0 overruns:0 frame:0
     TX packets:60058 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:1000
     RX bytes:135786210 (129.4 MiB)  TX bytes:6300628 (6.0 MiB)

lo

     Link encap:Local Loopback 
     inet addr:127.0.0.1  Mask:255.0.0.0
     inet6 addr: ::1/128 Scope:Host
     UP LOOPBACK RUNNING  MTU:16436  Metric:1
     RX packets:16 errors:0 dropped:0 overruns:0 frame:0
     TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:0
     RX bytes:960 (960.0 b)  TX bytes:960 (960.0 b)

[root@localhost ~]# ipconfig eth0 192.168.145.129—eth0网卡的IP更改为192.168.145.129
[root@localhost ~]# ifconfig———————————–同上
eth0

     Link encap:Ethernet  HWaddr 00:0C:29:52:C5:AF 
     inet addr:192.168.145.129  Bcast:192.168.145.255  Mask:255.255.255.0
     inet6 addr: fe80::20c:29ff:fe52:c5af/64 Scope:Link
     UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
     RX packets:100202 errors:0 dropped:0 overruns:0 frame:0
     TX packets:60093 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:1000
     RX bytes:135794420 (129.5 MiB)  TX bytes:6310735 (6.0 MiB)

lo

      Link encap:Local Loopback 
     inet addr:127.0.0.1  Mask:255.0.0.0
     inet6 addr: ::1/128 Scope:Host
     UP LOOPBACK RUNNING  MTU:16436  Metric:1
     RX packets:16 errors:0 dropped:0 overruns:0 frame:0
     TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:0
     RX bytes:960 (960.0 b)  TX bytes:960 (960.0 b)

[root@localhost ~]#
[root@localhost ~]# ifconfig eth0——-查看网卡eth0的详细配置
eth0

     Link encap:Ethernet  HWaddr 00:0C:29:52:C5:AF 
     inet addr:192.168.145.129  Bcast:192.168.145.255  Mask:255.255.255.0
     inet6 addr: fe80::20c:29ff:fe52:c5af/64 Scope:Link
     UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
     RX packets:100388 errors:0 dropped:0 overruns:0 frame:0
     TX packets:60109 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:1000
     RX bytes:135806653 (129.5 MiB)  TX bytes:6311863 (6.0 MiB)

[root@localhost ~]# ifconfig eth0 down—-将eth0网卡给关掉
[root@localhost ~]# ifconfig eth0—-同上
[root@localhost ~]# ifconfig eth0 up—-将eth0网卡给打开
[root@localhost ~]# ifconfig eth0—-同上
eth0 Link encap:Ethernet HWaddr 00:0C:29:52:C5:AF

     inet6 addr: fe80::20c:29ff:fe52:c5af/64 Scope:Link
     UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
     RX packets:100494 errors:0 dropped:0 overruns:0 frame:0
     TX packets:60125 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:1000
     RX bytes:135814294 (129.5 MiB)  TX bytes:6313607 (6.0 MiB)

[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# ifconfig—-同上
eth0

      Link encap:Ethernet  HWaddr 00:0C:29:52:C5:AF 
     inet addr:192.168.145.128  Bcast:192.168.145.255  Mask:255.255.255.0
     inet6 addr: fe80::20c:29ff:fe52:c5af/64 Scope:Link
     UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
     RX packets:100552 errors:0 dropped:0 overruns:0 frame:0
     TX packets:60168 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:1000
     RX bytes:135823375 (129.5 MiB)  TX bytes:6322221 (6.0 MiB)

lo

     Link encap:Local Loopback 
     inet addr:127.0.0.1  Mask:255.0.0.0
     inet6 addr: ::1/128 Scope:Host
     UP LOOPBACK RUNNING  MTU:16436  Metric:1
     RX packets:16 errors:0 dropped:0 overruns:0 frame:0
     TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:0
     RX bytes:960 (960.0 b)  TX bytes:960 (960.0 b)

[root@localhost ~]#
[root@localhost ~]# ifconfig eth0 netmask 255.255.0.0
[root@localhost ~]# ifconfig
eth0

     Link encap:Ethernet  HWaddr 00:0C:29:52:C5:AF 
     inet addr:192.168.145.128  Bcast:192.168.255.255  Mask:255.255.0.0
     inet6 addr: fe80::20c:29ff:fe52:c5af/64 Scope:Link
     UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
     RX packets:100630 errors:0 dropped:0 overruns:0 frame:0
     TX packets:60212 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:1000
     RX bytes:135828752 (129.5 MiB)  TX bytes:6329426 (6.0 MiB)

lo

     Link encap:Local Loopback 
     inet addr:127.0.0.1  Mask:255.0.0.0
     inet6 addr: ::1/128 Scope:Host
     UP LOOPBACK RUNNING  MTU:16436  Metric:1
     RX packets:16 errors:0 dropped:0 overruns:0 frame:0
     TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:0
     RX bytes:960 (960.0 b)  TX bytes:960 (960.0 b)

3.ping操作

[root@localhost ~]#
[root@localhost ~]# ping 192.168.145.1—–ping主机IP
PING 192.168.145.1 (192.168.145.1) 56(84) bytes of data.
64 bytes from 192.168.145.1: icmp_seq=1 ttl=128 time=0.844 ms
64 bytes from 192.168.145.1: icmp_seq=2 ttl=128 time=0.437 ms
64 bytes from 192.168.145.1: icmp_seq=3 ttl=128 time=0.488 ms
64 bytes from 192.168.145.1: icmp_seq=4 ttl=128 time=0.625 ms
64 bytes from 192.168.145.1: icmp_seq=5 ttl=128 time=0.989 ms
64 bytes from 192.168.145.1: icmp_seq=6 ttl=128 time=0.597 ms
64 bytes from 192.168.145.1: icmp_seq=7 ttl=128 time=0.581 ms
64 bytes from 192.168.145.1: icmp_seq=8 ttl=128 time=0.625 ms
64 bytes from 192.168.145.1: icmp_seq=9 ttl=128 time=0.655 ms
64 bytes from 192.168.145.1: icmp_seq=10 ttl=128 time=0.318 ms
64 bytes from 192.168.145.1: icmp_seq=11 ttl=128 time=0.660 ms
64 bytes from 192.168.145.1: icmp_seq=12 ttl=128 time=0.387 ms
64 bytes from 192.168.145.1: icmp_seq=13 ttl=128 time=0.348 ms
64 bytes from 192.168.145.1: icmp_seq=14 ttl=128 time=0.898 ms
64 bytes from 192.168.145.1: icmp_seq=15 ttl=128 time=0.494 ms
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# ping -n 3 192.168.145.1—-ping3次后停止ping操作
[root@localhost ~]# ping -t 10 192.168.145.1——一直ping下去
[root@localhost ~]# ping -l 1024 192.168.145.1—–ping的包设置大小
PING 192.168.145.1 (192.168.145.1) 56(84) bytes of data.
64 bytes from 192.168.145.1: icmp_seq=10 ttl=128 time=1.07 ms
64 bytes from 192.168.145.1: icmp_seq=11 ttl=128 time=0.717 ms
64 bytes from 192.168.145.1: icmp_seq=12 ttl=128 time=0.978 ms
64 bytes from 192.168.145.1: icmp_seq=13 ttl=128 time=0.360 ms
64 bytes from 192.168.145.1: icmp_seq=14 ttl=128 time=0.321 ms
64 bytes from 192.168.145.1: icmp_seq=15 ttl=128 time=0.298 ms
64 bytes from 192.168.145.1: icmp_seq=16 ttl=128 time=0.364 ms
64 bytes from 192.168.145.1: icmp_seq=17 ttl=128 time=0.315 ms
^C
— 192.168.145.1 ping statistics —
17 packets transmitted, 8 received, 52% packet loss, time 7780ms
rtt min/avg/max/mdev = 0.298/0.553/1.078/0.304 ms

4.相关命令的总结

模块 编号 命令试用 命令解释
帮助命令

   1    man cd    使用帮助查看cd操作的相关参数

目录文件处理命令

2    ll    显示该路径目录下可以显示的文件
3    ls -l /home/abc    显示该路径目录下可以显示的文件
4    ls -a    显示该路径目录下所有的文件
5    ls -l     显示该路径目录下可以显示的文件
6    ls -la    显示该路径目录下所有的文件
7    pwd    显示该用户此时的路径位置
8    cd /    进入根目录
9    cd      进入该用户的主目录
10    cd ..    该用户回退一格目录
11    mkdir abc    创建文件夹abc
12    mkdir -p a/b/c    创建文件夹a/b/c
13    rm -rf abc    删除文件夹abc
14    touch abc    创建空文件夹abc

文本文件处理命令

15    cat t.txt    顺序查看t.txt文本的内容
16    tac t.txt    逆序查看t.txt文本的内容
17    cp t.txt /home/2.txt    复制t.txt文件到home路径下
18    mv t.txt /home/3.txt    移动t.txt文件到home路径下
19    touch a.txt    创建空文本a.txt
20    wc -l t.txt    查看文本有几行 
21    wc t.txt    查看文本有几行、几个单词、几个字符
22    ln -s t.txt /home/t    在home路径下创建文本t.txt的快捷键
23    more t.txt    分页显示文本t.txt
24    tail -f t.txt    分页显示文本t.txt

ping操作

25    ping -n 3 192.168.145.1    ping主机操作3次
26    ping -t 192.168.145.1    一直ping主机操作
27    ping -l 1024 192.168.145.1    限制包的大小
28    ping 192.168.145.1    ping主机操作

文件查找

29    find / -name profile    查找根目录下的profile文件
30    find /root -name 111.txt    查找root目录下的111.txt文件

系统信息显示

31    ps -ef    查看进程
32    ps -ef |grep sort    查看名称是sort的进程
33    state    主机属性
34    who    试用该系统有哪些用户
35    who an i    我当前用什么用户登录该系统
36    hostname    主用户名称
37    hostname 123    更改主用户名称
38    uname    系统名称
39    uname -a    更改系统名称
40    top    查询所有进程 
41    ps -aux    查询所有进程
42    ps -aux |more    查询所有进程,分页显示
43    ps -ef |top    查询top进程
44    kill -9  5859    杀死进程9859
45    clear    清屏

查看当前内存使用情况

46    du    查看当前目录下所有文件的使用情况
47    df    查看所有磁盘的使用情况

查看通信状况

  48    ntstat -ano |more    查看通信状况

备份压缩

49    tar -czvf 1.tar.gz 1.txt    压缩,以gz方式
50    tar -xzvf 1.tar.gz    解压缩
51    tar -cjvf 1.tar.biz2 1.txt    压缩,以biz2方式
52    tar -xjvf 1.tar.biz2    解压缩

文本内容编辑

 53    vi r.txt    编辑文件;i;ESC;w保存;q退出;q!强制

用户管理

54    chmod 777 m.txt    rwx421 更改文件的属性
55    addusr 123    增加用户123
56    su 123    切换到用户123
    原文作者:吴建波
    原文地址: https://segmentfault.com/a/1190000008243802
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞