顯示具有 Linux 標籤的文章。 顯示所有文章
顯示具有 Linux 標籤的文章。 顯示所有文章

2022年10月10日 星期一

MD5 筆記

MD5 Intro

MD5 訊息摘要演算法(英語:MD5 Message-Digest Algorithm),一種被廣泛使用的密碼雜湊函式,可以產生出一個128位元(16個字元(BYTES))的雜湊值(hash value),用於確保資訊傳輸完整一致。(節自wiki)

簡易 MD5 工具 : md5sum

基本上 Unix, Linux 的作業系統都有預設 md5sum
  • md5sum 用法
        # pipe
        $ echo "123" | md5sum
        ba1f2511fc30423bdbb183fe33f3dd0f  -
    
        # 讀檔
        $ md5sum .gitignore
        247bc32fd24d78844194917cb32d556a  .gitignore
    
        # check
        $ md5sum .gitignore > tmp.md5
        $ md5sum -c tmp.md5
        .gitignore: OK
    
        # pipe check
        $ echo "247bc32fd24d78844194917cb32d556a .gitignore" | md5sum -c
        .gitignore: OK
    

openssl/evp.h

The EVP digest routines are a high level interface to message digests (節自 Linux man page)。這裡註記一下 EVP 大概是代表 Envelope。雖然現在已經被改掉,但以前的 openssl/evp.h 的 #ifndef 是 HEADER_ENVELOPE_H。
  • evp 大概的流程
        #include <stdio.h>
        #include <string.h>
        #include <openssl/evp.h>
    
        int main(int argc, char *argv[])
        {
            EVP_MD_CTX *mdctx;
            const EVP_MD *md;
            char mess1[] = "Test Message\n";
            char mess2[] = "Hello World\n";
            unsigned char md_value[EVP_MAX_MD_SIZE];
            unsigned int md_len, i;
    
            if (argv[1] == NULL) {
                printf("Usage: mdtest digestname\n");
                exit(1);
            }
    
            OpenSSL_add_all_algorithms(); // 有可能有些 algo 沒有 load, ex. RSA-SHA1
            md = EVP_get_digestbyname(argv[1]);
            if (md == NULL) {
                printf("Unknown message digest %s\n", argv[1]);
                exit(1);
            }
    
            mdctx = EVP_MD_CTX_new();
            EVP_DigestInit_ex(mdctx, md, NULL); // _ex() 較有效率, 以前的 code 可能是 EVP_DigestInit()
            EVP_DigestUpdate(mdctx, mess1, strlen(mess1));
            EVP_DigestUpdate(mdctx, mess2, strlen(mess2));
            EVP_DigestFinal_ex(mdctx, md_value, &md_len);
            EVP_MD_CTX_free(mdctx);
    
            printf("Digest is: ");
            for (i = 0; i < md_len; i++)
                printf("%02x", md_value[i]);
            printf("\n");
    
            exit(0);
        }
    
參考資料 :
1.MD5 wiki
2.MD5SUM wiki
3.linux man page
4.stackoverflow

2022年10月9日 星期日

讀取 Linux file info (stat)

讀取 Linux 的檔案資訊

Linux 的檔案有很多資訊,即使只用到檔案大小也是很方便。

