คำสั่ง pwd

pwd
pwd

คำสั่ง pwd ย่อมาจากคำว่า print working directory คือ คำสั่งแสดงชื่อไดเรกทรอรี่ปัจจุบัน ว่ากำลังทำงานอยู่ที่ไดเรกทรอรี่ใด เป็นคำสั่งที่มีใน shell พื้นฐาน จึงมีทั้งใน sh (Bourne shell 1977) และ bash (Basic Shell 1989)     ..
pwd – print name of current/working directory
Print the full filename of the current working directory.

การแสดงชื่อไดเรกทรอรี่ปัจจุบัน มีความจำเป็นอย่างมาก ถ้าต้องเปิดพร้อมกันหลาย terminal เพราะคำสั่งที่จะเรียกใช้ได้ต้องอยู่ใน working directory จึงต้องมั่นใจว่าอยู่ในห้องที่ถูกต้อง เช่นห้อง /var/log /etc /home /bin ล้วนมีแฟ้มที่ต้องให้ดำเนินการแตกต่างกันไป
นอกจากวิธีนี้แล้ว ยังสามารถใช้คำสั่ง $export PS1=.. เพื่อเปลี่ยน prompt string ของ shell เพื่อแสดง working directory หรือข้อมูลอื่นได้โดยสะดวก

Author: บุรินทร์ รุจจนพันธุ์

I am Lecturer, Developer, Researcher, Columnist, Writer, Photographer, and Webmaster - L@mpang man

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.