Skip to content
On this page

Linux 筆記

指令

  • pwd:印出當前目錄
  • ls:當前目錄下的文件(夾)
  • ls -l:當前目錄下的文件(夾)屬性
  • ls -a:當前目錄下的文件(夾)包含隱藏文件 all

image.png

  • ls --help:印出 ls 提供的方法
  • ls -t:照修改順序
  • touch deom.txt:新增 deom.txt
  • rm deom.txt:刪除 deom.txt
  • re -rf demo:強制刪除 deom 資料夾&裡面的東西
  • mkdir -p deom/deom2/deom3:依序創建 deom/deom2/deom3
    • 如果沒有 -p 又沒有該資料夾 會出錯
  • history:印出歷史紀錄

image.png

  • cat etc/profile:印出 etc/profile 的檔案內容
    • cat -b etc/profile:印出 etc/profile 的檔案內容 + 行數

image.png

  • cat test1.txt test2.txt:印出 test1.txt 和 test2.txt 的內容
  • cat test1.txt test2.txt >> test3.txt:將兩個檔案合併成 test3.txt
  • more test.txt:印出 test.txt 的檔案 按照%數
    • b 往前 f 往後

VI/VIM

image.png

HJKL 可以上下左右移動

image.png

  • :set nu:顯示行號
  • :17:移動到 17 行
  • e or b:移動單字的結尾或開頭

insert

image.png

image.png

image.png

image.png

image.png

image.png

user

system user & reglaur user

前面有 # 代表是 root 使用者

  • /etc/password 查看用戶
  • /etc/group
  • su demo: 切換成 demo 使用者
  • su: 切換成 root 使用者

[Ubuntu] 解決 xxx is not in the sudoers file https://jerrynest.io/xxx-is-not-in-the-sudoers-file/

image.png

image.png

image.png

  • d 文件夾
  • rwx 代表 可讀、可寫、可執行

image.png

  • chmod 修改權限

網路

  • DNS
  • GATEWAY
  • DHCP
  • NAT 網路地址轉換

image.png

  • apt install vim:安裝 vim

ssh 建立安全連接

輸入 ifconfig

ubuntu 安裝 sudo apt-get install openssh-server

連線 ssh [email protected]

ssh public key

git bash 生成 ssh public key & private key

ssh-keygen

傳到 linux

ssh-copy-id [email protected]

接著輸入密碼後,開始連線

exit 離開

scp

image.png

scp tmp/test.txt [email protected]:/hone/demo