stat

  • struct stat
    stat 的資料結構
        #include <sys/stat.h>
    
        struct stat {
            dev_t     st_dev;         /* ID of device containing file */
            ino_t     st_ino;         /* Inode number */
            mode_t    st_mode;        /* File type and mode */
            nlink_t   st_nlink;       /* Number of hard links */
            uid_t     st_uid;         /* User ID of owner */
            gid_t     st_gid;         /* Group ID of owner */
            dev_t     st_rdev;        /* Device ID (if special file) */
            off_t     st_size;        /* Total size, in bytes */
            blksize_t st_blksize;     /* Block size for filesystem I/O */
            blkcnt_t  st_blocks;      /* Number of 512B blocks allocated */
    
            /* Since Linux 2.6, the kernel supports nanosecond
                precision for the following timestamp fields.
                For the details before Linux 2.6, see NOTES. */
    
            struct timespec st_atim;  /* Time of last access */
            struct timespec st_mtim;  /* Time of last modification */
            struct timespec st_ctim;  /* Time of last status change */
    
            #define st_atime st_atim.tv_sec      /* Backward compatibility */
            #define st_mtime st_mtim.tv_sec
            #define st_ctime st_ctim.tv_sec
        };
    
  • struct stat
    讀取檔案 (這裡讀 .gitignore)
        #include <stdio.h>    // for printf
        #include <time.h>     // for ctime
        #include <sys/stat.h>
    
        int main()
        {
            struct stat st;
            // 0 success, -1 failed
            // error code: errno
            if(stat(".gitignore", &st) == -1){
                return -1;
            }
            printf("I-node number:             %ld\n", (long) st.st_ino);
            printf("Mode:                      %lo (octal)\n", (unsigned long) st.st_mode);
            printf("Link count:                %ld\n", (long) st.st_nlink);
            printf("Ownership:                 UID=%ld   GID=%ld\n", (long) st.st_uid, (long) st.st_gid);
            printf("device containing file id: %ld\n", (long) st.st_dev);
            printf("device id:                 %ld\n", (long) st.st_rdev);
            printf("File size:                 %lld bytes\n", (long long) st.st_size);
            printf("Preferred I/O block size:  %ld bytes\n", (long) st.st_blksize);
            printf("Blocks allocated:          %lld\n", (long long) st.st_blocks);
            printf("Last status change:        %s", ctime(&st.st_ctime));
            printf("Last file access:          %s", ctime(&st.st_atime));
            printf("Last file modification:    %s", ctime(&st.st_mtime));
            return 0;
        }
    
        I-node number:             20057552
        Mode:                      100664 (octal)
        Link count:                1
        Ownership:                 UID=1000   GID=1000
        device containing file id: 66306
        device id:                 0
        File size:                 16 bytes
        Preferred I/O block size:  4096 bytes
        Blocks allocated:          8
        Last status change:        Tue Mar 29 14:03:01 2022
        Last file access:          Sun Oct  9 19:02:52 2022
        Last file modification:    Thu Jun 17 10:20:57 2021
    
參考資料 :
1.Linux manual page
2.程式人生

2021年1月7日 星期四

LINUX - cURL 筆記

cURL - Client URL

    cURL is a command-line tool for getting or sending data including files using URL syntax。網站在開發 Restful API 時,測試會用到的最基本工具。這邊紀錄一些常用的參數
  • 基本的 request
        # Default 是 GET
        curl http://localhost:8888/
        # 指定 request (--request 可用 -X 代替)
        curl --request GET http://localhost:8888/
        curl --request POST http://localhost:8888/
  • 將 response 存成檔案
        # -o 加檔名, -O 直接將 URL 當檔名 (ex. list_user)
        $ curl -o temp  http://localhost:8888/list_user
        $ curl -O http://localhost:8888/list_user
  • 若 response 301/302(redirect),會跟著 redirect
        # 會 redirect 到 http://www.google.com    
        curl -L http://google.com
  • 把整個 request 流程 trace 儲存到 file
        curl --trace-ascii debugdump.txt -L http://google.com
參考資料 :


2020年9月3日 星期四

Linux - Shell Scripts - ln 指令

