ref: https://wiki.bash-hackers.org/howto/redirection_tutorial
本篇是個 Linux 相關的教學文,專注於透過視覺化的方式來教學到底 shell 上常常使用的 >, 2>&1 等差異是什麼。
舉例來說,你能不能清楚的說出下列兩種用法的差異,實際上 fd 到底會怎麼運作?
1. > file 2>&1
2. 2>&1 > file
亦或是某些 shell script 常看到 exec 2>log 到底是什麼意思?
本篇文章解釋得非常清除,透過 /dev/pts 這種 pseudo terminal 為起點,將 0(stdin), 1(stdout), 2(stderr) 三個 fd 給視覺化呈現。
基於這個概念開始探討下列不同指令實際上 fd 會有什麼變化
# Simple Redirections
">" 應該是最為簡單也最廣為人知的用法,command > file 的方式將輸入(stdout)給導入檔案(file)。
那加上數字後會有什麼變化呢? 譬如 command 1>file, command 3>file ?
下一個不能不知的就是 pipe 的概念,透過 pipe 能夠組合出各種指令來解決問題,到底 pipe(|) 的過程中這些 fd 是什麼變化?
# More On File Descriptors
另外一個很常被問到的用法就是,有沒有辦法將 stderr 跟 stdout 一起輸出?
這時候可能就會看到 1>&2 2>&1 等各種答案,那到底這些語法的背後是什麼意思?
非常推薦所有人都仔細閱讀這篇文章重新複習/學習這類型操作的底層變化。
同時也有31部Youtube影片,追蹤數超過44萬的網紅MakeLearningFun,也在其Youtube影片中提到,Programming become more and more important nowadays. Some people may think it is different to learn, but actually it is not! With the right tools and ...
「linux more」的推薦目錄:
- 關於linux more 在 矽谷牛的耕田筆記 Facebook 的最讚貼文
- 關於linux more 在 矽谷牛的耕田筆記 Facebook 的最讚貼文
- 關於linux more 在 iThome Facebook 的最讚貼文
- 關於linux more 在 MakeLearningFun Youtube 的最佳貼文
- 關於linux more 在 MakeLearningFun Youtube 的最佳貼文
- 關於linux more 在 Shiney Youtube 的最佳貼文
- 關於linux more 在 The 50 Most Popular Linux & Terminal Commands - YouTube 的評價
- 關於linux more 在 More Developers Use Linux than Mac, Report Shows 的評價
- 關於linux more 在 每天一个linux命令(12):more命令 - aimuke 的評價
- 關於linux more 在 Can I have a single server listen on more than 65535 ports by ... 的評價
linux more 在 矽谷牛的耕田筆記 Facebook 的最讚貼文
本篇文章是個經驗分享文,作者分享使用 Docker 作為開發環境時值得注意的 Best practices,透過這些經驗分享希望能夠讓開發者少走一些冤枉路。
原文提出了 15 個經驗談,這邊幫大家節錄幾個,有興趣的可以點選原文瞭解更多!
1. One thing at a time
2. Be ephemeral
3. Utilize .dockerignore
4. Less is more
5. Secrets should be secret
6. PID 1 is your birth right
7. Share and Care
8. Vulnerability Scan
9. Tag like you mean it
10. Permissions are costly
11. Source of Truth
12. Always official
13. Don’t include debug
14. Use entry point script smartly
15. Size does matter
One thing at a time
建置 Image 的時候專注做好一件事情,每個 Image 應該有一個專心要解決的問題,譬如一個應用程式,一個小工具等。對於 Nginx 這類型的 Image 來說,應該沒有人會期望於裡面看到有 Apache 的應用程式吧?
Be ephemeral
這個主要探討的是該 Image 本身建置時應該要以 stateless 的概念去處理,未來不論是透過 docker 或是 Kubernetes 來管理部署時,Contaienr 都很有機會被重啟,每次的重啟都意味該容器是重新啟動。所以千萬不要讓你的 Image 變成多次重啟會導致應用程式出問題的形式,任何的這類型資料應該都要透過外部取得,不要塞到你的 Image 內
Utilize .dockerignore
善用 .dockerignore 這個檔案來將不必要的檔案從 build 過程給排除,使用方法與 .gitignore 類似。透過這個檔案的設定可以避免 docker build 的時候不會把一些過大或是完全不需要的檔案都送給 docker daemon,不當浪費時間也浪費空間。
Less is more
避免安裝任何無關或是非必要的套件到你的 image 中,特別是那些 "nice to have" 的理由。
註: 我個人是滿討厭把 Image 弄得很乾淨的,除錯什麼工具都沒有,連 ash/sh/busybox/bash 都沒有的 image 更是我討厭中的排行榜冠軍
Secrets should be secret
任何機密資訊都應該要於運行期間動態載入,而不是建置期間塞入。請使用其他工具譬如 Vault 來管理這些機密資訊,並且執行期間讓 Container 能夠存取到正確的值。
PID 1 is your birth right
Linux 環境下會使用 SIGTERN, SIGKILL 等相關的 Singal 來戳你的應用程式,請確保你運行的應用程式要能夠攔截這些訊號來處理並完成有效的 Graceful shutdown.
Share and Care
如果環境中有多個 Image 彼此有共享相同的工具與功能,與其每個 Image 都單獨建置維護不如建置一個 Base Image,接者讓所有要使用的 image 去載入使用即可。
透過這種方式可以讓整體的維護性與管理性更為簡單,每個 image 可以減少重複的程式碼,同時要升級時只要針對 base Image 處理即可。
https://medium.com/pradpoddar/avoid-costly-mistakes-using-advanced-docker-development-best-practices-acd812784109
linux more 在 iThome Facebook 的最讚貼文
本周重要新聞彙整在這裡
⭐ Dell將VMware分拆上市
⭐ 臺灣第二家純網銀Line Bank正式對外展開營運
⭐ Nvidia跨入AI資安領域推專用框架Morpheus
⭐ Docker Desktop正式支援Apple Silicon
⭐把漏洞導入Linux核心來作實驗,Linux大老封殺明尼蘇達大學所有貢獻
⭐Visual Studio 2022將在今夏登場
⭐WSL也可以執行Linux GUI應用程式了
#看更多 https://www.ithome.com.tw/news/144015
----------------------------------------------------
◤ 最具指標年度盛事.CYBERSEC 2021 臺灣資安大會 ◢
2,300+ 家企業指定造訪、臺灣唯一超規格資安展會
掌握趨勢、諮詢專家,尋求資安解方的第一首選!
🔴 馬上報名 https://r.itho.me/register
🟢 邀請好友抽 AirPods Pro https://r.itho.me/share
★ 全方位主題論壇 200+ 場專業演說 👑
★ 破 200+ 品牌參展 歷年最大資安展覽 ⛹
★ 佳評如潮 CyberLAB 實機攻防演練 🏆
★ 獨門 CYBERSEC Playground 資安體驗區 🃏
★ 臺灣資安館 看見 MIT 自主研發實力 👊
★ CyberTalent Connect 資安新鮮人才專區 🙋
★ 票選最受歡迎 Tech Demo Award 拿大獎 📣
… and more!
🔵 鎖定大會動態 https://r.itho.me/CYBERSEC_2021
🔴 免費參加 https://r.itho.me/signup
________________________________
CYBERSEC 2021 臺灣資安大會
時間:5 月 4 - 6 日
地點:臺北南港展覽二館
#TRUST_redefined #信任重構
#CYBERSEC2021 #2021臺灣資安大會
#CYBERSECEXPO #臺灣資安大展 #資安 #iThomeSecurity
linux more 在 MakeLearningFun Youtube 的最佳貼文
Programming become more and more important nowadays. Some people may think it is different to learn, but actually it is not! With the right tools and resources, we believe every one can learn programming!
In this video, we explain hello world c++ program in detail such as iostream,
cout, less than operators, end , main function and return value of the program.
We also demonstration how the compiler can help us and some experiments about the return value.
If you want to watch more video from us, please
-do subscribe us!
-like the video and share to you friend who have kid on the facebook, tweeter, google+....etc
how to learn math
https://www.youtube.com/playlist?list...
stem projects
https://www.youtube.com/playlist?list...
Anpanman Educational Toys
https://www.youtube.com/playlist?list...
Learn Shapes for kids
https://www.youtube.com/playlist?list...
Learn letter A to Z
https://www.youtube.com/playlist?list...
Learn names of fruits and vegetables
https://www.youtube.com/playlist?list...
Learning street vehicles names and vehicle sounds
https://www.youtube.com/playlist?list...
Learn names of animal with animal sound
https://www.youtube.com/playlist?list...
linux more 在 MakeLearningFun Youtube 的最佳貼文
Programming become more and more important nowadays. Some people may think it is different to learn, but actually it is not! With the right tools and resources, we believe every one can learn programming!
Linux is a popular operating system which is widely used in the world. It is free and open source, we develop our first c++ hello world program on top of it. Linux become user friendly in recent years, but here is a lot of people asking how to learn, hence we address some linux fundamental here as well.
In this video, we briefly talk about the fundamental of linux, terminal, shell commands and process id's concept, it is for beginner level, hope you will enjoy it.
If you want to watch more video from us, please
-do subscribe us!
-like the video and share to you friend who have kid on the facebook, tweeter, google+....etc
how to learn math
https://www.youtube.com/playlist?list...
stem projects
https://www.youtube.com/playlist?list...
Anpanman Educational Toys
https://www.youtube.com/playlist?list...
Learn Shapes for kids
https://www.youtube.com/playlist?list...
Learn letter A to Z
https://www.youtube.com/playlist?list...
Learn names of fruits and vegetables
https://www.youtube.com/playlist?list...
Learning street vehicles names and vehicle sounds
https://www.youtube.com/playlist?list...
Learn names of animal with animal sound
https://www.youtube.com/playlist?list...
linux more 在 Shiney Youtube 的最佳貼文
Borderlands: The Pre-Sequel is an action role-playing first-person shooter video game developed by 2K Australia, with assistance from Gearbox Software and published by 2K Games. It is the third game in the Borderlands series, and is set after 2009's Borderlands and before 2012's Borderlands 2. It was released for Microsoft Windows, OS X, Linux, PlayStation 3 and Xbox 360 on 14 October 2014. PlayStation 4 and Xbox One ports were released as part of Borderlands: The Handsome Collection on 24 March 2015.
The storyline of The Pre-Sequel focuses on Jack, an employee of the Hyperion corporation; after the company's Helios space station is captured by a military unit known as the Lost Legion, he leads a group of four Vault Hunters—all of whom were non-playable characters and bosses in previous Borderlands games—on an expedition to re-gain control of Helios, defeat the Lost Legion, and find the hidden vault on Pandora's moon Elpis. The game expands upon the engine and gameplay of Borderlands 2 and introduced gameplay mechanics, including low-gravity environments, freeze weapons, and oxygen tanks, which are used to navigate and perform ground slamming attacks.
The Pre-Sequel received positive reviews; while praised for its new gameplay features, character classes, and for maintaining the trademark humour and style of previous entries in the franchise with an additional Australian comedy flair, the game was criticized by some for having confusing level designs, and for not providing many significant deviations from the core mechanics and gameplay of Borderlands 2 to make the game more than simply a standalone "expansion pack" for it.
ช่อง
Au Awesome : https://www.youtube.com/channel/UCI9X...
MangGucci https://www.youtube.com/channel/UC2kE...
Dosanga https://www.youtube.com/channel/UCgSJ...
linux more 在 More Developers Use Linux than Mac, Report Shows 的推薦與評價
The 2022 StackOverflow developer survey shows that more developers use Linux than Mac. And while Windows remains the most used platform with ... ... <看更多>
linux more 在 每天一个linux命令(12):more命令 - aimuke 的推薦與評價
more 命令,功能类似cat ,cat命令是整个文件的内容从上到下显示在屏幕上。 more会以一页一页的显示方便使用者逐页阅读,而最基本的指令就是按空白 ... ... <看更多>
linux more 在 The 50 Most Popular Linux & Terminal Commands - YouTube 的推薦與評價
Learn the 50 most popular Linux commands from Colt Steele. All these commands work on Linux, macOS, WSL, and anywhere you have a UNIX ... ... <看更多>