บทนำ
ปลดล็อกศักยภาพสูงสุดของระบบ Linux ของคุณด้วยคำแนะนำที่ครอบคลุมเกี่ยวกับคำสั่ง Linux ที่จำเป็น ไม่ว่าคุณจะเป็นผู้ดูแลระบบที่มีประสบการณ์หรือเพิ่งเริ่มต้น การเรียนรู้คำสั่งเหล่านี้อย่างเชี่ยวชาญเป็นสิ่งสำคัญสำหรับการจัดการเซิร์ฟเวอร์ การเขียนสคริปต์ และการแก้ไขปัญหาที่มีประสิทธิภาพ ในบทช่วยสอนนี้ คุณจะได้เรียนรู้คำสั่งที่ใช้บ่อยและทรงพลังที่สุดสำหรับการจัดการไฟล์ การควบคุมกระบวนการ การเข้าถึงของผู้ใช้ การกำหนดค่าเครือข่าย และการดีบักระบบ
คุณจะได้เรียนรู้ คำสั่ง Linux ที่ต้องรู้มากกว่า 50 คำสั่ง ที่จะเปลี่ยนคุณให้เป็นผู้ใช้ระดับสูงของ Linux ตั้งแต่ขั้นพื้นฐานไปจนถึงขั้นสูง คำสั่งเหล่านี้จะกลายเป็นเครื่องมือที่คุณใช้งานสะดวกสำหรับจัดการกับงานใดๆ ที่เข้ามาขวางทางคุณ
ประเด็นสำคัญ
- คำสั่ง Linux ได้รับการจัดระเบียบตามวัตถุประสงค์:การจัดการไฟล์ (
02,14รหัส> ,26รหัส> ,30รหัส> ) การควบคุมกระบวนการ (43,50รหัส> ,68รหัส> ) สิทธิ์ของผู้ใช้ (73,87รหัส> ,97รหัส> ) และเครือข่าย (102,119รหัส> ,122รหัส> ). 130รหัส> command จัดเตรียมเอกสารประกอบในตัวสำหรับคำสั่ง Linux ใดๆ และเป็นข้อมูลอ้างอิงหลักเมื่อคุณต้องการรายละเอียดไวยากรณ์หรือตัวเลือก- ใช้
140เพื่อค้นหาข้อความหรือไฟล์155/160รหัส> เพื่อดูตัวอย่างเนื้อหาไฟล์และ173/181รหัส> เพื่อเปรียบเทียบไฟล์ - สิทธิ์ของไฟล์ได้รับการจัดการด้วย
195(เปลี่ยนบิตของโหมด) และ204(เปลี่ยนเจ้าของ) ซึ่งมีความสำคัญต่อการรักษาความปลอดภัยเซิร์ฟเวอร์และการควบคุมการเข้าถึง - คำสั่งเช่น
219,223รหัส> และ238จัดการการเก็บถาวรและการบีบอัด246รหัส> และ255จัดการการเข้าถึงระยะไกลและการถ่ายโอนไฟล์อย่างปลอดภัย - คำสั่งการจัดการกระบวนการ (
268,271รหัส> ,284รหัส> ,298รหัส> ) เป็นสิ่งจำเป็นสำหรับการตรวจสอบความสมบูรณ์ของระบบและยุติกระบวนการที่ไม่ตอบสนอง
ข้อกำหนดเบื้องต้น
เราจะเรียกใช้คำสั่งเหล่านี้บนเซิร์ฟเวอร์ Ubuntu แต่คุณสามารถปฏิบัติตามได้ในการกระจาย Linux สมัยใหม่ คุณสามารถตั้งค่าเซิร์ฟเวอร์ Ubuntu สำหรับบทช่วยสอนนี้ได้โดยทำตามคำแนะนำในการตั้งค่าเซิร์ฟเวอร์เริ่มต้นบน Ubuntu
ปรับใช้แอปพลิเคชันส่วนหน้าของคุณจาก GitHub โดยใช้แพลตฟอร์มแอป DigitalOcean ให้ DigitalOcean มุ่งเน้นไปที่การปรับขนาดแอปของคุณ
มาเริ่มกันเลย!
คำสั่ง Linux 50 อันดับแรกที่คุณต้องรู้จักในฐานะผู้ใช้ทั่วไป
- LS - คำสั่งที่ใช้บ่อยที่สุดใน Linux เพื่อแสดงรายการไดเร็กทอรี
- กรุณา - พิมพ์คำสั่งไดเร็กทอรีการทำงานใน Linux
- ซีดี - คำสั่ง Linux เพื่อนำทางไปยังไดเร็กทอรี
- mkdir - คำสั่งที่ใช้สร้างไดเร็กทอรีใน Linux
- เอ็มวี - ย้ายหรือเปลี่ยนชื่อไฟล์ใน Linux
- ซีพี - การใช้งานคล้ายกับ mv แต่สำหรับการคัดลอกไฟล์ใน Linux
- อาร์ม - ลบไฟล์หรือไดเร็กทอรี
- สัมผัส - สร้างไฟล์เปล่า/ว่างเปล่า
- อิน - สร้างลิงก์สัญลักษณ์ (ทางลัด) ไปยังไฟล์อื่น
- ชัดเจน - ล้างจอแสดงผลเทอร์มินัล
- แมว - แสดงเนื้อหาไฟล์บนเทอร์มินัล
- เอคโค - พิมพ์ข้อความใดๆ ที่เป็นไปตามคำสั่ง
- น้อยลง - คำสั่ง Linux เพื่อแสดงเอาต์พุตเพจในเทอร์มินัล
- มนุษย์ - เข้าถึงหน้าคู่มือสำหรับคำสั่ง Linux ทั้งหมด
- อูเมะ - คำสั่ง Linux เพื่อรับข้อมูลพื้นฐานเกี่ยวกับระบบปฏิบัติการ
- โฮอามิ - รับชื่อผู้ใช้ที่ใช้งานอยู่
- ทาร์ - คำสั่งให้แยกและบีบอัดไฟล์ใน linux
- เกรป - ค้นหาสตริงภายในเอาต์พุต
- หัว - กลับตามจำนวนบรรทัดที่ระบุจากด้านบน
- หาง - กลับตามจำนวนบรรทัดที่ระบุจากด้านล่าง
- แตกต่าง - ค้นหาความแตกต่างระหว่างสองไฟล์
- ซีเอ็มพี - ช่วยให้คุณตรวจสอบว่าสองไฟล์เหมือนกันหรือไม่
- การสื่อสาร - รวมฟังก์ชันการทำงานของ diff และ cmp
- เรียงลำดับ - คำสั่ง Linux เพื่อจัดเรียงเนื้อหาของไฟล์ขณะส่งออก
- ส่งออก - ส่งออกตัวแปรสภาพแวดล้อมใน Linux
- ซิป - ไฟล์ ZIP ใน Linux
- แตกไฟล์ - แตกไฟล์ใน Linux
- ssh - คำสั่ง Secure Shell ใน Linux
- บริการ - คำสั่ง Linux เพื่อเริ่มและหยุดบริการ
- ปล. - แสดงกระบวนการที่ใช้งานอยู่
- ฆ่าและฆ่าทั้งหมด - ฆ่ากระบวนการที่ใช้งานอยู่ด้วย ID หรือชื่อกระบวนการ
- df - แสดงข้อมูลระบบไฟล์ของดิสก์
- เมานต์ - ติดตั้งระบบไฟล์ใน Linux
- ชโมด - คำสั่งเปลี่ยนการอนุญาตไฟล์
- ชอว์น - คำสั่งให้สิทธิ์การเป็นเจ้าของไฟล์หรือโฟลเดอร์
- ถ้ากำหนดค่า - แสดงอินเทอร์เฟซเครือข่ายและที่อยู่ IP
- ตัวติดตาม - ติดตามการกระโดดเครือข่ายทั้งหมดเพื่อไปยังปลายทาง
- เริ่มต้น - ดาวน์โหลดไฟล์โดยตรงจากอินเทอร์เน็ต
- ยูเอฟดับเบิลยู - คำสั่งไฟร์วอลล์
- ไอพีเทเบิล - ไฟร์วอลล์พื้นฐานสำหรับยูทิลิตี้ไฟร์วอลล์อื่นๆ ทั้งหมดที่จะเชื่อมต่อกับ
- ฉลาด แพคแมน ยำ รอบต่อนาที - ผู้จัดการแพ็คเกจขึ้นอยู่กับการแจกจ่าย
- ซูโดะ - คำสั่งเพื่อเพิ่มสิทธิ์ใน Linux
- แคลอรี - ดูปฏิทินบรรทัดคำสั่ง
- นามแฝง - สร้างทางลัดแบบกำหนดเองสำหรับคำสั่งที่คุณใช้เป็นประจำ
- วว - ใช้เป็นหลักในการสร้างแท่ง USB ที่สามารถบู๊ตได้
- อยู่ที่ไหน - ค้นหาไบนารี แหล่งที่มา และหน้าคู่มือสำหรับคำสั่ง
- คืออะไร - ค้นหาว่าคำสั่งใช้ทำอะไร
- ด้านบน - ดูกระบวนการที่ใช้งานอยู่พร้อมกับการใช้งานระบบ
- ผู้ใช้เพิ่ม และ usermod - เพิ่มผู้ใช้ใหม่หรือเปลี่ยนแปลงข้อมูลผู้ใช้ที่มีอยู่
- รหัสผ่าน - สร้างหรืออัปเดตรหัสผ่านสำหรับผู้ใช้ที่มีอยู่
คำสั่งไฟล์และไดเร็กทอรี
305 ไดเร็กทอรี cdChange.317 pwdShow ไดเรกทอรีปัจจุบัน322 mkdirสร้างไดเรกทอรีใหม่331 rmdirRemove ไดเร็กทอรีว่าง 347 rmDelete ไฟล์หรือไดเร็กทอรี 357 touchสร้างไฟล์ว่าง363 cpCopy ไฟล์หรือไดเร็กทอรี377 mvย้ายหรือเปลี่ยนชื่อไฟล์388 catDisplay เนื้อหาไฟล์390 ไฟล์ nano / vimEdit ในเทอร์มินัล 408 findSearch ค้นหาไฟล์ในลำดับชั้นไดเรกทอรี414 ข้อความ grepSearch โดยใช้รูปแบบ425 tarArchive และบีบอัดไฟล์436 dfShow การใช้ดิสก์ของระบบไฟล์445 duShow ไดเร็กทอรี/ขนาดไฟล์456 chmodChange การอนุญาตของไฟล์461 chownChange เจ้าของไฟล์ 472 เมานต์เมานต์ระบบไฟล์483 umountถอนติดตั้งระบบไฟล์499 คำสั่งเครือข่าย
502 ifconfig / ip aDisplay อินเทอร์เฟซเครือข่าย511 หรือ 525รหัส> netstat / ssShow การเชื่อมต่อเครือข่าย535 หรือ 546 wgetดาวน์โหลดไฟล์ผ่าน HTTP/FTP554 curlถ่ายโอนข้อมูลโดยใช้ไวยากรณ์ URL569 nc (Netcat) การดีบักเครือข่ายและการถ่ายโอนข้อมูล 572 tcpdumpจับและวิเคราะห์แพ็กเก็ตเครือข่าย581 iptablesกำหนดค่ากฎไฟร์วอลล์597 Tracerouteติดตามแพ็กเก็ตเส้นทางที่นำไปใช้กับโฮสต์เครือข่าย604 nslookupQuery DNS เพื่อรับชื่อโดเมนหรือการจับคู่ที่อยู่ IP614 sshเชื่อมต่อกับโฮสต์ระยะไกลอย่างปลอดภัย628 คำสั่งการตรวจสอบกระบวนการและระบบ
คำสั่ง คำอธิบาย คำสั่งตัวอย่าง หัว> psShow กระบวนการที่กำลังทำงานอยู่634 โปรแกรมดูกระบวนการ topDynamic645 htopEnhanced version of top.657 killส่งสัญญาณไปยังกระบวนการ667 killallKill ประมวลผลตามชื่อ673 uptimeSystem เวลาทำงานและโหลด686 whoamiCurrent ผู้ใช้ที่ล็อกอิน691 ตัวแปรสภาพแวดล้อม envDisplay701 การเรียกระบบ straceTrace ของกระบวนการ716 systemctlManage systemd services.728 บันทึกระบบ JournalctlView730 การใช้หน่วยความจำฟรีดิสเพลย์746 vmstatReport สถิติหน่วยความจำเสมือน 759 สถิติ iostatReport CPU และ I/O765 lsofList เปิดไฟล์ตามกระบวนการ770 ข้อความบัฟเฟอร์วงแหวนเคอร์เนล dmesgPrint784 คำสั่งการจัดการผู้ใช้และสิทธิ์
คำสั่ง คำอธิบาย คำสั่งตัวอย่าง หัว> passwdเปลี่ยนรหัสผ่านผู้ใช้799 adduser / useraddเพิ่มผู้ใช้ใหม่804 หรือ 816 deluser / userdelลบผู้ใช้825 หรือ 838 usermodModify บัญชีผู้ใช้845 groupsShow สมาชิกกลุ่ม859 คำสั่ง sudoExecute ในฐานะรูท866 chageเปลี่ยนข้อมูลการหมดอายุของรหัสผ่านผู้ใช้878 ข้อมูลประจำตัวผู้ใช้ idDisplay889 newgrpเข้าสู่ระบบกลุ่มใหม่899 คำสั่งการถ่ายโอนไฟล์และการซิงโครไนซ์
คำสั่ง คำอธิบาย คำสั่งตัวอย่าง หัว> scpคัดลอกไฟล์อย่างปลอดภัยบน SSH901 rsync ซิงค์ไฟล์และไดเร็กทอรีอย่างมีประสิทธิภาพ914 ftpTransfer ไฟล์โดยใช้ File Transfer Protocol927 sftp ถ่ายโอนไฟล์อย่างปลอดภัยโดยใช้ SSH File Transfer Protocol938 wgetดาวน์โหลดไฟล์จากเว็บ949 curlโอนข้อมูลจากหรือไปยังเซิร์ฟเวอร์950 คำสั่งการประมวลผลข้อความ
คำสั่ง คำอธิบาย คำสั่งตัวอย่าง หัว> การสแกนและประมวลผล awkPattern965 โปรแกรมแก้ไข sedStream สำหรับการกรอง/แก้ไขข้อความ974 cutRemove หัวข้อออกจากบรรทัดข้อความ980 sortSort บรรทัดข้อความ990 grepSearch สำหรับรูปแบบในข้อความ1006 wcนับคำ บรรทัด และอักขระ1018 pasteMerge บรรทัดของไฟล์1021 เข้าร่วมบรรทัดของสองไฟล์ในฟิลด์ทั่วไป1033 headOutput ส่วนแรกของไฟล์1041 tailOutput ส่วนสุดท้ายของไฟล์1057 ยูทิลิตี้เชลล์และคำสั่งทางลัด
คำสั่ง คำอธิบาย คำสั่งตัวอย่าง หัว> aliasสร้างทางลัดสำหรับคำสั่ง1066 unalias ลบนามแฝงออก1076 historyShow แสดงคำสั่งที่ป้อนไว้ก่อนหน้านี้1086 clearล้างหน้าจอเทอร์มินัล1097 รีบูต รีบูตระบบ 1104 ปิดเครื่อง ปิดระบบ1115 dateDisplay หรือตั้งวันที่และเวลาของระบบ1126 echoแสดงบรรทัดข้อความ1130 sleepDelay ตามระยะเวลาที่กำหนด1145 timeMeasure ระยะเวลาของการดำเนินการคำสั่ง1155 watchรันโปรแกรมเป็นระยะ โดยแสดงเอาต์พุตแบบเต็มหน้าจอ1168
ทีนี้มาเจาะลึกแต่ละคำสั่งเหล่านี้ให้ลึกลงไปอีกหน่อยแล้วทำความเข้าใจในรายละเอียดเพิ่มเติม เรามีบทความที่มีอยู่มากมายสำหรับแต่ละคำสั่งเหล่านั้นแล้ว เพื่อความสะดวกของคุณ เราจะเพิ่มลิงก์ไปยังบทความที่มีอยู่ทั้งหมด และอัปเดตบทความต่อไปเมื่อมีหัวข้อใหม่ครอบคลุม
1176รหัส> คำสั่งใน Linux
1186รหัส> คำสั่งใช้เพื่อแสดงรายการไฟล์และไดเร็กทอรีในไดเร็กทอรีการทำงานปัจจุบัน นี่จะเป็นหนึ่งในคำสั่ง Linux ที่ใช้บ่อยที่สุดที่คุณต้องรู้

