1. 程式人生 > >第四章第五章 環境搭建和24個命令總結

第四章第五章 環境搭建和24個命令總結

gpl和gun 基本命令 cp

GUN 和 GPL

GUN‘s not Unix 遞歸寫法,簡寫也是GUN

1. GUN 是84年自由軟件資金會牽頭弄的一個類unix操作系統,但是因為它不實用,而且總是跳票,所以並沒有流行起來。

2. 但是它裏面的很多軟件是很好的,比如bash,這些都被用在了linux系統上


GPL

general public license

通用公共許可

84年Richeal Stallman 發起了自由軟件運動後不久,在其他人的協作下,創立了GPL


Preamble
The GNU General Public License is a free, copyleft license for software and
 other kinds of works.
#官網的解釋,GPL 是自由的,公共版權(copyleft)的,軟件和其他的作品。

For example, if you distribute copies of such a program, 
whether gratis or for a fee, you must pass on to the recipients the same 
freedoms that you received. You must make sure that they, too, receive 
or can get the source code. And you must show them these terms so they
 know their rights.
#不管你的軟件是免費還是收費,你都傳遞相同的自由給其他人。你必須要他們也獲得了源代碼。並且讓
他們知道他們的權利。

Developers that use the GNU GPL protect your rights with two steps: 
(1) assert copyright on the software, and 
(2) offer you this License giving you legal permission to copy, distribute 
and/or modify it.
#開發者用兩步保護你的權利:
   1. 確保軟件的版權(是開發者的)
   2. 給你復制,傳播,修改這個軟件的權利


For the developers‘ and authors‘ protection, the GPL clearly explains that 
there is no warranty for this free software. 
For both users‘ and authors‘ sake, the GPL requires that modified versions 
be marked as changed, so that their problems will not be attributed 
erroneously to authors of previous versions.
#為了保護開發者,GPL明確了這些免費軟件是沒有保修的(質保?咋翻譯呢)。
#任何修改過的軟件都要註明修改版本,免得以後出問題責任歸咎到前面版本的開發者。

Finally, every program is threatened constantly by software patents. 
States should not allow patents to restrict development and use of 
software on general-purpose computers, but in those that do, 
we wish to avoid the special danger that patents applied to a free
 program could make it effectively proprietary. 
 To prevent this, the GPL assures that patents cannot be used to render 
 the program non-free.
#這一段說的是專利法也不能用來限制軟件的自由傳播。有些州用專利法限制軟件的傳播,這些GPL是不
承認的。

linux內核是基於gun通用公共許可的,但是linux不是gun計劃的一部分



24命令總結