ln 指令

    ln 指令是用來建立連結檔, 這裡用安裝 nodejs 示範。安裝法為在官網下載編譯好的 nodejs, 然後用 ln 建立連結檔。
    # 從 nodejs.org 下載並解壓縮至 /home/user/software
    $ ln -s /home/daniel/software/node-v12.18.3-linux-x64/bin/node /usr/local/bin/
    $ ln -s /home/daniel/software/node-v12.18.3-linux-x64/bin/npm  /usr/local/bin/
    # 之後利用 node -v 跟 npm -v 來確定安裝是否完成...
    
    daniel@daniel-pc:~/daniel/node-v12.18.3-linux-x64$ ls -al /usr/local/bin/
    總計 8
    drwxr-xr-x  2 root root 4096  9月  3 15:46 .
    drwxr-xr-x 10 root root 4096  2月  4  2020 ..
    lrwxrwxrwx  1 root root   52  9月  3 15:02 node -> /home/daniel/daniel/node-v12.18.3-linux-x64/bin/node
    lrwxrwxrwx  1 root root   51  9月  3 15:46 npm -> /home/daniel/daniel/node-v12.18.3-linux-x64/bin/npm

軟連結(soft/symbolic link) 跟 硬連結(hard link)

    上面範例我用的是軟連結, 指令有加 -s, 硬連結則是不加。下面是兩種連結的比較。
    連結 : 與連結的檔案相同的 inode, 相對路徑不受連結之檔案影響
    連結 : 與連結的檔案不同的 inode, 相對路徑連結之檔案影響
    如果用相對路徑去軟連結, 結果就是 2 個連結檔壞掉, 因為 inode 不同, 軟連結找不到 ./bin/node 跟 ./bin/npm。
    $ sudo ln -s ./bin/node /usr/local/bin/
    $ sudo ln -s ./bin/npm  /usr/local/bin/
    $ ls -al /usr/local/bin/
    總計 8
    drwxr-xr-x  2 root root 4096  9月  3 18:16 .
    drwxr-xr-x 10 root root 4096  2月  4  2020 ..
    lrwxrwxrwx  1 root root   10  9月  3 18:16 node -> ./bin/node
    lrwxrwxrwx  1 root root    9  9月  3 18:16 npm -> ./bin/npm
    如果用相對路徑去硬連結, 因為 inode 相同, 硬連結找得到 ./bin/node。
    $ sudo ln ./bin/node /usr/local/bin/
    $ sudo ln ./bin/npm  /usr/local/bin/
    $ ls -al /usr/local/bin/
    總計 47520
    drwxr-xr-x  2 root   root       4096  9月  3 18:24 .
    drwxr-xr-x 10 root   root       4096  2月  4  2020 ..
    -rwxr-xr-x  2 daniel daniel 48646656  7月 22 23:00 node
    lrwxrwxrwx  2 daniel daniel       38  9月  3 13:34 npm -> ../lib/node_modules/npm/bin/npm-cli.js
    但上面的 npm 是壞的, 因為原本的 npm 也是連結檔, 而且連的是相對位置。雖然透過 inode 找到該連結檔, 但因為是在 /usr/local/bin 下找相對位置所以找不到。所以就如同文章最一開始的安裝示範, 軟連結在相對路徑的處理上會受所連結檔案影響, 反而能成功找到 ../lib/node_modules/npm/bin/npm-cli.js。
參考資料 :

2020年8月28日 星期五

C 語言 - 正規表示法實作 ( regex.h )