ดังที่คุณเห็นในภาพด้านบน การใช้คำสั่งเพียงอย่างเดียวโดยไม่มีข้อโต้แย้งใดๆ จะทำให้เราได้ผลลัพธ์พร้อมไฟล์และไดเร็กทอรีทั้งหมดในไดเร็กทอรี คำสั่งให้ความยืดหยุ่นอย่างมากในแง่ของการแสดงข้อมูลในเอาต์พุต
เรียนรู้เพิ่มเติมเกี่ยวกับการใช้ 1195 คำสั่ง
ข้ามกลับไปที่รายการคำสั่ง ↑
1200รหัส> คำสั่งใน Linux
1215รหัส> คำสั่งอนุญาตให้คุณพิมพ์ไดเร็กทอรีการทำงานปัจจุบันบนเทอร์มินัลของคุณ มันเป็นคำสั่งพื้นฐานมากและแก้ไขวัตถุประสงค์ได้เป็นอย่างดี

ตอนนี้พรอมต์เทอร์มินัลของคุณควรมีไดเร็กทอรีที่สมบูรณ์อยู่แล้ว แต่ในกรณีที่ไม่เป็นเช่นนั้น นี่อาจเป็นคำสั่งด่วนเพื่อดูไดเร็กทอรีที่คุณอยู่ แอปพลิเคชันอื่นของคำสั่งนี้คือเมื่อสร้างสคริปต์โดยที่คำสั่งนี้สามารถช่วยให้เราค้นหาไดเร็กทอรีที่สคริปต์ถูกบันทึกไว้
ข้ามกลับไปที่รายการคำสั่ง ↑
1221รหัส> คำสั่งใน Linux
ในขณะที่ทำงานภายใน Terminal การย้ายภายในไดเร็กทอรีถือเป็นสิ่งจำเป็น คำสั่ง cd เป็นหนึ่งในคำสั่ง Linux ที่สำคัญที่คุณต้องรู้ และคำสั่งนี้จะช่วยคุณนำทางไปยังไดเร็กทอรีต่างๆ เพียงพิมพ์ 1231 ตามด้วยไดเร็กทอรี ดังที่แสดงด้านล่าง
root@ubuntu:~# cd <directory path>