命令總結

  1. mkdir 創建目錄 -p 遞歸創建

  2. touch 創建文件

  3. ls 列表目錄

  4. cd 切換目錄

  5. echo 打印

  6. cp 拷貝目錄文件 -r遞歸 -a(dpr)

  7. vi 記事本編輯

  8. head 查看前n

  9. rm rm -f -r 目錄 練!

  10. cat 查看文件內容

  11. rmdir 刪除空目錄

  12. grep -v 後面要排除的內容

    1. -B before 出了顯示

    2. -A after

    3. -C context 前後

  13. find 目錄 -type f -name "名字" -mtime +7, 7, -7

    1. [[email protected]
/* */ test]# find . -type f -name "*" -mtime +12 ./space.txt ./awk.txt ./rex.txt ./tab.txt ./recode.txt ./root.txt
  1. eg

  • sed 增刪改查 -i 修改 -n 取消默認輸出 -e多項編輯

    1. p s g

  • alias 修改和設置別名,查看

  • unalias 取消別名

  • xargs 從標準輸入讀入創建執行命令 -n 1分組

    1. 記住從標準輸入讀入

    2. [[email protected] test]# find . -type f -name "*" -mtime -10 | xargs
      ./dtest_link.txt ./test1/jacob ./oldboy.txt ./dtest.txt
    3. [[email protected] test]# find . -type f -name "*" -mtime -10 | xargs -n 1
      ./dtest_link.txt
      ./test1/jacob
      ./oldboy.txt
      ./dtest.txt
    4. [[email protected] test]# find . -type f -name "*.txt" -mtime -10 | cat
      ./dtest_link.txt
      ./oldboy.txt
      ./dtest.txt
      [[email protected] test]# find . -type f -name "*.txt" -mtime -10 | xargs cat
      -->6)target is a good market
      -->1)target is a good market
      -->10)target is a good market
      -->3)tj_max is a good market
      -->9)target is a good market
      -->8)target is a good market
      -->13)target is a good market
      -->5)target is a good market
      -->2)walmart is a good market


  • awk -F 指定分隔符 NR 行號 {print $1 $2}

  • seq 打印序列

    1. 1 2 3 4 5 6 7 8 9 10

    1. seq -s " " 10 橫著打印

      -s指定分隔符

    2. seq -s " " 10

  • pwd 打印當前目錄

  • tree 打印目錄結構 目錄樹

    1. yum install tree -y

  • tr 截取 替換

  • tail 尾巴 默認後10行, -n 數字

  • vim 復雜編輯器 寫 shell,python

  • mv 移動 相當於改名

    1. [[email protected] test]# mv dtest.txt dtestchanged.txt
      [[email protected] test]# ls
      a                 dtest_link.txt  rex.txt             stu_nihao00_1.jpg
      aaaaaa.txt        dtest_soft.txt  riqi2017-07-22.txt  tab.txt
      awk.txt           md5.log         root.txt            test1
      b                 mod.txt         space.txt           today.txt
      c                 nihao.sh        sshd                umasktest1.txt
      ceshi.txt         oldboy.txt      stu_100_3.jpg       umasktest.txt
      checklog.sh       person.txt      stu_100_4.jpg
      dtestchanged.txt  recode.txt      stu_100_5.jpg
      [[email protected] test]# cat dtestchanged.txt
      -->6)target is a good market
      -->1)target is a good market
      -->10)target is a good market
    1. 移動到當前目錄,相當於改名了

  • date -s 改時間

    1. date -s "05/10/2009 10:18:00"



  • 重點研究了cp這個命令

    cp

    默認復制是符號鏈接也就是軟連接的

    比如

    [[email protected] test]# ln -s today.txt todaysoft.txt
    [[email protected] test]# ln -s today.txt todaysoft1.txt
    [[email protected] test]# cp todaysoft1.txt todaysoft3.txt
    lrwxrwxrwx 1 root  root       9 Aug  3 23:44 todaysoft1.txt -> today.txt
    -rwxr-xr-x 1 root  root      23 Aug  3 23:45 todaysoft3.txt
    lrwxrwxrwx 1 root  root       9 Aug  3 23:44 todaysoft.txt -> today.txt

    修改源復制的文件不會對源文件造成影響

    cp test2.sh test1.sh 這條命令不會把test1.sh的軟連接也copy過去,這就是cp命令的默認設置。-d就關閉了這個稱為derefrence(解除綁定)的默認選項

    eg:

    [[email protected] test]# cp -d todaysoft1.txt todaysoft4.txt
    lrwxrwxrwx 1 root  root       9 Aug  3 23:44 todaysoft1.txt -> today.txt
    -rwxr-xr-x 1 root  root      23 Aug  3 23:45 todaysoft3.txt
    lrwxrwxrwx 1 root  root       9 Aug  3 23:44 todaysoft4.txt -> today.txt
    lrwxrwxrwx 1 root  root       9 Aug  3 23:44 todaysoft.txt -> today.txt


    cp -d test2.sh test1.sh 就會保留這個鏈接

    -r 是遞歸復制,

    -a 包含了-d -p -r -p是指包含一切諸如屬組,修改時間等信息

    綜上所述,-a是完全一樣的復制 但是這是對於除了硬鏈接以外的文件

    筆者嘗試了cp 一個硬鏈接,但是產生了一個與源文件inode不相同的文件,也就是說,cp 對硬鏈接的默認復制就是復制了一個源文件,並且是inode不同的源文件

    也就是相當於cp了源文件

    cp 為我們提供了一個專門創建硬鏈接的選項 -l

    值得一提的是 ln這個命令的默認順序是 要復制的在前面,硬鏈接的結果在後面

    NAME
           ln - make links between files
    
    SYNOPSIS
           ln [OPTION]... [-T] TARGET LINK_NAME   (1st form)
           ln [OPTION]... TARGET                  (2nd form)
           ln [OPTION]... TARGET... DIRECTORY     (3rd form)
           ln [OPTION]... -t DIRECTORY TARGET...  (4th form)


    [ ] 裏面是可選的選項,就是說,默認情況下,目標在前,鏈接後的名字在後

    最後一個 -t 選項, 可是更改過來,但是是對目錄建立硬鏈接



    若幹特殊符號

    >or1>輸出重定向

    >>or1>>

    <or <0 從文件裏出來

    <<or<<0

    { }生成序列

    echo {1..10}

    echo {a..z} seq不一樣

    {a,b}/txt


    本文出自 “愛生活,愛linux” 博客,請務必保留此出處http://baoyu.blog.51cto.com/9768109/1953553

    第四章第五章 環境搭建和24個命令總結