https://hackmd.io/@IMOK/Lab11
講師: 賴昱有
https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh
)"https://github.com/romkatv/powerlevel10k.git
\({ZSH_CUSTOM:-\)HOME/.oh-my-zsh/custom}/themes/powerlevel10khttps://github.com/zsh-users/zsh-syntax-highlighting.git
用法 : ssh {user}@{host}
e.g. ssh b0135XXXX@linux.aclab.cool
or 使用 GUI (Bitvise SSh Client)
文字介面編輯器
按 ESC 回到 normal mode
在 normal mode 打冒號可以輸入指令
Command | Description |
---|---|
:w | 儲存 |
:wq | 儲存並退出 |
:q! | 不儲存退出 |
vim 是個很強大的編輯器
在 normal mode 可以用的指令還有連技超多
如果想了解的可以看看 這個Vim
推薦要學 只能用文字介面的時候非常好用
另一個文字介面編輯器
joe filename.txt
operation | description |
---|---|
Ctrl+K,H | show help |
Ctrl+K,F | search text |
Ctrl+K,L | go to line |
Ctrl+K,S | save file |
Ctrl+K,X | save file and exit editor |
Ctrl+Y | delete a line |
如果不知道指令怎麼用 請參考
command –help
man command
command | usage | description |
---|---|---|
chsh | chsh /bin/tcsh | 修改預設登入 shell |
passwd | passwd | 修改密碼 |
chmod | chmod 664 file | 修改檔案權限 |
cd | cd directory | 進入資料夾 |
pwd | pwd | 顯示目前的目錄位置 |
echo | echo "hello world" | 輸出文字 |
cat | cat file | 檢視檔案內容 |
less | less file | 另開分頁查看內容 |
command | usage | description |
---|---|---|
head | head -n 10 file | 檢視檔案前10行 |
tail | tail -n 10 file | 檢視檔案最後10行 |
grep | grep "apple" example.txt | 擷取有關鍵字的那一行 |
cp | cp file file_copy | 複製檔案 |
mv | mv file file_moved | 移動、重新命名檔案 |
mkdir | mkdir directory | 創建資料夾 |
rmdir | rmdir directory | 刪除空目錄 |
touch | touch file | 創建檔案 |
rm | rm file | 刪除檔案 |
command | usage | description |
---|---|---|
chsh | chsh /bin/tcsh | 修改預設登入 shell |
ypchsh | ypchsh /bin/tcsh | 在 NIS 機器上修改預設登入 shell |
passwd | passwd | 修改密碼 |
yppasswd | yppasswd | 在 NIS 機器上修改密碼 |
ls | ls -l | 列出當前目錄下的檔案 |
ll | ll | ls -l的縮寫 |
command | usage | description |
---|---|---|
vim | vim file | 使用 vim 編輯檔案 |
df | df -h | 列出磁碟剩餘空間 |
du | du –max-depth 1 -h . | 列出資料夾所占空間 |
free | free -h | 列出記憶體使用狀況 |
who | who | 查看目前登入使用者 |
gcc | gcc main.c | 編譯 c 語言檔案 |
g++ | g++ main.cpp | 編譯 c++ 語言檔案 |
command | description |
---|---|
gcc file.c | 編譯 file.c,生成默認執行檔 a.out |
gcc -o output file.c | 編譯 file.c,輸出執行檔為 output |
gcc -c file.c | 只編譯生成目標檔案 file.o 不連結 |
gcc -E file.c -o file.i | 只進行預處理,輸出為 file.i |
gcc -S file.c | 只產生組合語言檔案 file.s |
gcc -v file.c | 顯示詳細編譯過程 |
列出磁碟剩餘空間
e.g.df -h
列出資料夾所占空間
e.g. du –max-depth 1 -h .
列出記憶體使用狀況
e.g. free -h
編譯 c 語言檔案
e.g. gcc main.c
編譯 c++ 語言檔案
e.g. g++ main.cpp
在指令後面加上 & 可以放到背景執行
e.g. sleep 60 &
用 ps 列出當前所有 process
用 jobs 可以看到正在背景執行的 process
執行程式時可以用組合鍵 Ctrl+c 傳送停止訊號
或是用 Ctrl+z 將程式暫停後放到背景
放到背景後可以用 fg %1 把它放到前景繼續執行
或是 bg %1 讓他在背景繼續執行
可以使用 kill %1 對程式發送訊號
kill 並不是只能發送停止訊號
overwrite:echo "string" > file.txt
append:echo "string2" >> file.txt
cat file.txt | grep "apple"
cat /proc/meminfo | grep Pages | sort
du -d 1 -h | sort -h
ls *.txt
cat file *
GNU / Linux 各種壓縮與解壓縮指令 - 凍仁的筆記
作業做完請上傳到 http://140.121.197.13/tutorial
並且注意上傳時間限制、檔名、其他規範
上課時提前做完可以直接給助教 demo 登記
就不需要上傳 demo 過的部分
Write a program to find the prime numbers
between 1 and 10000 and compile it using gcc or g++.
Execute the file and redirect the output to the file primes.txt.
Allow the user to input 10 numbers, then sort them using the insertion sort and
save the sorted result to a file isort10.txt.
Complete the 99 multiplication table using only one loop
and output the result to a file named 1loop99.txt.