อย่างที่คุณเห็นในคำสั่งด้านบน ฉันแค่พิมพ์ 1247 เพื่อเข้าสู่ไดเร็กทอรี /etc เราใช้ 1255 คำสั่งเพื่อพิมพ์ไดเร็กทอรีการทำงานปัจจุบัน
ข้ามกลับไปที่รายการคำสั่ง ↑
1269รหัส> คำสั่งใน Linux
1277รหัส> คำสั่งอนุญาตให้คุณสร้างไดเร็กทอรีจากภายในเทอร์มินัล
root@ubuntu:~# mkdir <folder name>

ดังที่คุณเห็นในภาพหน้าจอด้านบน เราได้สร้างไดเร็กทอรีใหม่ด้วยคำสั่งง่ายๆ นี้
ข้ามกลับไปที่รายการคำสั่ง ↑
1285รหัส> และ 1298 คำสั่ง
1300รหัส> และ 1317 คำสั่งเทียบเท่ากับคำสั่งคัดลอกวางและตัดวางใน Windows แต่เนื่องจาก Linux ไม่มีคำสั่งในการเปลี่ยนชื่อไฟล์จริงๆ เราจึงใช้ 1327 คำสั่งเปลี่ยนชื่อไฟล์และโฟลเดอร์
root@ubuntu:~# cp <source> <destination>

ในคำสั่งข้างต้น เราได้สร้างสำเนาของไฟล์ชื่อ Sample มาดูกันว่าจะเกิดอะไรขึ้นถ้าเราใช้ 1334 คำสั่งในลักษณะเดียวกัน
root@ubuntu:~# mv <source> <destination>

ในกรณีข้างต้น เนื่องจากเรากำลังย้ายไฟล์ภายในไดเร็กทอรีเดียวกัน ไฟล์จึงทำหน้าที่เป็นการเปลี่ยนชื่อ ขณะนี้ชื่อไฟล์มีการเปลี่ยนแปลง
ข้ามกลับไปที่รายการคำสั่ง ↑
1344รหัส> คำสั่งใน Linux
ในส่วนก่อนหน้านี้ เราได้ลบไฟล์ Sample-Copy คำสั่ง rm ใช้เพื่อลบไฟล์และโฟลเดอร์ และเป็นหนึ่งในคำสั่ง Linux ที่สำคัญที่คุณต้องรู้
root@ubuntu:~# rm <file name>

หากต้องการลบไดเรกทอรี คุณต้องเพิ่ม 1359 อาร์กิวเมนต์กับมัน ไม่มี 1361 อาร์กิวเมนต์ 1373 คำสั่งจะไม่ลบไดเร็กทอรี
root@ubuntu:~# rm -r <folder/directory name>
1389รหัส> ตั้งค่าสถานะใน 1393 คำสั่งใน Linux ย่อมาจาก “recursive ". เมื่อใช้ร่วมกับ 1409 คำสั่ง มันจะลบไม่เฉพาะไฟล์ที่ระบุเท่านั้น แต่ยังลบไดเร็กทอรีย่อยทั้งหมดและไฟล์ภายในไดเร็กทอรีย่อยเหล่านั้นแบบวนซ้ำ
หมายเหตุ: สิ่งสำคัญคือต้องระมัดระวังเมื่อใช้ 1413 คำสั่งด้วย 1427 เนื่องจากสามารถลบไฟล์และไดเร็กทอรีจำนวนมากได้อย่างรวดเร็วและถาวร เป็นความคิดที่ดีที่จะใช้ 1439 ตั้งค่าสถานะร่วมกับ 1447 ซึ่งจะแจ้งให้คุณยืนยันก่อนที่จะลบแต่ละไฟล์และไดเร็กทอรี
ตัวอย่างเช่น หากต้องการลบ 1456 ไดเร็กทอรีและเนื้อหาพร้อมการยืนยัน คุณสามารถใช้คำสั่งนี้:
root@ubuntu:~# rm -ri mydir
ระบบจะแจ้งให้คุณยืนยันก่อนที่จะลบแต่ละไฟล์และไดเร็กทอรีภายใน 1465 ไดเร็กทอรี
ข้ามกลับไปที่รายการคำสั่ง ↑
1479รหัส> คำสั่งใน Linux
1488รหัส> คำสั่งใน Linux จะสร้างไฟล์เปล่าหรืออัพเดตการประทับเวลาของไฟล์ที่มีอยู่
root@ubuntu:~# touch <file name>

