Back to Browse

How to Use “exec” Command in Linux [8 Practical Examples] | LinuxSimply

1.7K views
Feb 24, 2024
9:32

💡 Elevate your Linux skills with our latest course ‘Linux Fundamentals: A Complete Guide for Beginners’. Start learning today: https://www.udemy.com/course/linux-fundamentals-a-complete-guide-for-beginners Have you ever thought of any command which could replace the current terminal process with a new command ? For your knowledge, the exec command is there for you in this case. Whether you're a system administrator, developer, or Linux enthusiast, this video is your comprehensive guide to mastering "exec" with 8 practical examples. 💡 Key Topics Covered: 1. Understand the basics exec command, exec command syntax and its options. 2. Know how to list the contents of the current directory in long format. 3. Know how to list all environment variables and their values. 4. Learn how to call another program in a bash script. 5. Learn how to clean your system environment variables and values by running bash script. 6. Know how to search files and display its contents using exec command. 7. Know how to search files and compress them if needed using exec command. 8. Know how to search files and change their file permission using exec command. Embark on an exploration into Linux mastery, delving deep into the exec command! Effortlessly manage your system environment and its variables. Subscribe now to immerse yourself in a comprehensive learning experience that will reshape your Linux skills. Content Index: 0:00 Introduction 0:14 What is exec Command? 1:05 Example 1: List the Contents of the Current Directory in Long Format 1:54 Example 2: List All Environment Variables And Their Values 2:28 Example 3: Call Program in Bash Script 4:08 Example 4: Log Stdout & Stderr In the Bash Script 5:25 Example 5: Create a Clean Environment By Running Script 6:16 Example 6: Search Files And Display Their Contents 7:00 Example 7: Search Files And Compress Them 8:15 Example 8: Search Files And Change Permission Instructor Details: Fahmid Bin Kibria https://linuxsimply.com/fahmid-bin-kibria/ Editor Details: Reshma Raj https://linuxsimply.com/reshma-raj/ Article Link: The “exec” Command in Linux [8 Practical Examples] https://linuxsimply.com/exec-command-in-linux/ Commands Used: ----------------------------------------------- What is exec Command ? help exec Example 1: List the Contents of the Current Directory in Long Format 1. bash 2. exec ls -la Example 2: List All Environment Variables And Their Values 1. bash 2. exec env Example 3: Call Program in Bash Script 1. nano script.sh 2. ./script.sh Example 4: Log Stdout & Stderr In the Bash Script 1. nano logging.sh 2. cat testFile.log Example 5: Create a Clean Environment By Running Script 1. printenv 2. bash 3. exec -c printenv Example 6: Search Files And Display Their Contents 1. find ~/MyFolder -name "*.txt" -exec cat {} \; Example 7: Search Files And Compress Them 1. ls MyFolder/ 2. find ~/MyFolder -name "*.log" -exec gzip {} \; 3. ls MyFolder/ Example 8: Search Files And Change Permission 1. ls -la MyFolder/ 2. find ~/MyFolder -name "*.log" -exec chmod +x {} \; 3. ls -la MyFolder/ Follow Us: Facebook: https://web.facebook.com/softeko.linuxsimply/ Twitter: https://twitter.com/LinuxSimply LinkedIn: https://www.linkedin.com/company/linuxsimply/ Tiktok: https://www.tiktok.com/@linuxsimply #linux #linuxsimply #linuxtutorial #exec #command #ubuntu #process #terminal

Download

1 formats

Video Formats

360pmp414.2 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

How to Use “exec” Command in Linux [8 Practical Examples] | LinuxSimply | NatokHD