regex.h (Linux 原生, Windows 再說)

    Regex.h 實作主要分 3 階段,regcom, regexec, regfree。
    // 要被批配的 buffer 跟一些參數
    int status, len, i;
    char buf[1024], data[1024];
    getdata(data);

    // 正規表示式的會要先 compile (regcomp())並儲存在 regex_t 此資料結構
    regex_t preg;

    // 設定批配模式的 flag. 
    // REG_EXTENDED ERE (Extended Regular Expression, 不用就是 BRE)
    // REG_ICASE    忽略大小寫
    // REG_NOSUB    不儲存批配後的結果
    // REG_NEWLINE  識別換行符(^$ 這類符號會成每一行的開頭跟結尾), REG_NEWLINE 效力 > eflags
    int cflags = REG_EXTENDED | REG_NEWLINE;

    // 正規表示式的批配樣板
    const char * regex = "Name: ([A-Z a-z]+)\nYear of Birth: ([^\n]*)\n([^:]*: [^\n]*)";

    // pmatch 為 struct 陣列去儲存批配後的結果
    // pmatch.rm_so 批配到的子字串在 target string 的起始 index
    // pmatch.rm_eo 批配到的子字串在 target string 的終止 index
    // nmatch 為宣告 pmatch 的陣列大小
    const size_t nmatch = 10;
    regmatch_t pmatch[nmatch];
    
    // eflags 也會對批配做改動
    // REG_NOTBOL   開頭批配符號(^)永遠批配不到
    // REG_NOTEOL   結尾批配符號($)永遠批配不到
    // REG_STARTEND 是直接使用 pmatch[0] 的 rm_so 跟 rm_eo
    //   作為字串頭尾的 index 然後批配,是為了避免 target string 
    //   中間有終止符(\0) 或 字串太長 strlen() 會 fail.
    int eflags = 0;

    // compile regex 
    if( regcomp(&preg, regex, cflags) != 0 ) {
        puts("regex compile error!\n");
        return;
    }

    // 進行批配 status = 0 代表成功
    status = regexec(&preg, data, nmatch, pmatch, eflags);
    if (status == REG_NOMATCH) {
        printf("No Match\n");
    } else if (status == 0) {
        // pmatch[0] 所指的子字串會是整串
        // pmatch[1], pmatch[2]... 會是括弧裡 sub regex,通常拿來取真正想要的值
        for (i = 0; i < nmatch && pmatch[i].rm_so >= 0; ++i) {
            len = pmatch[i].rm_eo - pmatch[i].rm_so;
            strncpy(buf, data + pmatch[i].rm_so, len);
            buf[len] = '\0';
            printf("match %d :\n%s\n\n", i+1, buf);
        }
    }

    regfree(&preg);
    return;

測試資料 跟 結果

    測試資料
Name: JunYe
Year of Birth: 1993
Gender: Male
    結果
match 1 :
Name: JunYe
Year of Birth: 1993
Gender: Male

match 2 :
JunYe

match 3 :
1993

match 4 :
Gender: Male

Basic (BRE) and extended (ERE) regular expression

    在一些特殊字元處理不一樣, 請參考 GNU的說明
參考資料 :

2020年7月20日 星期一

Linux - Shell Scripts (3) (pipe : grep)

管線命令 ( Pipe )

    管線命令是用 "|" 去連接,只要前一資料能變成 standard input。管線命令僅會處理 standard output,而不會處理 standard error output。下面用時下最夯的 MBTI 作的假資料。
index    name    MBTI
1        JunYe   ISTJ
2        JunYe   ISTP
3        JunYe   ESTP
4        JunYe   ESTJ
5        Mario   ISFJ
6        Mario   ISFP
7        Mario   ESFP
8        Mario   ESFJ
9        Joel    INFJ
10       Joel    INFP
11       Joel    ENFP
12       Joel    ENFJ
13       Joel    INTJ
14       Joel    INTP
15       Joel    ENTP
16       John    ENTJ
17       John    ESFP
18       Peter   ESFJ
19       Peter   INFJ
20       Peter   INFP
21       Peter   ENFP
22       Eva     ESTJ

基本管線命令 grep

    grep會在每一行找尋配對的字串,然後列出來。
$ bash pipeData.sh | grep "JunYe"
1        JunYe   ISTJ
2        JunYe   ISTP
3        JunYe   ESTP
4        JunYe   ESTJ
    加 -v 找每一行沒配對的字串,然後列出來。
$ bash pipeData.sh | grep -v "JunYe"
index    name    MBTI
5        Mario   ISFJ
6        Mario   ISFP
7        Mario   ESFP
8        Mario   ESFJ
9        Joel    INFJ
10       Joel    INFP
11       Joel    ENFP
12       Joel    ENFJ
13       Joel    INTJ
14       Joel    INTP
15       Joel    ENTP
16       John    ENTJ
17       John    ESFP
18       Peter   ESFJ
19       Peter   INFJ
20       Peter   INFP
21       Peter   ENFP
22       Eva     ESTJ
上一篇 :