ข้ามกลับไปที่รายการคำสั่ง ↑
1492รหัส> คำสั่งใน Linux
หากต้องการสร้างลิงก์ไปยังไฟล์อื่น เราใช้ 1509 คำสั่ง นี่เป็นหนึ่งในคำสั่ง Linux ที่สำคัญที่สุดที่คุณควรรู้หากคุณวางแผนที่จะทำงานเป็นผู้ดูแลระบบ Linux
root@ubuntu:~# ln -s <source path> <link name>

1511รหัส> ธงสร้าง ลิงก์สัญลักษณ์ (หรือที่เรียกว่า symlink หรือ soft link) ไปยังไฟล์หรือไดเร็กทอรี ลิงก์สัญลักษณ์คือไฟล์ชนิดพิเศษที่ทำหน้าที่เป็นทางลัดหรือตัวชี้ไปยังไฟล์หรือไดเร็กทอรีอื่น
โดยค่าเริ่มต้น 1522 คำสั่งจะสร้าง ฮาร์ดลิงก์ แทนสัญลักษณ์หรือซอฟต์ลิงก์
หมายเหตุ: สมมติว่าคุณมีไฟล์ข้อความ หากคุณสร้าง ลิงก์สัญลักษณ์ ไปยังไฟล์นั้น ลิงก์จะเป็นเพียงตัวชี้ไปยังไฟล์ต้นฉบับเท่านั้น หากคุณลบไฟล์ต้นฉบับ ลิงก์จะใช้งานไม่ได้ เนื่องจากไม่มีอะไรจะชี้ไปอีกต่อไป
ฮาร์ดลิงก์ เป็นสำเนามิเรอร์ของไฟล์ต้นฉบับที่มีเนื้อหาเหมือนกันทุกประการ เช่นเดียวกับลิงก์สัญลักษณ์ หากคุณแก้ไขเนื้อหาของไฟล์ต้นฉบับ การเปลี่ยนแปลงเหล่านั้นจะปรากฏในฮาร์ดลิงก์ หากคุณลบไฟล์ต้นฉบับ ฮาร์ดลิงก์จะยังคงใช้งานได้ และคุณสามารถดูและแก้ไขไฟล์ได้เช่นเดียวกับที่คุณทำสำเนาไฟล์ต้นฉบับตามปกติ
เรียนรู้เพิ่มเติมเกี่ยวกับลิงก์แบบซอฟต์และฮาร์ด
ข้ามกลับไปที่รายการคำสั่ง ↑
1532รหัส> คำสั่งใน Linux
1544รหัส> คำสั่งใน Linux จะล้างหน้าจอเทอร์มินัล โดยจะลบข้อความและเอาต์พุตทั้งหมดที่แสดงบนเทอร์มินัลในปัจจุบัน และช่วยให้คุณมีขั้นตอนการทำงานที่ชัดเจน
นี่คือตัวอย่างวิธีใช้ 1557 คำสั่ง:
root@ubuntu:~# clear
การดำเนินการนี้จะล้างหน้าจอเทอร์มินัลและเลื่อนเคอร์เซอร์ไปที่มุมซ้ายบนของหน้าจอ
คุณยังสามารถใช้ 1567 คำสั่งร่วมกับคำสั่งอื่นๆ เช่น:
root@ubuntu:~# ls -l; clear
ซึ่งจะแสดงรายการไฟล์และไดเร็กทอรีในไดเร็กทอรีปัจจุบัน จากนั้นล้างหน้าจอเทอร์มินัล
หมายเหตุ: 1572รหัส> คำสั่งจะไม่ลบไฟล์หรือข้อมูลใด ๆ ออกจากระบบของคุณ จะส่งผลต่อการแสดงผลของเทอร์มินัลเท่านั้น
1582รหัส> , 1594รหัส> และ 1608 คำสั่ง
เมื่อคุณต้องการส่งออกเนื้อหาของไฟล์หรือพิมพ์สิ่งใด ๆ ไปยังเทอร์มินัลเอาต์พุต เราจะใช้ 1615 หรือ 1620รหัส> คำสั่ง มาดูการใช้งานพื้นฐานกันดีกว่า
root@ubuntu:~# cat <file name>
root@ubuntu:~# echo <Text to print on terminal>

ดังที่คุณเห็นในตัวอย่างข้างต้น 1633 คำสั่งเมื่อใช้กับ 1649 ของเรา , พิมพ์เนื้อหาของไฟล์ ขณะเดียวกันเมื่อเราใช้ 1651 คำสั่ง เพียงพิมพ์สิ่งต่อไปนี้หลังจากคำสั่ง
1664รหัส> คำสั่งจะใช้เมื่อเอาต์พุตที่พิมพ์โดยคำสั่งใดๆ มีขนาดใหญ่กว่าพื้นที่หน้าจอและจำเป็นต้องเลื่อน 1676รหัส> คำสั่งอนุญาตให้ผู้ใช้แยกย่อยเอาต์พุตและเลื่อนดูโดยใช้ปุ่ม Enter หรือเว้นวรรค
วิธีง่ายๆ ในการทำเช่นนี้คือการใช้ตัวดำเนินการไปป์ (1684 ).
root@ubuntu:~# cat /boot/grub/grub.cfg | less
หมายเหตุ: ใช้ 1690 ตั้งค่าสถานะด้วย 1709 เพื่อเปิดใช้งานการตัดบรรทัด ซึ่งจะทำให้คุณสามารถดูข้อความเป็นบรรทัดยาวๆ โดยไม่ต้องเลื่อนในแนวนอน
ใช้ 1719 ตั้งค่าสถานะด้วย 1729 เพื่อแสดงหมายเลขบรรทัด สิ่งนี้มีประโยชน์เมื่อคุณต้องการทราบหมายเลขบรรทัดของข้อความเฉพาะ
คุณสามารถใช้แฟล็กที่เป็นประโยชน์เหล่านี้ได้ในลักษณะต่อไปนี้:
root@ubuntu:~# cat /boot/grub/grub.cfg | less -SN
ใช้ 1730 ด้วยตัวดำเนินการท่อจะมีประโยชน์ในหลาย ๆ สถานการณ์ นี่เป็นตัวอย่างบางส่วน:
- การดูเอาต์พุตของคำสั่งที่ใช้เวลานาน เช่น
1747 หรือ 1756 .
- การค้นหาข้อความเฉพาะในผลลัพธ์ของคำสั่ง เช่น
1767 หรือ 1773 .
ข้ามกลับไปที่รายการคำสั่ง ↑
1788รหัส> คำสั่งใน Linux
1795รหัส> command เป็นคำสั่ง Linux ที่มีประโยชน์มากที่ต้องรู้ เมื่อทำงานกับ Linux แพ็คเกจที่เราดาวน์โหลดอาจมีฟังก์ชันมากมาย การรู้ทุกอย่างเป็นไปไม่ได้
1808รหัส> คำสั่งใน Linux ใช้เพื่อแสดงหน้าคู่มือสำหรับคำสั่งเฉพาะ โดยให้ข้อมูลโดยละเอียดเกี่ยวกับคำสั่ง รวมถึงไวยากรณ์ ตัวเลือก และตัวอย่าง
นี่คือตัวอย่างวิธีใช้ 1819 คำสั่ง:
- เปิดเทอร์มินัลแล้วพิมพ์
1820 เพื่อแสดงหน้าคู่มือสำหรับ 1838 คำสั่ง
root@ubuntu:~# man ls
นี่จะแสดงหน้าที่มีลักษณะดังนี้:
LS(1) User Commands LS(1)
NAME
ls - list directory contents
SYNOPSIS
ls [OPTION]... [FILE]...
DESCRIPTION
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
Mandatory arguments to long options are mandatory for short options too.
-a, --all
do not ignore entries starting with .
-A, --almost-all
do not list implied . and ..
-c with -lt: sort by, and show, ctime (time of last modification
of file status information) with -l: show ctime and sort
by name;
...
ข้ามกลับไปที่รายการคำสั่ง ↑
1843รหัส> และ 1858รหัส> คำสั่ง
1864รหัส> และ 1871 คำสั่งช่วยให้คุณเข้าถึงข้อมูลพื้นฐานบางอย่างที่มีประโยชน์เมื่อคุณทำงานกับหลายระบบ
1880 คำสั่งใน Linux จะแสดงข้อมูลเกี่ยวกับเคอร์เนลของระบบ รวมถึงชื่อเคอร์เนล ชื่อโฮสต์ รุ่นเคอร์เนล เวอร์ชันเคอร์เนล และชื่อฮาร์ดแวร์ของเครื่อง
1898รหัส> คำสั่งใน Linux ส่งคืนชื่อผู้ใช้ของผู้ใช้ปัจจุบัน ย่อมาจาก “ฉันเป็นใคร” และมักใช้เพื่อระบุตัวตนของผู้ใช้ปัจจุบันในเชลล์สคริปต์หรือเทอร์มินัล
มาดูผลลัพธ์ของทั้งคำสั่งและวิธีการใช้งานกันดีกว่า
root@ubuntu:~# uname -a

