Linux系统中shell命令总结

这篇文章主要是介绍Linux系统中shell指令     现在开始做电子版笔记,将学的课本知识变薄,自己对这些知识点进行总结,加深对知识的理解! 

ls:  显示文件名

cat:  显示文本文件的内容

       $ ls

       practice      //this is a file

       $  cat practice

       this is a small file that i created with a text editor.

rm:(remove)删除文件

          $ rm practice  

           $ rm -i  practice  //this is a relatively approach compared with the  first one.

hostname:显示系统名

       $ hostname

       person

cp:文件复制  格式:cp  source-file  destinnation-file  

     $ ls                                                                                    //注意:如果目标文件是一个已经存在的文件,执行指令后会覆盖原文件

      abc                                                                        //  因此  用指令 :   $cp  -i  abc   abc.copy   -i  为了避免覆盖重要文件

    $ cp abc abc.copy

    $  ls

     abc  abc.copy

 mv:更改文件名   格式: mv  existing-filename  new-filename

              $ ls

                abc

           $ mv abc  abc.newname                         //mv 也可能会销毁文件,故采用    $ mv  -i   abc  abc.newname  

             $  ls

             abc.newname

lpr:(line printer)打印文件

                 $ lpr  report

               $ lpr  -p  mailroom  report     //-p mailroom   指定打印机mailroom 进行打印任务

                  $  lpq    //查看打印作业

             $ lprm  86   //清除打印任务并停止;  86  是打印的作业号(lpq可以查阅打印号)

grep :查找字符串

              $  cat  abc

                I is a handsome boy.

           $ grep  'handsome'  abc

          handsome

 head: 显示文件头部

             $  head -4 abc   //显示abc文件的第4行

tail:显示文件尾部

            $ tail  -f  abc.file

sort:按顺序显示文件的内容                          //   -u 使排列列表中的每一行都唯一     -n   对一列数进行排序

             $  sort  abc.file

uniq:忽略文件中重复的行    //重复的行只显示一行

diff: 比较两个文件的内容   显示文件的不同之处

          $  diff  -u  abc1  abc2 

file: 识别文件的内容  主要是查看文件的类型

           $  file  abc1   abc2

|  :(管道)   实现进程间的通行通信

       $     sort  abcfile  |   head   -4     //sort对abcfile文件排序,然后通过管道,shell 将sort输出发给head的输入, head 显示排序后的前4行

echo :显示文本

   $  echo   filename

   $  echo  star:*      显示当前目录下所有的文件列表

   $  echo 'my-file' > new-file      //echo  将原文件的输出定向到新的文件中,相当于保存在另外一个文件中

data:显示日期和时间

     $  data    

     Tue Apr  10:14:42  PDT   2013

script  :   记录shell的会话信息

         $   script

unix2dos   ;  unix2mac :将linux文件转换为windows 和MacOS格式

       $    unix2dos   abc.txt

bzip2:压缩文件

                 $  bzip2   -v  filename     //  -v 显示磁盘节约的空间   文件扩展名为  .bz2

bzcat 和  bunzip2:解压缩文件

                 $ bzcat    filename.bz2    |  head   -2

                 $bunzip2   filename.bz2

tar: 打包和解包文件

                  $  tar -cvf   all.tar      g  b   d 

                  $ tar   -tvf   all.tar     

                   $  tar   -xvf  mak*

                 $  gunzip   mak*

which 与   whereis  : 定位应用程序

locate:搜索文件

who:列出系统上的用户

finger :列出系统上的用户

uptime:显示负载和持续运作时间信息

free:显示内存使用信息

        $    free   -mt       //-m  以M显示;  -t  输出的最后增加 total  一行

write :发送消息

       $   write   max-name  [terminal]

mesg:   接收消息    

     $    mesg  y  //接收消息

     $    mesg n   //拒绝接收消息

这些指令知识只写了大概的用法,上述指令的具体的还需要下来根据需要在深入学习了解。边学边做些电子版笔记,这样印象非常深刻! 

posted @ 2019-03-14 10:57  mysoulmate  阅读(571)  评论(1)    收藏  举报