2020年7月16日 星期四

Linux - Shell Scripts (2)

sh vs bash

    我有時候用 sh 會讓 shell script 執行不過,通常會報 Bad substitution 之類的錯誤。其實是因為我用 ubuntu,ubuntu 的 sh 其實是指到 dash 而非 bash。dash 在這不作多介紹, 把它想像成輕量型的 bash,所以支援的功能有限,所以有機會報錯。
ubuntu: cd /bin/
ubuntu: /bin$ ls -l
lrwxrwxrwx 1 root root       4  4月  9 16:36 sh -> dash

shell 字串操作

    #!/bin/bash
    # Shell 字串操作
    # 執行 bash string.sh

        file=/dir1/dir2/dir3/my.file.txt

        # 字串刪減
        # '#' 專刪右邊
        echo ${file#*/}   # 從左邊開始批配,刪掉 / 自身和其左邊的字串:dir1/dir2/dir3/my.file.txt
        echo ${file##*/}  # 從右邊開始批配,刪掉 / 自身和其左邊的字串:my.file.txt
        echo ${file#*.}   # 從左邊開始批配,刪掉 . 自身和其左邊的字串:file.txt
        echo ${file##*.}  # 從右邊開始批配,刪掉 . 自身和其左邊的字串:txt
        # '%' 專刪右邊
        echo ${file%/*}   # 從右邊開始批配,刪掉 / 自身和其右邊的字串:/dir1/dir2/dir3
        echo ${file%%/*}  # 從左邊開始批配,刪掉 / 自身和其右邊的字串:
        echo ${file%.*}   # 從右邊開始批配,刪掉 . 自身和其右邊的字串:/dir1/dir2/dir3/my.file
        echo ${file%%.*}  # 從左邊開始批配,刪掉 . 自身和其右邊的字串:/dir1/dir2/dir3/my

        # 取子字串
        echo ${file:0:5}  # 從 index 為 0 之字元,往後取 5 個:/dir1
        echo ${file:5:5}  # 從 index 為 5 之字元,往後取 5 個:/dir2

        # 字串取代
        echo ${file/dir/path}  # 將第一個 dir 取代成 path:/path1/dir2/dir3/my.file.txt
        echo ${file//dir/path} # 將全部的 dir 取代成 path:/path1/path2/path3/my.file.txt

    exit 0

shell 陣列操作

    # Array 操作

        declare -a ARRAY      # 宣告 array 可以省略
        ARRAY=(first second third)
        echo ${ARRAY[0]}      # first
        echo ${ARRAY[1]}      # second
        echo ${ARRAY[2]}      # third
        echo ${ARRAY[*]}      # first second third
        echo ${ARRAY[*]:1:2}  # second third
        echo ${ARRAY[@]:1:2}  # second third
        
    exit 0
上一篇 :
下一篇 :

2020年7月14日 星期二

Linux - Shell Scripts (1)

sh v.s source

    如果直接用 sh 執行 script,基本上就是開一個子程序去執行 script。所以父程序要獲得子程序的結果,通常都是靠著 export 解決 scope 的不同。若是使用 source 去執行 script,則是直接用本身程序去執行,所以本身與腳本享有共同 scope。更多請參考 : 鳥哥私房菜

基本的 variable & operator

    基本上 shell 的語法網路上有很多相關資料,這邊我想紀錄的是那些對於菜鳥不怎麼直觀的 variable & operator。而且其實我認為 shell 的精華就是在這些 variable & operator。
  • variable
        #!/bin/sh
            # 執行 : sh variable.sh a b c 
            echo $0         # script 本身
            echo $1 $2 $3   # 執行 script 時, 後面跟著的 arguments
            echo $#         # arguments 之總數
            echo $*         # 全部 arguments, 這個例子就是 a b c 
            echo $@         # 全部 arguments, 這個例子就是 a b c ($* $@ 應該有所不同, 不過我試不出來...)
            echo $?         # 上一個程式最後回傳值 (exit 0)
            echo $$         # 此 shell 的 pid
            echo $!         # 此 shell 最後執行的 background process 的 pid
        exit 0
  • operator
        #!/bin/sh
        # 執行 : sh operator.sh 20 10 
            
            # 此格式為固定的, ``, operator 前後要有空格
            # expr 不會檢查 $1 跟 $2, 所以沒有的話會出錯
            # 即使加了 "" 也會被判定 null, 等於 non-integer 也是錯 
            val=`expr $1 + $2`    # 相加
            val=`expr $1 - $2`    # 相減
            val=`expr $1 \* $2`   # 相乘 (*須加反斜線)
            val=`expr $1 / $2`    # 相除
            val=`expr $1 % $2`    # 取餘數
    
            # ==, !=, >, <, >=, <=
            if [ $1 = $2 ]; then
                val="equal"
            fi
    
            if [ $1 != $2 ]; then
                val="non-equal"
            fi
    
            if [ $1 -eq $2 ]; then
                val="equal"
            fi
    
            if [ $1 -ne $2 ]; then
                val="non-equal"
            fi
    
            if [ $1 -gt $2 ]; then
                val="greater than"
            fi
    
            if [ $1 -lt $2 ]; then
                val="less than"
            fi
    
            if [ $1 -ge $2 ]; then
                val="greater or equal"
            fi
    
            if [ $1 -le $2 ]; then
                val="less or equal"
            fi
        exit 0
  • 更多 operator
        #!/bin/sh
            # 執行 : sh operator2.sh 字串1 字串2 ...
            # 參數判斷時, 最好加上 "", 否則有高機率失效, 並出現 unary operator expected 等錯誤.
            if [ -z "$1" ]; then
                echo "there's no argument"
            fi
    
            if [ ! -z "$1" ]; then
                echo "there's at least one argument (!-z)"
            fi
    
            if [ -n "$1" ]; then
                echo "there's at least one argument (-n)"
            fi
    
            if [ "$1" ]; then
                echo "#1 argument is exist"
            fi
    
            # boolean operator -a = and, -o = or
            if [ "$1" -a "$2" ]; then
                echo "#1 and #2 arguments are both exist"
            fi
    
            if [ "$1" -o "$2" ]; then
                echo "there's at least one argument"
            fi
        exit 0
參考資料 :
下一篇 :

2020年5月10日 星期日

C 語言 - CLI ( Command Line Interface ) 設計 (1)

CLI 命令列介面


    在設計 CLI 的程式時,最好的方法是遵從 IEEE Std 1003 ( POSIX ) 對 program 的 command-line options 之規範。所以用 getopt 去做 parse command-line 是最簡單的,有一點要注意的是 GNU 提供的 getopt 支援 " -- ",這個 POSIX 沒有規範。

常見的 Usage 設計

    Usage : 
        my_program tcp <host> <port> [--timeout=<seconds>]
        my_program serial <port> [--baud=9600] [--timeout=<seconds>]
        my_program (-h | --help)
    參數
    my_program   : program name
    tcp   : commands
    -h, --help   : options
    <host>   : arguments

    符號
    [ ]   : optional
    ( )   :  required
     |   :  mutually exclusive
    ...   :  repeating elements

Options 設計


    在設計長命名的 option ( " -- " ),最好需要有一個相對短命名的 option ( " - " ),example : -h, --help。

    每隻程式最好都要有 --help 跟 --version


參考資料 :

2020年3月17日 星期二

Linux 初學 (3)

Linux 檔案系統

    Linux 採用 FHS ( Filesystem Hierarchy Standard ),基本上規定三項
  • /        : 與開機系統有關
  • /usr   : 與軟體安裝 / 執行有關
  • /var   : 與系統運作過程有關

Linux 目錄指令

    cd [相對路徑或絕對路徑]   // 到該目錄
    cd ~username              // 到該使用者家目錄
    cd ~                      // 到當前使用者家目錄
    pwd                       // 顯示當前目錄

Linux 環境變數 $PATH

    echo $PATH
    /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
某些情況下,即使你已經將 ls 搬回 /bin 了,不過系統還是會告知你無法處理 /root/ls 喔!很可能是因為指令參數被快取的關係。 不要緊張,只要登出 (exit) 再登入 (su -) 就可以繼續快樂的使用 ls 了!

Linux 特殊權限 SUID, SGID, SBIT

    // SUID = 4 ,設在檔案上,讓有檔案執行權利的使用者執行檔案時,權利跟檔案擁有者一樣
    // SGID = 2 ,設在檔案或目錄上,讓有檔案執行權利的使用者執行檔案時,權利跟檔案群組一樣
    // SBIT = 1 ,設在目錄上,使在目錄下的使用者只能對自己的檔案或目錄作刪除/更名/移動等動作
    
    // example
        chmod 4755 test
        ls -l test
        -rwsr-xr-x 1 root root 0 Mar 17 12:38 test


上一篇:

2020年3月13日 星期五

Linux 初學 (2)

Linux 指令查詢

     Linux 指令有很多,使用者不可能全部記下來,所以查詢指令就很重要了。
    man             // 提供一般的查詢,支援度高
    info            // 提供閱讀介面較好的查詢
    /usr/share/doc  // 通常會把指令相關文件放在這

Linux 檔案權限

    ls -al          // l = 列出所有資訊,a = 包含隱藏檔案

    -rwxr--r--.  1 root root 0 Mar 13 17:05 test

    // 第一個字串(字串)
        // 第 1 個字元代表檔案類型
        // 第 1 組 rwx 代表擁有者權限
        // 第 2 組 rwx 代表群組權限
        // 第 3 組 rwx 代表其他使用者權限
    
    // 第二個字串(數字)    // 第三個字串(字串)    // 第四個字串(字串)
        // 檔案連結數          // 擁有者名稱          // 群組名稱
    
    // 第五個字串(數字)    // 第六個字串(時間)    // 第七個字串(字串)
        // 檔案大小            // 最後修改時間        // 檔案名稱
    可得很多當前目錄檔案的訊息,如何閱讀 鳥哥的 Linux 私房菜 都有教學。
    以下指令為修改檔案權限之指令。要有目錄執行權力才能 call cd 或讀取裡面的檔案。
    chown           // 修改擁有者
    chgrp           // 修改群組
    chmod           // 修改權限

上一篇:
下一篇:


參考資料 :
鳥哥的Linux私房菜

2020年3月11日 星期三

Linux 初學 (1)

Linux是一個作業系統


     相較其他作業系統特殊的地方就是 Linux 為 GPL 授權軟體,Open source 的一種。使用者可以免費下載使用且隨意更改原始碼,只要你不修改其 GPL 授權或販賣簡單軟體 ( 簡單軟體指得是 Linux 上開發的軟體,但開發商還是能販售所謂的"服務" )。

Virtual Box 安裝 Linux


     基本上我是照著 鳥哥的 Linux 私房菜 裝的,只是我是用 Virtual Box,不一樣的是 Virtual Box 預設沒有支援 CentOS,所以先新增一個 Red Hat,再將存放裝置讀取從 CentOS.org 所載的 iso 檔,然後注意開機 boot 的順序即可 ( 光碟 > 硬碟 )。



如想嘗試完全照抄鳥哥的安裝法


     鳥哥用 GPT 去切割硬碟,如果想要照抄,得先開啟 EFI ( 也叫 UEFI,EFI 似乎是早期的名子 ),然後多切割一個 /boot/efi ,容量 300 ~ 500 M 就好了。





下一篇:


Popular Posts