พารามิเตอร์ 1902 ด้วย 1910 คำสั่งย่อมาจาก “ทั้งหมด” เพื่อพิมพ์ข้อมูลที่ครบถ้วน หากไม่ได้เพิ่มพารามิเตอร์ สิ่งที่คุณจะได้รับเมื่อเอาต์พุตคือ “Linux”
หมายเหตุ: ธงสำคัญบางอย่างที่คุณสามารถใช้กับ 1928 คำสั่ง
- ใช้
1931 เพื่อแสดงชื่อเคอร์เนล
- ใช้
1943 เพื่อแสดงชื่อโฮสต์
- ใช้
1950 เพื่อแสดงการเผยแพร่เคอร์เนล
- ใช้
1960 เพื่อแสดงเวอร์ชันเคอร์เนล
- ใช้
1977 เพื่อแสดงชื่อฮาร์ดแวร์ของเครื่อง
ข้ามกลับไปยังรายการคำสั่ง ↑
1985 , 1990รหัส> และ 2004 คำสั่ง
2017 คำสั่งใน Linux ใช้เพื่อสร้างและแยกไฟล์ที่เก็บถาวร เราสามารถแยกไฟล์เก็บถาวรหลายไฟล์ได้โดยใช้ 2029 คำสั่ง
ในการสร้างไฟล์เก็บถาวร เราใช้ 2036 พารามิเตอร์ และในการแยกไฟล์เก็บถาวร เราใช้ 2049 พารามิเตอร์ มาดูกันว่ามันทำงานอย่างไร
#Compress
root@ubuntu:~# tar -cvf <archive name> <files separated by space>
#Extract
root@ubuntu:~# tar -xvf <archive name>

ในบรรทัดแรก เราได้สร้างไฟล์เก็บถาวรชื่อ Compress.tar ด้วย New-File และ New-File-Link ในคำสั่งถัดไป เราได้แยกไฟล์เหล่านั้นออกจากไฟล์เก็บถาวรแล้ว
มาหารือเกี่ยวกับ 2056 กัน และ 2067 คำสั่ง ทั้งสองตรงไปตรงมามาก คุณสามารถใช้มันได้โดยไม่ต้องมีพารามิเตอร์ใดๆ และมันจะทำงานได้ตามที่ตั้งใจไว้ มาดูตัวอย่างด้านล่าง
root@ubuntu:~# zip <archive name> <file names separated by space>
root@ubuntu:~# unzip <archive name>

เนื่องจากเรามีไฟล์เหล่านั้นอยู่ในไดเร็กทอรีเดียวกันแล้ว 2072 คำสั่งจะแจ้งเราก่อนที่จะเขียนทับไฟล์เหล่านั้น
ข้ามกลับไปที่รายการคำสั่ง ↑
2080รหัส> คำสั่งใน Linux
2099รหัส> command เป็นเครื่องมือค้นหาข้อความที่ทรงพลังและอเนกประสงค์ในระบบปฏิบัติการ Linux และ Unix สามารถค้นหารูปแบบหรือสตริงเฉพาะในไฟล์ตั้งแต่หนึ่งไฟล์ขึ้นไปและกรองเอาต์พุตของคำสั่งอื่น
2108รหัส> คำสั่งย่อมาจาก "การพิมพ์นิพจน์ทั่วไปทั่วโลก" ซึ่งสะท้อนถึงความสามารถในการค้นหานิพจน์ทั่วไปในหลายบรรทัดและไฟล์
root@ubuntu:~# <Any command with output> | grep "<string to find>"

นี่เป็นการสาธิตคำสั่งอย่างง่าย เรียนรู้เพิ่มเติมเกี่ยวกับคำสั่ง grep
ข้ามกลับไปที่รายการคำสั่ง ↑
2112รหัส> และ 2121รหัส> คำสั่ง
เมื่อส่งออกไฟล์ขนาดใหญ่ 2136 และ 2140รหัส> คำสั่งมีประโยชน์ คำสั่งเหล่านี้แสดงจุดเริ่มต้นหรือจุดสิ้นสุดของไฟล์ตามลำดับ โดยทั่วไปจะใช้เพื่อดูเนื้อหาของไฟล์อย่างรวดเร็วโดยไม่ต้องเปิดในโปรแกรมแก้ไขข้อความ
2154รหัส> และ 2166 คำสั่งจะแสดง 10 บรรทัดแรกของไฟล์ตามค่าเริ่มต้น หากต้องการแสดงจำนวนบรรทัดที่แตกต่างกัน คุณสามารถใช้ 2175 ตามด้วยจำนวนบรรทัดที่คุณต้องการแสดง
นี่คือตัวอย่างการใช้ 2187 และ 2198 คำสั่ง:
root@ubuntu:~# head <file name>
root@ubuntu:~# tail <file name>

อย่างที่คุณเห็น คำสั่ง head แสดง 10 บรรทัดจากด้านบนของไฟล์

คำสั่ง tail ส่งออก 10 บรรทัดล่างสุดจากไฟล์
คำสั่งเหล่านี้สามารถใช้เพื่อดูเนื้อหาของไฟล์ได้อย่างรวดเร็ว ตรวจสอบการอัปเดตแบบเรียลไทม์สำหรับการแก้ไขปัญหา กรองเอาต์พุตจากคำสั่งอื่น และดำเนินการวิเคราะห์บันทึก
ข้ามกลับไปที่รายการคำสั่ง ↑
2201รหัส> , 2215รหัส> และ 2225รหัส> คำสั่ง
2237รหัส> , 2249รหัส> และ 2258 คำสั่งทั้งหมดใช้เพื่อเปรียบเทียบไฟล์ในระบบปฏิบัติการที่ใช้ Linux และ Unix คำสั่งเหล่านี้สามารถใช้เพื่อระบุความแตกต่างระหว่างสองไฟล์ รวมการเปลี่ยนแปลง และดำเนินการเปรียบเทียบไฟล์อื่นๆ
root@ubuntu:~# diff <file 1> <file 2>

ดังที่คุณเห็นข้างต้น เราได้เพิ่มข้อความเล็กๆ ที่ระบุว่า "บรรทัดนี้ได้รับการแก้ไขแล้ว" ลงในไฟล์ที่แก้ไขไฟล์ใหม่
2263รหัส> คำสั่งใช้เพื่อเปรียบเทียบสองไฟล์และแสดงไบต์แรกที่แตกต่างกันระหว่างไฟล์เหล่านั้น สามารถใช้เพื่อระบุความแตกต่างระหว่างไฟล์ไบนารีหรือเพื่อตรวจสอบความเสียหายในไฟล์
root@ubuntu:~# cmp <file 1> <file 2>

2276รหัส> คำสั่งบอกเราเพียงหมายเลขบรรทัดซึ่งแตกต่างกัน ไม่ใช่ข้อความจริง
2280รหัส> คำสั่งใช้เพื่อเปรียบเทียบไฟล์ที่เรียงลำดับสองไฟล์และแสดงบรรทัดที่ไม่ซ้ำกันสำหรับแต่ละไฟล์ เช่นเดียวกับบรรทัดที่ใช้ร่วมกันสำหรับทั้งสองไฟล์
root@ubuntu:~# comm <file 1> <file2>

