理解 Linux 下 Shell 命令的不同分类及它们的用法(转)

当你打算真正操纵好你的 Linux 系统,没有什么能比命令行界面更让你做到这一点。 Canada Goose Expedition Parka 为了成为一个 Linux 高手,你必须能够理解 Shell 命令的不同类型[1],并且会在终端下正确的使用它们。 Joc Pederson Jersey 在 Linux 下,命令有几种类型,对于一个 Linux 新手来说,知道不同命令的意思才能够高效和准确的使用它们。因此,在这篇文章里,我们将会遍及各种不同分类的 Linux Shell 命令。 louboutin sneakers 需要注意一件非常重要的事:命令行界面和 Shell 是不同的,命令行界面只是为你提供一个访问 Shell 的方式。 Nike Air Max 90 Femme Noir Et Blanc Nike Air Max 2016 Dames wit Fjallraven Kanken Sverige

  • AIR HUARACHE
  • 而 Shell ,它是可编程的,这使得它可以通过命令与内核进行交流。 Jason Pierre-Paul Los Angeles Lakers 下面列出了 Linux 下命令的不同种类: 1. goedkoop nike air max 2016 程序可执行文件(文件系统 中的命令) 当你执行一条命令的时候,Linux 通过从左到右搜索存储在 $PATH 环境变量中的目录来找到这条命令的可执行文件。 你可以像下面这样查看存储在 $PATH 中的目录:

    • $ echo $PATH
    • /home/aaronkilik/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

    在上面的命令中,目录 /home/aaronkilik/bin 将会被首先搜索,紧跟着是 /usr/local/sbin,然后一直接着下去。 Women Air Jordan 6 在搜索过程中,搜索顺序是至关重要的。 Adidas Superstar Femme Portee A.J. Green Jerseys 比如在 /usr/bin 目录里的文件系统中的命令:

    • $ ll /bin/

    示例输出:

    • total 16284
    • drwxr-xr-x 2 root root 4096 Jul 31 16:30 ./
    • drwxr-xr-x 23 root root 4096 Jul 31 16:29 ../
    • -rwxr-xr-x 1 root root 6456 Apr 14 18:53 archdetect*
    • -rwxr-xr-x 1 root root 1037440 May 17 16:15 bash*
    • -rwxr-xr-x 1 root root 520992 Jan 20 2016 btrfs*
    • -rwxr-xr-x 1 root root 249464 Jan 20 2016 btrfs-calc-size*
    • lrwxrwxrwx 1 root root 5 Jul 31 16:19 btrfsck -> btrfs*
    • -rwxr-xr-x 1 root root 278376 Jan 20 2016 btrfs-convert*
    • -rwxr-xr-x 1 root root 249464 Jan 20 2016 btrfs-debug-tree*
    • -rwxr-xr-x 1 root root 245368 Jan 20 2016 btrfs-find-root*
    • -rwxr-xr-x 1 root root 270136 Jan 20 2016 btrfs-image*
    • -rwxr-xr-x 1 root root 249464 Jan 20 2016 btrfs-map-logical*
    • -rwxr-xr-x 1 root root 245368 Jan 20 2016 btrfs-select-super*
    • -rwxr-xr-x 1 root root 253816 Jan 20 2016 btrfs-show-super*
    • -rwxr-xr-x 1 root root 249464 Jan 20 2016 btrfstune*
    • -rwxr-xr-x 1 root root 245368 Jan 20 2016 btrfs-zero-log*
    • -rwxr-xr-x 1 root root 31288 May 20 2015 bunzip2*
    • -rwxr-xr-x 1 root root 1964536 Aug 19 2015 busybox*
    • -rwxr-xr-x 1 root root 31288 May 20 2015 bzcat*
    • lrwxrwxrwx 1 root root 6 Jul 31 16:19 bzcmp -> bzdiff*
    • -rwxr-xr-x 1 root root 2140 May 20 2015 bzdiff*
    • lrwxrwxrwx 1 root root 6 Jul 31 16:19 bzegrep -> bzgrep*
    • -rwxr-xr-x 1 root root 4877 May 20 2015 bzexe*
    • lrwxrwxrwx 1 root root 6 Jul 31 16:19 bzfgrep -> bzgrep*
    • -rwxr-xr-x 1 root root 3642 May 20 2015 bzgrep*

    2. fjallraven kanken goedkoop Linux 别名 这些是用户定义的命令,它们是通过 shell 内置命令 alias 创建的,其中包含其它一些带有选项和参数的 shell 命令。 Asics Gel Lyte 5 Homme 这个意图主要是使用新颖、简短的名字来替代冗长的命令。 nike air jordan 11 homme asics tiger femme 创建一个别名的语法像下面这样:

    • $ alias newcommand='command -options'

    通过下面的命令,可以列举系统中的所有别名:

    • $ alias -p
    • alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
    • alias egrep='egrep --color=auto'
    • alias fgrep='fgrep --color=auto'
    • alias grep='grep --color=auto'
    • alias l='ls -CF'
    • alias la='ls -A'
    • alias ll='ls -alF'
    • alias ls='ls --color=auto'

    要在 Linux 中创建一个新的别名,仔细阅读下面的例子。 Nike Air Max

    • $ alias update='sudo apt update'
    • $ alias upgrade='sudo apt dist-upgrade'
    • $ alias -p | grep 'up'

    然而,上面这些我们创建的别名只能暂时的工作,当经过下一次系统启动后它们不再工作。 Air Jordan 30 Homme 2015 new balance 530 nike air max 但你可以在 ‘.bashrc’ 文件中设置永久别名。 New Balance 990 homme Maglie Milwaukee Bucks 添加以后,运行下面的命令来激活:

    • $ source ~/.bashrc

    3. nike buty sklep Linux Shell 保留字 在 shell 程序设计中,ifthenfiforwhilecaseesacelseuntil 以及其他更多的字都是 shell 保留字。正如描述所暗示的,它们在 shell 中有特殊的含义。 Asics Gel Lyte Pas Cher 你可以通过使用下面展示的 type 命令来列出所有的 shell 关键字:

    • $ type if then fi for while case esac else until
    • if is a shell keyword
    • then is a shell keyword
    • fi is a shell keyword
    • for is a shell keyword
    • while is a shell keyword
    • case is a shell keyword
    • esac is a shell keyword
    • else is a shell keyword
    • until is a shell keyword

    4. nike air max 2016 grijs Linux shell 函数 一个 shell 函数是一组在当前 shell 内一起执行的命令。 Asics Homme Air Jordan 6 函数有利于在 shell 脚本中实现特殊任务。 New Balance 373 femme Nike Air Max bw Homme nike tn rose femme Bart Starr Packers Jerseys 在 shell 脚本中写 shell 函数的传统形式是下面这样:

    • function_name() {
    • command1
    • command2
    • ......
    • }

    或者像这样:

    • function function_name {
    • command1
    • command2
    • ......
    • }

    让我们看一看如何在一个名为 shell_functions.sh 的脚本中写 shell 函数。 Nike Homme Air Jordan 11 (XI)

    • #!/bin/bash
    • #write a shell function to update and upgrade installed packages
    • upgrade_system(){
    • sudo apt update;
    • sudo apt dist-upgrade;
    • }
    • #execute function
    • upgrade_system

    取代通过命令行执行两条命令:sudo apt updatesudo apt dist-upgrade,我们在脚本内写了一个像执行一条单一命令一样来执行两条命令的 shell 函数 upgrade_system。 nike air max pas cher 保存文件,然后使脚本可执行。 Washington Wizards 最后像下面这样运行 shell 函数:

    • $ chmod +x shell_functions.sh
    • $ ./shell_functions.sh

    5. Nike Blazer High femme ADIDAS ZX 700 Linux Shell 内置命令 这些是在 shell 中内置的 Linux 命令,所以你无法在文件系统中找到它们。 Asics Gel Lyte 3 Femme Bleu ff14 gil for sale 这些命令包括pwdcdbgaliashistorytypesourcereadexit 等。 asics kayano 24 femme 你可以通过下面展示的 type 命令来列出或检查 Linux 内置命令:

    • $ type pwd
    • pwd is a shell builtin
    • $ type cd
    • cd is a shell builtin
    • $ type bg
    • bg is a shell builtin
    • $ type alias
    • alias is a shell builtin
    • $ type history
    • history is a shell builtin

    结论 作为一个 Linux 用户,知道你所运行的命令类型是很重要的。 adidas yeezy boost 350 v2 homme 我相信,通过上面明确、简单并且易于理解的解释,包括一些相关的说明,你可能对 “Linux 命令的不同种类[5]”有了很好的理解。 New Balance 998 femme Air Jordan 4 Cement 你也可以在下面的评论区提任何问题或补充意见,从而和我们取得联系。

    Posted in Linux | Leave a comment

    简单做一个自己的rpm软件包

    1、创建一个脚本文件 [root@localhost redhat]# cat SOURCES/wang.sh # !/bin/bash # HH=”this is my first rpm ruanjian, from wang” echo “ok!! zhu yi bian liang shi $HH” #chmod 755 wang.sh #tar -zcvf wang.tar.gz wang.sh 2、创建spec文件 [root@localhost SPECS]# vim wang.spec [root@localhost SPECS]# cat wang.spec Name: wang-sj Summary: zuo zhe wan ne Version: 1.0 Release: 1 Group: System Environment/Shells License: GPL Packager: wsj <wangshj@bizsmooth.com> Source: wang.tar.gz URL: http://www.bizsmooth.com %description wang shu juan jie shao %prep %setup -c %install install -m 755 wang.sh /usr/local/bin/wang.sh %files /usr/local/bin/wang.sh 3、编译软件包 [root@localhost SPECS]# rpmbuild -bb wang.spec Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.67230 + umask 022 + cd /usr/src/redhat/BUILD + LANG=C + export LANG + unset DISPLAY + cd /usr/src/redhat/BUILD + rm -rf wang-sj-1.0 + /bin/mkdir -p wang-sj-1.0 + cd wang-sj-1.0 + /bin/gzip -dc /usr/src/redhat/SOURCES/wang.tar.gz + tar -xvvf – -rwxr-xr-x root/root 160 2010-06-22 01:54:50 wang.sh + STATUS=0 + ‘[' 0 -ne 0 ']‘ ++ /usr/bin/id -u + ‘[' 0 = 0 ']‘ + /bin/chown -Rhf root . Nike Air Max 2011 Femme Nike Air Max BW Femme ++ /usr/bin/id -u + ‘[' 0 = 0 ']‘ + /bin/chgrp -Rhf root . adidas gazelle uomo rosse + /bin/chmod -Rf a+rX,u+w,g-w,o-w . West Virginia Mountaineers + exit 0 Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.67230 + umask 022 + cd /usr/src/redhat/BUILD + cd wang-sj-1.0 + LANG=C + export LANG + unset DISPLAY + install -m 755 wang.sh /usr/local/bin/wang.sh + /usr/lib/rpm/redhat/brp-compress + /usr/lib/rpm/redhat/brp-strip /usr/bin/strip + /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip + /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump + /usr/lib/rpm/brp-python-bytecompile + /usr/lib/rpm/redhat/brp-java-repack-jars Processing files: wang-sj-1.0-1 Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHave Prefix) <= 4.0-1 Checking for unpackaged file(s): /usr/lib/rpm/check-files %{buildroot} Wrote: /usr/src/redhat/RPMS/i386/wang-sj-1.0-1.i386.rpm [root@localhost SPECS]# cd .. asics gel quantum 360 uomo [root@localhost redhat]# tree . |– BUILD | |– wang-sj-1.0 | | `– wang.sh | `– wang.sh |– RPMS | |– athlon | |– i386 | | `– wang-sj-1.0-1.i386.rpm | |– i486 | |– i586 | |– i686 | `– noarch |– SOURCES | |– bash-completion-20060301.tar.bz2 | |– bash_completion.sh | |– wang.sh | `– wang.tar.gz |– SPECS | |– bash-completion.spec | `– wang.spec `– SRPMS 12 directories, 9 files 4、安装软件包 [root@localhost redhat]# rpm -ivvh RPMS/i386/wang-sj-1.0-1.i386.rpm D: ============== RPMS/i386/wang-sj-1.0-1.i386.rpm D: Expected size: 2073 = lead(96)+sigs(180)+pad(4)+data(1793) D: Actual size: 2073 D: RPMS/i386/wang-sj-1.0-1.i386.rpm: Header SHA1 digest: OK (252d9509e76b2a660e0 06ac4694eef27ea47d6e4) D: added binary package [0] D: found 0 source and 1 binary packages D: opening db environment /var/lib/rpm/Packages joinenv D: opening db index /var/lib/rpm/Packages rdonly mode=0×0 D: locked db index /var/lib/rpm/Packages D: ========== +++ wang-sj-1.0-1 i386/linux 0×0 D: opening db index /var/lib/rpm/Depends create mode=0×0 D: Requires: rpmlib(CompressedFileNames) <= 3.0.4-1 YES (rpmlib provides ) D: Requires: rpmlib(PayloadFilesHavePrefix) <= 4.0-1 YES (rpmlib provides ) D: opening db index /var/lib/rpm/Conflictname rdonly mode=0×0 D: closed db index /var/lib/rpm/Depends D: closed db index /var/lib/rpm/Conflictname D: closed db index /var/lib/rpm/Packages D: closed db environment /var/lib/rpm/Packages D: ========== recording tsort relations D: ========== tsorting packages (order, #predecessors, #succesors, tree, depth, breadth) D: 0 0 0 0 1 0 +wang-sj-1.0-1.i386 D: installing binary packages D: opening db environment /var/lib/rpm/Packages joinenv D: opening db index /var/lib/rpm/Packages create mode=0×42 D: mounted filesystems: D: i dev bsize bavail iavail mount point D: 0 0×00000801 4096 3606812 4804967 / D: 1 0×00000003 4096 0 -1 /proc D: 2 0×00000000 4096 0 -1 /sys D: 3 0x0000000b 4096 0 -1 /dev/pts D: 4 0×00000011 4096 59414 59413 /dev/shm D: 5 0×00000012 4096 0 -1 /proc/sys/fs/binfmt_misc D: 6 0×00000013 4096 0 -1 /var/lib/nfs/rpc_pipefs D: sanity checking 1 elements D: opening db index /var/lib/rpm/Name create mode=0×42 D: running pre-transaction scripts D: computing 1 file fingerprints Preparing… Asics Homme D: computing file dispositions D: opening db index /var/lib/rpm/Basenames create mode=0×42 ########################################### [100%] D: ========== +++ wang-sj-1.0-1 i386-linux 0×0 D: Expected size: 2073 = lead(96)+sigs(180)+pad(4)+data(1793) D: Actual size: 2073 D: wang-sj-1.0-1: Header SHA1 digest: OK (252d9509e76b2a660e006ac4694eef27ea47d6 e4) D: install: wang-sj-1.0-1 has 1 files, test = 0 1:wang-sj D: ========== Directories not explicitly included in package: D: 0 /usr/local/bin/ D: ========== D: fini 100755 1 ( 0, 0) 160 /usr/local/bin/wang.sh;4c1fbe46 GZDIO: 1 reads, 420 total bytes in 0.000078 secs ########################################### [100%] D: +++ h# 1212 Header SHA1 digest: OK (252d9509e76b2a660e006ac4694eef27ea47 d6e4) D: adding “wang-sj” to Name index. Jordan 2017 Homme sac lancel pas cher D: adding “wang.sh” to Basenames index. Canada Goose Constable Femme D: opening db index /var/lib/rpm/Group create mode=0×42 D: adding “System Environment/Shells” to Group index. Nike Blazer homme D: opening db index /var/lib/rpm/Requirename create mode=0×42 D: opening db index /var/lib/rpm/Providename create mode=0×42 D: adding “wang-sj” to Providename index. New Balance 577 męskie D: opening db index /var/lib/rpm/Dirnames create mode=0×42 D: adding “/usr/local/bin/” to Dirnames index. Nike Air Max Thea Homme Bleu Fjallraven Kanken mini D: opening db index /var/lib/rpm/Requireversion create mode=0×42 D: adding 2 entries to Requireversion index. D: opening db index /var/lib/rpm/Provideversion create mode=0×42 D: adding “1.0-1″ to Provideversion index. buy cheap ffxiv gil D: opening db index /var/lib/rpm/Installtid create mode=0×42 D: adding 1 entries to Installtid index. nike little rift br bambini

  • NIKE CORTEZ
  • D: opening db index /var/lib/rpm/Sigmd5 create mode=0×42 D: adding 1 entries to Sigmd5 index. Nike Air Max 95 360 Homme New Balance Hombre D: opening db index /var/lib/rpm/Sha1header create mode=0×42 D: adding “252d9509e76b2a660e006ac4694eef27ea47d6e4″ to Sha1header index.

  • Air Jordan 9 Homme
  • D: opening db index /var/lib/rpm/Filemd5s create mode=0×42 D: adding 1 entries to Filemd5s index.

    Posted in Linux | Leave a comment

    一个关于tcpdump的命令

    高级里面我们安装了tcpdump软件包, louboutin femme nike air jordan 8 uomo ff14 items Nike Pas Cher USC Trojans AIR MAX THEA Scarpe Nike Store 它可以抓包, Nike Air Max 2014 Homme nike air max thea print uomo Chaussures adidas Nike Air Max 97 Homme Canotte Boston Celtics Hogan Uomo Prezzi 2017 New Balance 993 mujer 我们可以根据抓取的数据包分析过程。 new balance baskets nike air max 2015 donna Adidas Zx Flux Femme Blanche asics gel quantum 360 uomo Nike Seattle Seahawks jerseys Air Jordan 8 Retro sac à dos kanken fjallraven pas cher 下面给大家一个它的使用 #tcpdump -i eth0 -nn -X -vv tcp port 21 and ip host 192.168.1.1 监控eth0网卡的21端口信息 以上命令中出现了几个参数,

    Posted in Linux | Leave a comment