zoukankan      html  css  js  c++  java
  • Linux常用命令集合

    一、文件管理命令

    1. ls

    ls 显示非隐藏文件

    1 [geek@localhost ~]$ ls
    2 cprograms  Lshare   signal_lshare  模板  图片  下载  桌面
    3 lin        scripts  公共           视频  文档  音乐

    ls -a 显示所有文件(包括隐藏文件)

    1 [geek@localhost ~]$ ls -a
    2 .              .bashrc    .ICEauthority  scripts        图片
    3 ..             .cache     lin            signal_lshare  文档
    4 .bash_history  .config    .local         公共           下载
    5 .bash_logout   cprograms  Lshare         模板           音乐
    6 .bash_profile  .esd_auth  .mozilla       视频           桌面

    ls -l (或者直接用ll)显示详细信息(包括权限信息,所有者信息,大小,创建时间等)

     1 [geek@localhost ~]$ ls -l
     2 总用量 4
     3 drwxr-xr-x. 2 root root  102 7月   7 21:47 cprograms
     4 drwxr-xr-x. 2 root root    6 7月   6 21:16 lin
     5 drwxrwxr-x. 2 geek geek    6 7月   6 16:29 Lshare
     6 drwxr-xr-x. 2 root root 4096 7月   8 15:22 scripts
     7 lrwxrwxrwx. 1 geek geek    6 7月   6 16:30 signal_lshare -> Lshare
     8 drwxr-xr-x. 2 geek geek    6 10月 17 2014 公共
     9 drwxr-xr-x. 2 geek geek    6 10月 17 2014 模板
    10 drwxr-xr-x. 2 geek geek    6 10月 17 2014 视频
    11 drwxr-xr-x. 2 geek geek    6 10月 17 2014 图片
    12 drwxr-xr-x. 2 geek geek    6 10月 17 2014 文档
    13 drwxr-xr-x. 2 geek geek    6 10月 17 2014 下载
    14 drwxr-xr-x. 2 geek geek   18 7月   6 16:23 音乐
    15 drwxr-xr-x. 2 geek geek    6 10月 17 2014 桌面

    2. pwd

    pwd 打印当前目录

    1 [geek@localhost ~]$ pwd
    2 /home/geek

    3. cd

    cd .. 切换到上一级目录

    1 [geek@localhost ~]$ cd ..
    2 [geek@localhost home]$ pwd
    3 /home
    4 [geek@localhost home]$ 

    cd / 切换到根目录

    1 [geek@localhost home]$ cd /
    2 [geek@localhost /]$ pwd
    3 /
    4 [geek@localhost /]$ 

    4. mkdir

    mkdir geek 在当前目录创建名为geek的子目录

    1 [geek@localhost ~]$ mkdir geek
    2 [geek@localhost ~]$ ls
    3 cprograms  lin     scripts        公共  视频  文档  音乐
    4 geek       Lshare  signal_lshare  模板  图片  下载  桌面

    5. rmdir

    rmdir geek 删除空目录geek

    1 [geek@localhost ~]$ rmdir geek
    2 [geek@localhost ~]$ ls
    3 cprograms  Lshare   signal_lshare  模板  图片  下载  桌面
    4 lin        scripts  公共           视频  文档  音乐

    6. touch

    touch 1.txt 在当前目录创建空文件1.txt

    1 [geek@localhost ~]$ touch 1.txt
    2 [geek@localhost ~]$ ls
    3 1.txt      lin     scripts        公共  视频  文档  音乐
    4 cprograms  Lshare  signal_lshare  模板  图片  下载  桌面

    7. rm

    rm 1.txt 删除当前目录的1.txt

    1 [geek@localhost ~]$ rm 1.txt
    2 [geek@localhost ~]$ ls
    3 cprograms  Lshare   signal_lshare  模板  图片  下载  桌面
    4 lin        scripts  公共           视频  文档  音乐

    rm -rf lin 删除非空目录lin

    1 [geek@localhost ~]$ ls lin
    2 test
    3 [geek@localhost ~]$ rmdir lin
    4 rmdir: 删除 "lin" 失败: 目录非空
    5 [geek@localhost ~]$ rm -rf lin
    6 [geek@localhost ~]$ ls
    7 cprograms  scripts  公共  模板  视频  图片  文档  下载  音乐  桌面
    8 [geek@localhost ~]$ 

    8. cat

    cat 1.txt 直接显示1.txt的所有内容,跳转到末尾

    1 [geek@localhost ~]$ cat 1.txt
    2 .
    3 .
    4 .
    5 ,但是维基百科内仍然包含有大量未经证实或者是相互矛盾的信息[32]。不过《自然》在2005年的调查之中认为维基百科在科学文章这一领域与作为传统百科全书代表的《大英百科全书》有着相似的精确度,但是两者在内容上都有一定程度上的“严重缺失”[33][34]。
    6 [geek@localhost ~]$

    9. more

    more 1.txt 分页显示1.txt的内容,按空格键可以向下查看

    1 [geek@localhost ~]$ more 1.txt
    2 维基百科最早是在吉米·威尔士与拉里·桑格两人的合作下,在2001年1月13日于互联网上推
    3 出网站服务,并在1月15日正式展开网络百科全书的项目[4]。其中桑格同时结合了维基百科
    4 网站合作核心的“Wiki”以及具有百科全书之意的“encyclopedia”,而创造出新的混成词“Wik
    5 ipedia”。
    6 --More--(49%)

    10. less

    less 1.txt 进入全文阅读模式,可上下滚轮和按空格向下查看,按q退出

    1 [geek@localhost ~]$ less 1.txt

    11. grep

    grep -i “wiki” 1.txt 从1.txt中不区分大小写地找出包含”wiki” 的行

    1 [geek@localhost ~]$ grep -i "wiki" 1.txt
    2 维基百科最早是在吉米·威尔士与拉里·桑格两人的合作下,在2001年1月13日于互联网上推出网站服务,并在1月15日正式展开网络百科全书的项目[4]。其中桑格同时结合了维基百科网站合作核心的“Wiki”以及具有百科全书之意的“encyclopedia”,而创造出新的混成词“Wikipedia”。
    3 。。。

    12. mv

    mv 1.txt 2.txt 将1.txt更名为2.txt

    1 [geek@localhost ~]$ mv 1.txt 2.txt
    2 [geek@localhost ~]$ ls
    3 2.txt  cprograms  scripts  公共  模板  视频  图片  文档  下载  音乐  桌面

    mv 2.txt /home 移动当前目录中的2.txt到/home目录中

    1 [root@localhost geek]# ls
    2 2.txt  cprograms  scripts  公共  模板  视频  图片  文档  下载  音乐  桌面
    3 [root@localhost geek]# mv 2.txt /home
    4 [root@localhost geek]# cd ..
    5 [root@localhost home]# ls
    6 2.txt  geek

    13. cp

    cp 2.txt /home/geek/1.txt 将当前目录的2.txt复制到/home/geek并更名为1.txt

    1 [root@localhost home]# cp 2.txt /home/geek/1.txt
    2 [root@localhost home]# cd geek
    3 [root@localhost geek]# ls
    4 1.txt  cprograms  scripts  公共  模板  视频  图片  文档  下载  音乐  桌面

    cp /home/2.txt /home/geek 将/home中的2.txt复制到/home/geek目录中

    1 [root@localhost geek]# cp /home/2.txt /home/geek
    2 [root@localhost geek]# ls
    3 1.txt  2.txt  cprograms  scripts  公共  模板  视频  图片  文档  下载  音乐  桌面

    14. find

    find *.txt 在当前目录查找所有以“.txt”结尾的文件

    1 [root@localhost geek]# find *.txt
    2 1.txt
    3 2.txt

    find -name *.txt 递归查找当前目录及其子目录中的所有以“.txt”结尾的文件

    1 [root@localhost geek]# cd ..
    2 [root@localhost home]# find -name *.txt
    3 ./geek/.local/share/Trash/files/2.txt
    4 ./geek/2.txt
    5 ./2.txt

    15. file

    file 2.txt 显示2.txt的文件类型

    1 [root@localhost home]# file 2.txt
    2 2.txt: UTF-8 Unicode text, with very long lines

    二、磁盘管理命令

    1.df

    df

    1 [geek@localhost home]$ df  列出文件系统的整体磁盘使用量
    2 文件系统                  1K-块    已用    可用 已用% 挂载点
    3 /dev/mapper/centos-root 8910848 4801752 4109096   54% /
    4 devtmpfs                 496140       0  496140    0% /dev
    5 tmpfs                    505428     148  505280    1% /dev/shm
    6 tmpfs                    505428   13532  491896    3% /run
    7 tmpfs                    505428       0  505428    0% /sys/fs/cgroup
    8 /dev/sda1                508588  121304  387284   24% /boot

    df -h 以易读(KB、MB、GB)形式显示文件系统的整体磁盘使用量

    1 [geek@localhost home]$ df -h
    2 文件系统                 容量  已用  可用 已用% 挂载点
    3 /dev/mapper/centos-root  8.5G  4.6G  4.0G   54% /
    4 devtmpfs                 485M     0  485M    0% /dev
    5 tmpfs                    494M  148K  494M    1% /dev/shm
    6 tmpfs                    494M   14M  481M    3% /run
    7 tmpfs                    494M     0  494M    0% /sys/fs/cgroup
    8 /dev/sda1                497M  119M  379M   24% /boot

    df -T 将文件系统类型也显示出来

    1 [geek@localhost home]$ df -T
    2 文件系统                类型       1K-块    已用    可用 已用% 挂载点
    3 /dev/mapper/centos-root xfs      8910848 4801808 4109040   54% /
    4 devtmpfs                devtmpfs  496140       0  496140    0% /dev
    5 tmpfs                   tmpfs     505428     148  505280    1% /dev/shm
    6 tmpfs                   tmpfs     505428   13532  491896    3% /run
    7 tmpfs                   tmpfs     505428       0  505428    0% /sys/fs/cgroup
    8 /dev/sda1               xfs       508588  121304  387284   24% /boot

    df /etc 显示目录/etc所在的分区的使用情况

    1 [geek@localhost home]$ df /etc
    2 文件系统                  1K-块    已用    可用 已用% 挂载点
    3 /dev/mapper/centos-root 8910848 4801776 4109072   54% /
    4 [geek@localhost home]$ df /home/geek/2.txt
    5 文件系统                  1K-块    已用    可用 已用% 挂载点
    6 /dev/mapper/centos-root 8910848 4801776 4109072   54% /

    2.du

    du -h 以易读的方式评估当前目录及其递归子目录的文件量

    1 [geek@localhost ~]$ du -h
    2 4.0K    ./.mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}
    3 4.0K    ./.mozilla/extensions
    4 0   ./.mozilla/plugins

    du -s 列出当前目录的总文件量(默认单位为KB)

    1 [root@localhost home]# du -s
    2 38040   .

    du -sm 检查当前目录下各个目录的文件量,单位为MB

    1 [root@localhost home]# du -sm ./*
    2 1   ./2.txt
    3 38  ./geek

    3.fdisk

    fdisk -l 列出磁盘分区表

     1 [root@localhost home]# fdisk -l
     2 
     3 磁盘 /dev/sda:10.7 GB, 10737418240 字节,20971520 个扇区
     4 Units = 扇区 of 1 * 512 = 512 bytes
     5 扇区大小(逻辑/物理):512 字节 / 512 字节
     6 I/O 大小(最小/最佳):512 字节 / 512 字节
     7 磁盘标签类型:dos
     8 磁盘标识符:0x000bf8fb
     9 
    10    设备 Boot      Start         End      Blocks   Id  System
    11 /dev/sda1   *        2048     1026047      512000   83  Linux
    12 /dev/sda2         1026048    20971519     9972736   8e  Linux LVM
    13 
    14 磁盘 /dev/mapper/centos-swap:1073 MB, 1073741824 字节,2097152 个扇区
    15 Units = 扇区 of 1 * 512 = 512 bytes
    16 扇区大小(逻辑/物理):512 字节 / 512 字节
    17 I/O 大小(最小/最佳):512 字节 / 512 字节
    18 
    19 
    20 磁盘 /dev/mapper/centos-root:9135 MB, 9135194112 字节,17842176 个扇区
    21 Units = 扇区 of 1 * 512 = 512 bytes
    22 扇区大小(逻辑/物理):512 字节 / 512 字节
    23 I/O 大小(最小/最佳):512 字节 / 512 字节

    三、文件权限命令

    1.chmod

    Linux文件的基本权限有9个,分别是owner、group、others三种身份各有自己的read、write、execute权限。文件的权限字符为“-rwxrwxrwx”,这9个权限是三个三个一组的。其中,我们可以使用数字来代表各个权限,各权限的分数分别为:r—-4,w—-2,x—-1。每种身份(owner、group、others)各自的三个权限(r、w、x)分数是需要累加的。1 
    chmod -o=rw 2.txt 给2.txt的其他用户加上写的权限

    1 [root@localhost home]# ll
    2 总用量 12
    3 -rw-rw-r--.  1 geek geek 5080 7月   9 12:30 2.txt
    4 drwx------. 15 geek geek 4096 7月   9 13:59 geek
    5 [root@localhost home]# chmod o=rw 2.txt
    6 [root@localhost home]# ll
    7 总用量 12
    8 -rw-rw-rw-.  1 geek geek 5080 7月   9 12:30 2.txt
    9 drwx------. 15 geek geek 4096 7月   9 13:59 geek

    chmod 777 2.txt 给2.txt的所有用户加上所有权限

    1 [root@localhost home]# ll
    2 总用量 12
    3 -rw-rw-rw-.  1 geek geek 5080 7月   9 12:30 2.txt
    4 drwx------. 15 geek geek 4096 7月   9 13:59 geek
    5 [root@localhost home]# chmod 777 2.txt
    6 [root@localhost home]# ll
    7 总用量 12
    8 -rwxrwxrwx.  1 geek geek 5080 7月   9 12:30 2.txt
    9 drwx------. 15 geek geek 4096 7月   9 13:59 geek

    2.chown

    chown -R root scripts 更改scripts目录连同其下的的所有目录文件的所有者为root

     1 [root@localhost geek]# chown -R root scripts
     2 [root@localhost geek]# ll
     3 总用量 20
     4 -rw-r--r--. 1 root root 5080 7月   9 13:08 1.txt
     5 -rw-r--r--. 1 root root 5080 7月   9 13:11 2.txt
     6 drwxr-xr-x. 2 root root  102 7月   7 21:47 cprograms
     7 drwxr-xr-x. 2 root geek 4096 7月   8 15:22 scripts
     8 drwxr-xr-x. 2 geek geek    6 10月 17 2014 公共
     9 drwxr-xr-x. 2 geek geek    6 10月 17 2014 模板
    10 drwxr-xr-x. 2 geek geek    6 10月 17 2014 视频
    11 drwxr-xr-x. 2 geek geek    6 10月 17 2014 图片
    12 drwxr-xr-x. 2 geek geek    6 10月 17 2014 文档
    13 drwxr-xr-x. 2 geek geek    6 10月 17 2014 下载
    14 drwxr-xr-x. 2 geek geek   18 7月   6 16:23 音乐
    15 drwxr-xr-x. 2 geek geek    6 10月 17 2014 桌面

    chown root:root 2.txt 改变2.txt的所有者为root和所属组为root

    1 [root@localhost home]# ll
    2 总用量 12
    3 -rwxrwxrwx.  1 geek geek 5080 7月   9 12:30 2.txt
    4 drwx------. 15 geek geek 4096 7月   9 13:59 geek
    5 [root@localhost home]# chown root:root 2.txt
    6 [root@localhost home]# ll
    7 总用量 12
    8 -rwxrwxrwx.  1 root root 5080 7月   9 12:30 2.txt
    9 drwx------. 15 geek geek 4096 7月   9 13:59 geek

    3.chgrp

    chgrp geek 2.txt 改变2.txt的所属组为geek

    1 [root@localhost home]# ll
    2 总用量 12
    3 -rwxrwxrwx.  1 root root 5080 7月   9 12:30 2.txt
    4 drwx------. 15 geek geek 4096 7月   9 13:59 geek
    5 [root@localhost home]# chgrp geek 2.txt
    6 [root@localhost home]# ll
    7 总用量 12
    8 -rwxrwxrwx.  1 root geek 5080 7月   9 12:30 2.txt
    9 drwx------. 15 geek geek 4096 7月   9 13:59 geek

    四、用户管理命令

    1.su、sudo

    sudo passwd root 从当前用户更新root的密码

    1 [geek@localhost home]$ sudo passwd root
    2 [sudo] password for geek: 
    3 更改用户 root 的密码 。
    4 新的 密码:
    5 无效的密码: 密码少于 8 个字符
    6 重新输入新的 密码:
    7 passwd:所有的身份验证令牌已经成功更新。

    su root 从当前用户切换root用户

    1 [geek@localhost home]$ su root
    2 密码:
    3 [root@localhost home]# 

    2.who/w

    who 获取目前已登录系统的用户信息

    1 [root@localhost home]# who
    2 geek     pts/0        2015-07-09 11:07 (:1)
    3 geek     :1           2015-07-06 21:38 (:1)
    4 [root@localhost home]# w
    5  16:37:49 up 1 day, 9 min,  2 users,  load average: 0.11, 0.26, 0.18
    6 USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
    7 geek     pts/0     11:07    5.00s  1.01s 27.56s /usr/libexec/gnome-terminal-serve
    8 geek     :1        一21   ?xdm?  57:05   0.62s gdm-session-worker [pam/gdm-autol

    3.useradd

    useradd Lshare 以默认方式新增用户Lshare

    1 [root@localhost home]# useradd Lshare
    2 [root@localhost home]# id Lshare
    3 uid=1001(Lshare) gid=1002(Lshare) 组=1002(Lshare)

    在CentOS中,系统默认处理以下几个项目:

    • 在/etc/passwd里面创建一行与账号相关的数据,包括UID/GID/主文件夹等;
    • 在/etc/shadow里面将此账号的密码相关参数填入,但是尚未有密码;
    • 在/etc/group里面加入一个与账号名称一模一样的组名;
    • 在/home下面创建一个与账号同名的目录作为用户文件夹,且权限为7002

    4.groupadd

    groupadd geeks 添加用户组geeks

    1 [root@localhost home]# groupadd geeks
    2 [root@localhost home]# grep geeks /etc/group
    3 geeks:x:1003:

    5.passwd

    passwd geek 更改geek的登录密码

    1 [root@localhost home]# passwd geek
    2 更改用户 geek 的密码 。
    3 新的 密码:
    4 无效的密码: 密码少于 8 个字符
    5 重新输入新的 密码:
    6 passwd:所有的身份验证令牌已经成功更新。

    6.usermod

    usermod -l Lee Lshare 修改用户名Lshare为Lee

    1 [root@localhost home]# usermod -l Lee Lshare
    2 [root@localhost home]# grep Lee /etc/shadow
    3 Lee:!!:16625:0:99999:7:::

    usermod -e “2015-07-31” Lee 用户Lee的密码将在15年7月31号失效

    1 [root@localhost home]# grep Lee /etc/shadow
    2 Lee:!!:16625:0:99999:7:::
    3 [root@localhost home]# usermod -e "2015-07-31" Lee
    4 [root@localhost home]# grep Lee /etc/shadow
    5 Lee:!!:16625:0:99999:7::16647:

    7.id

    id geek 获取geek用户的ID

    1 [root@localhost home]# id geek
    2 uid=1000(geek) gid=1000(geek) 组=1000(geek),10(wheel)

    8.userdel

    userdel Lshare 删除用户Lshare

    1 [root@localhost home]# userdel Lshare
    2 [root@localhost home]# grep Lshare /etc/shadow
    3 [root@localhost home]# 

    9.groupmod

    groupmod -n guests geeks 更改组名geeks为guest

    1 [root@localhost home]# groupmod -n guests geeks
    2 [root@localhost home]# grep guests /etc/gshadow
    3 guests:!::

    10.gpasswd

    gpasswd -a Lee guests 将用户Lee添加到用户组guests中

    1 [root@localhost home]# gpasswd -a Lee guests
    2 正在将用户“Lee”加入到“guests”组中
    3 [root@localhost home]# id Lee
    4 uid=1001(Lee) gid=1004(Lshare) 组=1004(Lshare),1003(guests)

    11.groupdel

    groupdel guests 删除用户组guests

    1 [root@localhost home]# groupdel guests
    2 [root@localhost home]# id Lee
    3 uid=1001(Lee) gid=1004(Lshare) 组=1004(Lshare)

    五、软件管理命令

    1.rpm

    软件管理器 简介3

    distribution代表软件管理机制使用命令在线升级机制(命令)
    Red Hat/Fedora RPM rpm,rpmbuild YUM(yum)
    Debian/Ubuntu DPKG dpkg APT(apt-get)

    RPM与SRPM区别4

    文件格式文件名格式直接安装与否内含程序类型可否修改参数并编译
    RPM xxx.rpm 已编译 不可
    SRPM xxx.src.rpm 不可 未编译的源代码

    RPM包下载:http://rpm.pbone.net/


    rpm -ivh htop-1.0.2-6.1.x86_64.rpm

    1 [root@localhost geek]# ls
    2 1.txt  cprograms                  scripts  模板  图片  下载  桌面
    3 2.txt  htop-1.0.2-6.1.x86_64.rpm  公共     视频  文档  音乐
    4 [root@localhost geek]# rpm -ivh htop-1.0.2-6.1.x86_64.rpm 
    5 警告:htop-1.0.2-6.1.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID c86c6f35: NOKEY
    6 准备中...                          ################################# [100%]
    7 正在升级/安装...
    8    1:htop-1.0.2-6.1                   ################################# [100%]
    9 root@localhost geek]# htop

    htop的界面

    rpm -Uvh htop-1.0.2-6.1.x86_64.rpm 升级软件包(若无已安装的旧版软件也要安装) 
    rpm -Fvh htop-1.0.2-6.1.x86_64.rpm 更新软件包(若无已安装的旧版软件则不安装)

    1 [root@localhost geek]# rpm -Uvh htop-1.0.2-6.1.x86_64.rpm 
    2 警告:htop-1.0.2-6.1.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID c86c6f35: NOKEY
    3 准备中...                          ################################# [100%]
    4     软件包 htop-1.0.2-6.1.x86_64 已经安装

    rpm -qa 查询系统中所有已安装的软件包

    1 [root@localhost geek]# rpm -qa
    2 libvirt-daemon-driver-qemu-1.1.1-29.el7.x86_64
    3 newt-0.52.15-4.el7.x86_64
    4 nautilus-3.8.2-7.el7.x86_64
    5 python-krbV-1.0.90-8.el7.x86_64
    6 ...

    rpm -qi htop-1.0.2-6.1.x86_64 查询该软件的信息,包括开发商、版本和说明等。

    1 [root@localhost geek]# rpm -qi htop-1.0.2-6.1.x86_64
    2 Name        : htop
    3 Version     : 1.0.2
    4 Release     : 6.1
    5 ...

    rpm -ql htop-1.0.2-6.1.x86_64 列出该软件提供的所有目录和文件

    1 [root@localhost geek]# rpm -ql htop-1.0.2-6.1.x86_64
    2 /usr/bin/htop
    3 /usr/share/applications/htop.desktop
    4 /usr/share/doc/htop-1.0.2
    5 ...

    rpm -qR htop-1.0.2-6.1.x86_64 列出该软件所依赖软件所含的文件

    1 [root@localhost geek]# rpm -qR htop-1.0.2-6.1.x86_64
    2 libc.so.6()(64bit)
    3 libc.so.6(GLIBC_2.2.5)(64bit)
    4 libc.so.6(GLIBC_2.3)(64bit)
    5 ...

    rpm -qf usr/share/man/man1/htop.1.gz 查询文件htop.1.gz所属的已安装的软件

    1 [root@localhost geek]# rpm -qf usr/share/man/man1/htop.1.gz
    2 htop-1.0.2-6.1.x86_64

    rpm -e htop-1.0.2-6.1.x86_64 卸载(erase)软件包htop-1.0.2-6.1.x86_64

    1 [root@localhost geek]# rpm -qa |grep htop
    2 htop-1.0.2-6.1.x86_64
    3 [root@localhost geek]# rpm -e htop-1.0.2-6.1.x86_64
    4 [root@localhost geek]# rpm -q htop-1.0.2-6.1.x86_64
    5 未安装软件包 htop-1.0.2-6.1.x86_64 

    2.tar、./configure、make、make install

    Tarball软件

    • 源代码文件
    • 检测程序文件(configure或config)
    • 安装说明(INSTALL或README)
    类别压缩方式后缀名
    1 gzip .tar.gz
    2 bzip2 .tar.bz2

    Tarball软件的安装

    1. 取得源文件,并解压到、usr/local/src中;
    2. 查看安装说明并安装依赖软件;
    3. 建立makefile,检测安装环境并makeclean清除产生的目标文件;
    4. 编译make;
    5. 安装make install;
    6. 为安装到单独目录的软件的man page加入man path。 
     安装Linux流量监控工具 - iftop(http://www.ex-parrot.com/~pdw/iftop/
    
    安装依赖包
    ----------
    1 [root@localhost geek]# yum install flex byacc  libpcap ncurses ncurses-devel libpcap-devel
    2 已加载插件:fastestmirror, langpacks
    3 base                                                            | 3.6 kB  00:00:00     
    4 extras                                                          | 3.4 kB  00:00:00     
    5 updates                                                         | 3.4 kB  00:00:00 
    6 ...
    
    
    安装iftop
    ----------
    
    
     1 [root@localhost geek]# ls
     2 1.txt  cprograms                  iftop-0.17.tar.gz  公共  视频  文档  音乐
     3 2.txt  htop-1.0.2-6.1.x86_64.rpm  scripts            模板  图片  下载  桌面
     4 [root@localhost geek]# cd /usr/local/src
     5 [root@localhost src]# tar -xvf /home/geek/iftop-0.17.tar.gz 
     6 iftop-0.17/
     7 iftop-0.17/aclocal.m4
     8 iftop-0.17/addr_hash.c
     9 ...
    10 [root@localhost src]# cd iftop-0.17/
    11 [root@localhost iftop-0.17]# vi INSTALL 
    12 [root@localhost iftop-0.17]# ./configure --prefix=/usr/local/iftop
    13 checking build system type... x86_64-unknown-linux-gnu
    14 checking host system type... x86_64-unknown-linux-gnu
    15 checking target system type... x86_64-unknown-linux-gnu
    16 ...
    17 [root@localhost iftop-0.17]# make clean;make
    18 [root@localhost iftop-0.17]# make check
    19 [root@localhost iftop-0.17]# make install
    
    
    修改环境变量,在/etc/profile末尾添加
    export PATH="/usr/local/iftop/sbin:$PATH"
    ----------
    1 [root@localhost sbin]# vi /etc/profile
    2 [root@localhost sbin]# source /etc/profile
    3 [root@localhost sbin]# iftop 

    iftop

    六、启动管理命令

    1.reboot、init 6

    
    重启系统
    ----------
    1 [root@localhost geek]# reboot
    2 3 [root@localhost geek]# init 6
     

    2.halt、init 0、shutdown –h now

    
    关闭系统
    ----------
    1 [root@localhost geek]# halt
    2 3 [root@localhost geek]# init 0
    4 5 [root@localhost geek]# shutdown –h now
     

    3.runlevel

    运行级别

    运行级别说明
    0 关机
    1 单用户模式
    2 多用户模式,但不提供网络文件系统(NFS)
    3 完整的多用户模式,仅提供字符界面
    4 保留的运行级别
    5 完整的多用户模式,自动启动图形化界面、
    6 重新启动
    第一个数字为上一次的运行级别,第二个为当前的运行级别
    ----------
    1 [root@localhost geek]# runlevel
    2 3 5

    4.init 5

    进入桌面模式
    ----------
    1 [root@localhost geek]# init 5

    5.chkconfig

    七、进程管理命令

    1.top

    1 [root@localhost geek]# top

    top

    2.ps

    1 [root@localhost geek]# ps -aux

    ps

    3.pstree

    1 [root@localhost geek]# pstree

    pstree


    1. 引自《鸟哥的Linux私房菜 基础学习篇(第三版)》Page 146,略有改动。 
    2. 引自《鸟哥的Linux私房菜 基础学习篇(第三版)》Page 410,略有改动。 
    3. 引自《鸟哥的Linux私房菜 基础学习篇(第三版)》Page 686、687。 
    4. 引自《鸟哥的Linux私房菜 基础学习篇(第三版)》Page 686、687。 
    写在后面:

    1. 子曰:「学而不思则罔,思而不学则殆」。
    2. 站点地图
    2. 本作品作者为 Lshare,采用知识共享署名 4.0 国际许可协议进行许可。
  • 相关阅读:
    第九章、硬件抽象层:HAL
    第八章、让开发板发出声音:蜂鸣器驱动
    第七章、LED将为我闪烁:控制发光二极管
    第六章、第一个Linux驱动程序:统计单词个数
    第五章、搭建S3C6410开发板的测试环境
    Android深度探索(卷1)HAL与驱动开发
    第三次月考
    第二次月考
    Android深度探索(卷1)HAL与驱动开发
    第六章 集合运算
  • 原文地址:https://www.cnblogs.com/lshare/p/4641560.html
Copyright © 2011-2022 走看看