ข้อความที่จัดชิดซ้ายจะปรากฏเฉพาะใน 2294 . ข้อความที่จัดกึ่งกลางจะแสดงเฉพาะใน 2308 . และข้อความที่จัดชิดขวาจะปรากฏในทั้งสองไฟล์
จากรูปลักษณ์ของมัน 2316 คำสั่งเหมาะสมที่สุดเมื่อเราพยายามเปรียบเทียบไฟล์ที่มีขนาดใหญ่กว่าและต้องการเห็นทุกอย่างที่จัดเรียงไว้ด้วยกัน
คำสั่งทั้งสามนี้เป็นเครื่องมือสำคัญสำหรับการทำงานกับไฟล์ในระบบปฏิบัติการ Linux และ Unix โดยทำความเข้าใจการใช้งาน 2324 , 2331รหัส> และ 2342 คำสั่งได้อย่างมีประสิทธิภาพ คุณสามารถระบุความแตกต่างระหว่างไฟล์ รวมการเปลี่ยนแปลง และดำเนินการเปรียบเทียบไฟล์อื่นๆ ได้
คำสั่งเหล่านี้ช่วยให้คุณระบุและแก้ไขปัญหาเกี่ยวกับไฟล์ได้ เช่นเดียวกับการติดตามการเปลี่ยนแปลงและรักษาการควบคุมเวอร์ชัน ไม่ว่าคุณจะเป็นนักพัฒนาหรือผู้ดูแลระบบ คำสั่งเหล่านี้เป็นส่วนสำคัญของชุดเครื่องมือของคุณ
ข้ามกลับไปที่รายการคำสั่ง ↑
2352รหัส> คำสั่งใน Linux
2362รหัส> คำสั่งใช้เพื่อเรียงลำดับบรรทัดในไฟล์ข้อความหรืออินพุตมาตรฐานในระบบปฏิบัติการ Linux และ Unix สามารถใช้เพื่อเรียงลำดับบรรทัดจากน้อยไปมากหรือจากมากไปน้อย และดำเนินการเรียงลำดับอื่นๆ เช่น การเรียงลำดับตามฟิลด์ หรือใช้ลำดับการเรียงลำดับแบบกำหนดเอง
ไวยากรณ์พื้นฐานของ 2373 คำสั่งคือ:
root@ubuntu:~# sort <filename>

ตามค่าเริ่มต้น 2380 คำสั่งเรียงลำดับบรรทัดใน ลำดับการเรียง ASCII ซึ่งอาจนำไปสู่ผลลัพธ์ที่ไม่คาดคิดเมื่อเรียงลำดับตัวเลขหรืออักขระพิเศษ หากต้องการเรียงลำดับตัวเลขตามลำดับตัวเลข คุณสามารถใช้ 2399 ตัวเลือก
นี่คือตัวอย่างการใช้ 2400 ตัวเลือก:
root@ubuntu:~# sort -n file.txt
คำสั่งดังกล่าวจะเรียงลำดับบรรทัดใน 2416 ตามลำดับตัวเลข
2428รหัส> คำสั่งยังสามารถใช้เพื่อเรียงลำดับบรรทัดตามฟิลด์เฉพาะโดยใช้ 2438 ตัวเลือก
นี่คือตัวอย่างการใช้ 2441 ตัวเลือก:
root@ubuntu:~# sort -k 2 file.txt
คำสั่งนี้จะเรียงลำดับบรรทัดใน 2452 ขึ้นอยู่กับฟิลด์ที่สอง
2463รหัส> command เป็นเครื่องมือที่ทรงพลังและยืดหยุ่นสำหรับการทำงานกับไฟล์ข้อความในระบบปฏิบัติการ Linux และ Unix โดยทำความเข้าใจการใช้งาน 2471 คำสั่งอย่างมีประสิทธิภาพ คุณสามารถเรียงลำดับบรรทัดในไฟล์ข้อความ เรียงลำดับบรรทัดตามฟิลด์เฉพาะ และดำเนินการเรียงลำดับอื่นๆ ได้
คำสั่งเหล่านี้สามารถช่วยคุณจัดระเบียบและวิเคราะห์ข้อมูลและดำเนินการจัดการไฟล์อื่นๆ ได้ ไม่ว่าคุณจะเป็นนักพัฒนาหรือผู้ดูแลระบบ 2486 คำสั่งเป็นส่วนสำคัญของชุดเครื่องมือของคุณ
ข้ามกลับไปที่รายการคำสั่ง ↑
2499รหัส> คำสั่งใน Linux
2507รหัส> คำสั่งในระบบปฏิบัติการ Linux และ Unix ใช้เพื่อตั้งค่าตัวแปรสภาพแวดล้อม ตัวแปรสภาพแวดล้อมใช้เพื่อจัดเก็บข้อมูลที่กระบวนการหรือคำสั่งสามารถใช้ได้
เมื่อตั้งค่าตัวแปรสภาพแวดล้อมแล้ว จะสามารถเข้าถึงได้โดยกระบวนการหรือคำสั่งใดๆ ที่ทำงานอยู่ในเชลล์เดียวกัน
ตัวแปรสภาพแวดล้อมสามารถใช้เพื่อจัดเก็บข้อมูลได้หลากหลาย เช่น การตั้งค่าการกำหนดค่า การกำหนดค่าตามความชอบของผู้ใช้ หรือข้อมูลระบบ
นี่คือตัวอย่างการใช้ 2514 คำสั่ง:
root@ubuntu:~# export <variable name>=<value>

เรียนรู้เพิ่มเติมเกี่ยวกับ 2521 คำสั่ง
ข้ามกลับไปที่รายการคำสั่ง ↑
ตัว <โค้ด>2531 คำสั่งใน Linux
2545รหัส> คำสั่งในระบบปฏิบัติการ Linux และ Unix จะสร้างการเชื่อมต่อเชลล์ที่ปลอดภัยไปยังเซิร์ฟเวอร์ระยะไกล คำสั่งนี้ให้การเชื่อมต่อที่เข้ารหัสอย่างปลอดภัยระหว่างเซิร์ฟเวอร์ท้องถิ่นและเซิร์ฟเวอร์ระยะไกล ทำให้ผู้ใช้สามารถรันคำสั่งและถ่ายโอนไฟล์ได้อย่างปลอดภัย
ไวยากรณ์พื้นฐานของ 2551 คำสั่งคือ:
root@ubuntu:~ ssh username@remote-server
คำสั่งนี้สร้าง 2562 การเชื่อมต่อกับ 2574 โดยใช้ 2586 account.
The 2590 command supports a wide range of options and configurations, including:
- Configuring authentication methods (password, public key, etc.)
- Configuring encryption algorithms
- Configuring compression
- Configuring port forwarding
- Configuring X11 forwarding
- Configuring SSH keys
The 2603 command in Linux
The 2610 command in Linux is used to manage system services, which are long-running processes that are started at boot time and run in the background. These services are responsible for providing various system functionalities, such as networking, database management, and user authentication.
The 2628 command is used to start, stop, restart, and check the status of these services. It is a front-end to the 2633 command, which is used to manage the 2647 service manager.
The basic syntax of the command is as below.
root@ubuntu:~ service ssh status
root@ubuntu:~ service ssh stop
root@ubuntu:~ service ssh start

As you can see in the image, the 2657 server is running on our system.
Jump back to commands list ↑
The 2662 , 2679 , and 2682 commands
The 2690 , 2700 , and 2715 commands are all used to manage processes in Linux.
The 2720 command is used to display information about the current running processes on the system. Here are some examples of using the 2733 command:
Display a list of all running processes:
root@ubuntu:~ ps -ef
Display a list of all processes for a specific process ID (PID):
root@ubuntu:~ ps -p PID
Let’s see all of this in action:
root@ubuntu:~ ps
root@ubuntu:~ kill <process ID>
root@ubuntu:~ killall <process name>
For demonstration purposes, we will create a shell script with an infinite loop and will run it in the background.
With the use of the 2741 symbol, we can pass a process into the background. As you can see, a new bash process with PID 14490 is created.

Now, to kill a process with the 2755 command, you can type 2764 followed by the PID(Process Id) of the process.

But if you do not know the process ID and just want to kill the process with the name, you can make use of the killall command.

You will notice that PID 2779 stayed active. That is because, both times, we killed the sleep process.
Learn more about the 2783 command and the 2798 command.
Jump back to commands list ↑
The 2806 and 2815 commands
When working with Linux, the 2828 and 2831 commands are very efficient utilities to mount filesystems and get details of the file system.
The 2844 command is used to display the amount of disk space used and available on the file systems, and the 2858 command is used to mount a file system or device to a specific directory.
When we say 2865 , it means that we’ll connect the device to a folder so we can access the files from our filesystem. The default syntax to mount a filesystem is below:
root@ubuntu:~ mount /dev/cdrom /mnt
root@ubuntu:~ df -h
In the above case, 2877 is the device that needs to be mounted. Usually, a mountable device is found inside the 2882 โฟลเดอร์ 2891 is the destination folder to which to mount the device. You can change it to any folder you want, but we have used 2907 as it’s the system’s default folder for mounting devices.
To see the mounted devices and get more information about them, we use the df command. Just typing 2917 will give us the data in bytes, which is not readable. So, we’ll use the 2923 parameter to make the data human-readable.

Jump back to commands list ↑
The 2937 and 2948 commands
The 2950 and 2968 commands are used to modify file permissions and ownership in Linux.
The 2974 command is used to change the permissions of a file or directory, and the 2985 command is used to change the ownership of a file or directory
The default syntax for both the commands is 2996 and 3005 ป>
root@ubuntu:~ chmod +x loop.sh
root@ubuntu:~ chmod root:root loop.sh

In the above example, we’re adding executable permissions to the 3016 file with the 3021 คำสั่ง In addition, with the 3032 command, we’ve made it accessible only to the root user and users within the root group.

As you will notice, the 3043 part is now changed to 3059 which is the new user who has full file ownership.
Learn more about the Linux file Permissions and using the 3062 command.
Jump back to commands list ↑
The 3071 and 3085 commands
The 3095 and 3106 commands manage network interfaces and trace the route of network packets in Linux.
The 3114 command will give you the list of all the network interfaces along with the IP addresses, MAC addresses and other information about the interface.
root@ubuntu:~ ifconfig
There are multiple parameters that can be used, but we’ll work with the basic command here.

The 3129 command is used to trace the route of network packets and determine the path they take to reach a specific destination.
When working with 3132 , you can simply specify the IP address, hostname, or domain name of the endpoint.
root@ubuntu:~ traceroute <destination address>

Now, obviously, 3141 is just one hop (the network interface itself). You can try this same command with any other domain name or IP address to see all the routers your data packets pass through to reach the destination.
Jump back to commands list ↑
The 3157 command in Linux
If you want to download a file from within the terminal, the 3164 command is one of the handiest command-line utilities available. It is one of the important Linux commands you should know when working with source files.
When you specify the link for download, it has to directly be a link to the file. If the file cannot be accessed by the 3174 command, it will simply download the webpage in HTML format instead of the actual file that you wanted.
Let’s try an example. The basic syntax of the 3188 command is :
root@ubuntu:~ wget <link to file>
Or,
root@ubuntu:~ wget -c <link to file>
The 3194 argument allows us to resume an interrupted download.
Jump back to commands list ↑
The 3205 and 3217 commands
The 3227 and 3233 commands are used to manage firewalls in Linux.
UFW and IPTables are firewall interfaces for the Linux Kernel’s netfilter firewall. IPTables directly passes firewall rules to Netfilter while UFW configures the rules in IPTables, which then sends those rules to Netfilter.
Why do we need UFW when we have IPTables? Because IPTables is pretty difficult for a newbie. UFW makes things extremely easy. See the below example where we are trying to allow port 80 for our webserver.
root@ubuntu:~# iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
root@ubuntu:~# ufw allow 80
I’m sure you now know why UFW was created! Look at how easy the syntax becomes. Both these firewalls are very comprehensive and can allow you to create any kind of configuration required for your network. Learn at least the basics of UFW or IPTables firewall, as these are the Linux commands you must know.
Learn more about managing firewall with 3246 and managing firewall with 3251 .
Jump back to commands list ↑
Package Managers in Linux
Different Linux distributions use different package managers. Since we’re working on a Ubuntu server, we have the 3261 package manager. But for someone working on a Fedora, Red Hat, Arch, or Centos machine, the package manager will be different.
Below are the commands on how to use these package managers on different Linux distributions.
- Debian and Debian-based distros -
3276
- Arch and Arch-based distros -
3288
- Red Hat and Red Hat-based distros -
3290
- Fedora and CentOS -
3306
Getting yourself well versed with the package manager of your distribution will make things much easier for you in the long run. So even if you have a GUI based package management tool installed, try an make use of the CLI based tool before you move on to the GUI utility. Add these to your list of Linux commands you must know.
Jump back to commands list ↑
The 3319 command in Linux
“With great power, comes great responsibility” _
This is the quote displayed when a sudo-enabled user(sudoer) first uses the 3325 command to escalate privileges. This command is equivalent to logging in as 3330 (based on what permissions you have as a sudoer).
non-root-user@ubuntu:~# sudo <command you want to run>
Password:
Just add the command 3344 before any command that you need to run with escalated privileges, and that’s it. It’s very simple to use, but can also be an added security risk if a malicious user gains access to a sudoer.
Learn more about how to create a new 3359 user and how to edit sudoers file.
Jump back to commands list ↑
The 3364 command in Linux
Have you ever wanted to view the calendar in the terminal? There apparently are people who want it to happen, and well, here it is.
The 3376 command displays a well-presented calendar on the terminal. Just enter the command 3385 on your terminal prompt.
root@ubuntu:~# cal
root@ubuntu:~# cal March 2024

Although we don’t need it often, it’s a great addition! It’s an amazing option for terminal fans.
Jump back to commands list ↑
The 3398 command
Do you have some commands that you run very frequently while using the terminal? It could be 3405 or 3419 , or it could be something longer like 3426 .
This is one of the productivity-boosting Linux commands you must know.
If you know a command that you run very often, it’s time to create an 3438 .
What’s an alias? In simple terms, it’s another name for a command that you’ve defined.
root@ubuntu:~# alias lsl="ls -l"
OR
root@ubuntu:~# alias rmd="rm -r"
Now, every time you enter 3449 or 3459 in the terminal, you’ll receive the output that you’d have received if you had used the full commands.
The examples here are for really small commands that you can still type by hand every time. But in some situations where a command has too many arguments that you need to type, it’s best to create a shorthand version of the same.
Jump back to commands list ↑
The 3461 command in Linux
This command was created to convert and copy files from multiple file system formats. In the current day, the command is simply used to create bootable USB for Linux but there still are some things important you can do with the command.
The 3474 command in Linux is a versatile command used for low-level copying and conversion of data. It stands for “data-description” or “data definition,” and it can be used to copy and convert data between different file formats and storage devices.
For example, if we wanted to back up the entire hard drive as is to another drive, we would use the 3487 command.
root@ubuntu:~# dd if=/dev/sdb of=/dev/sda
The if and of arguments stand for input file and output file .
It’s a powerful and flexible tool, but it can also be dangerous if not used carefully. Always double-check your syntax and make sure you know what the command will do before executing it.
Jump back to commands list ↑
The 3498 and 3509 commands
The 3510 and 3525 commands are used in Linux to search for information about programs and files.
The 3534 command locates the binary, source, and manual pages for a specific command or program, and the 3540 command displays a short description of a command or program.
root@ubuntu:~# whereis sudo
sudo: /usr/bin/sudo /usr/lib/sudo /usr/share/man/man8/sudo.8.gz
The 3550 command gives us an explanation of what a command actually is.
root@ubuntu:~# whatis sudo
sudo (8) - execute a command as another user
Jump back to commands list ↑
The 3566 command in Linux
A few sections earlier, we talked about the 3578 คำสั่ง You observed that the 3581 command will output the active processes and end itself.
The 3593 command is like a CLI version of the task manager in Windows.
The 3601 command in Linux is a system monitoring tool that displays real-time information about system processes and resource usage. It provides a dynamic, real-time view of system activity, including CPU usage, memory usage, and process information.

หมายเหตุ: Here are some examples of using the 3617 command:
- Sort processes by memory usage:
root@ubuntu:~# top -o MEM
This will sort the process list by memory usage, with the most memory-intensive processes at the top.
- Display detailed information about a specific process:
root@ubuntu:~# top -p PID
Replace 3626 with the ID of the process you want to inspect.
- Display a summary of system resource usage:
root@ubuntu:~# top -n 1
This will display a single summary screen of system resource usage.
It’s a powerful and flexible tool for monitoring system activity and troubleshooting performance issues.
Jump back to commands list ↑
The 3636 and 3646 commands
The 3657 and 3664 commands are used in Linux to manage user accounts.
The 3675 or 3686 commands are the exact same commands where 3690 is just a symbolic link to the 3705 คำสั่ง This command allows us to create a new user in Linux.
root@ubuntu:~# useradd JournalDev -d /home/JD
The above command will create a new user named 3715 with the home directory as 3728 .
The 3736 command, on the other hand, is used to modify existing users. You can modify any value of the user including the groups, the permissions, etc.
For example, if you want to add more groups to the user, you can type in:
root@ubuntu:~# usermod JournalDev -a -G sudo, audio, mysql
Jump back to commands list ↑
The 3746 command in Linux
Now that you know how to create new users, let’s also set the password for them. The 3755 command lets you set the password for your own account, or if you have the permissions, set the password for other accounts.
Here are some examples of using the 3760 command:
-
Change the password for the current user:
root@ubuntu:~# passwd
This will prompt you to enter a new password for the current user.
-
Change the password for a specific user:
root@ubuntu:~# passwd username
Replace 3775 with the name of the user whose password you want to change.
-
Force a user to change their password at the next login:
root@ubuntu:~# passwd -f username
-
Set an expiration date for a user’s password:
root@ubuntu:~# passwd -e -n days -w warndays username
Replace 3781 with the number of days before the password expires and 3791 with the number of days before the password expires that the user will be warned.
These are just a few examples of using the 3807 command in Linux. By understanding how to use this command effectively, you can manage user accounts and ensure that your system is secure.

Jump back to commands list ↑
Common Errors and Debugging
When working with Linux commands, you may encounter various errors and issues. Here are some common problems and how to resolve them:
1. Fixing “command not found” errors
If you receive a 3815 error, it means that the command you are trying to run is not recognized by the system. This can happen for several reasons:
-
The command is not installed on your system. You can install it using your package manager (e.g., 3829 , 3837 , 3845 ).
If you see:
bash: xyz: command not found
Use:
which xyz
If the command isn’t installed, try installing:
apt-get install <package-name>
-
The command is not in your system’s PATH. You can add the directory containing the command to your PATH.
export PATH=$PATH:/path/to/command
-
You made a typo. Double-check the command for any spelling errors.
2. Resolving permission issues with sudo
If you encounter permission issues, you can use 3858 to run the command with superuser privileges. ตัวอย่างเช่น:
sudo command_name
3. Handling File Conflicts
File conflicts can occur when multiple users or processes attempt to modify the same file simultaneously. Here are some ways to handle file conflicts:
-
Use Version Control Systems (VCS): Tools like Git can help manage file conflicts by allowing users to merge changes and resolve conflicts manually.
git merge <branch_name>
If there are conflicts, Git will prompt you to resolve them. Open the conflicting files, make the necessary changes, and then commit the resolved files.
git add <resolved_file>
git commit -m "Resolved merge conflict"
-
Locking Mechanisms: Implement file locking to prevent multiple processes from writing to the same file simultaneously. Use 3860 in Linux to create a lock on a file.
flock -x <file> -c "<command>"
-
Atomic Operations: Use atomic operations to ensure that file writes are completed in a single step, reducing the risk of conflicts.
mv temp_file target_file
Or, Use 3877 with 3887 (force) or 3894 with 3904 (interactive):
mv -f file1 file2
cp -i file1 file2
4. Debugging Performance Bottlenecks
Performance bottlenecks can significantly impact the efficiency of your system. Here are some steps to debug and resolve them:
-
Identify the Bottleneck: Use tools like 3919 , 3921 , 3933 , and 3949 to monitor system performance and identify the resource causing the bottleneck (CPU, memory, disk I/O, etc.).
top
-
Analyze Logs: Check system and application logs for any errors or warnings that might indicate performance issues.
tail -f /var/log/syslog
-
Optimize Code: Review and optimize your code to improve performance. Look for inefficient algorithms, unnecessary computations, and memory leaks.
-
Profile Your Application: Use profiling tools like 3953 , 3969 , or 3973 to analyze your application’s performance and identify slow functions or memory issues.
gprof <executable> gmon.out
-
Scale Resources: If the bottleneck is due to resource limitations, consider scaling up your hardware or using load balancing to distribute the load across multiple servers.
FAQs
1. What are the most used Linux commands?
The most used Linux commands include 3987 , 3999 , 4007 , 4016 , 4025 , 4039 , 4048 , 4052 , 4069 , 4071 , 4082 , 4092 , 4104 , 4117 , 4127 , 4132 , 4142 , 4154 , 4168 , 4175 , 4180 , 4193 , 4209 , 4211 , 4224 , 4236 , 4244 , 4250 , 4269 , 4279 , and 4289 .
2. How do I list all available commands in Linux?
You can list all available commands in Linux by using the 4290 คำสั่ง This will display a list of all commands that are available on your system.
3. How do I find a file in Linux?
You can find a file in Linux using the 4307 คำสั่ง The basic syntax is 4316 , where 4327 is the directory where you want to start searching, and 4333 is the name of the file you’re looking for. For example, 4348 .
4. How do I kill a process in Linux?
You can kill a process in Linux using the 4355 คำสั่ง First, you need to find the process ID (PID) of the process you want to kill using the 4368 or 4379 คำสั่ง Then, use the 4380 command followed by the PID. For example, 4398 , where 4403 is the PID of the process.
5. What is the difference between 4418 and 4424 ?
The 4431 command is used to copy files or directories, while the 4440 command is used to move or rename files or directories. 4458 creates a duplicate of the original file, leaving the original intact, whereas 4462 moves the file to a new location, removing it from the original location.
6. How do I check my Linux system’s memory usage?
You can check your Linux system’s memory usage using the 4470 คำสั่ง This command displays the total amount of free and used physical and swap memory in the system. For example, 4488 will display the memory usage in a human-readable format.
บทสรุป
In this tutorial, you explored over 50 essential Linux commands covering file and directory management, process control, user permissions, networking, text processing, and shell utilities. You also worked through real-world examples, troubleshooting patterns, and comparisons between related commands.
You can now navigate the Linux filesystem, manage processes, configure permissions, and troubleshoot common issues from the command line. These commands form the foundation of effective Linux system administration and scripting.
To go deeper on specific topics, explore these tutorials:
- The grep Command in Linux/Unix
- The ls Command in Linux/Unix
- Process Management in Linux
- The ps Command in Linux
- An Introduction to the Linux Terminal
This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.
-
-
-
-