Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Builtin Command in Linux
3.
Mathematical Functions in Korn Shell
4.
Frequently Asked Questions
4.1.
What is the sudo command?
4.2.
How do the Builtin functions benefit the developer?
4.3.
What is the advantage of using commands?
5.
Conclusion
Last Updated: Mar 27, 2024
Medium

Linux - Builtin Functions

Author Manish Kumar
0 upvote
Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

Introduction

Linux is one of the most versatile Operating Systems. Almost all the major big tech firms use Linux as their main operating system for servers. Builtin commands are convenient for managing these servers. We can write our custom functions and make them work as commands.

Linux Builtin Functions

 In this blog, we will learn about the Builtin Command and other mathematical functions. 😁

Builtin Command in Linux

The Builtin command runs a shell builtin function but allows us to input arguments and get exit status. This command helps to change the behaviour of an existing function. Let's understand this with the example of the cd command.

BuiltIn Command

From the image above, we can see that the behaviour of the cd command changes and it changes the current directory to a folder names' home' that we created early using the mkdir command. Now, whenever we use the cd command, it will always take us to the home directory.

Syntax:

builtin [shell-builtin [arg ..]]

Note: To get some help regarding the builtin command, we can use the ‘builtin –help’ command. See the image below for more clarification.

help
Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Mathematical Functions in Korn Shell

Korn shell is a UNIX shell developed by David Korn. It is also based on bourne shell source code similar to other popular shells. This shell provides an interactive shell for command programming and interpretation. In this section, we will look at some of the mathematical functions available in Korn Shell.

Before we look at the functions, let's see how we can install Korn Shell in our Linux distro.

✅To install Korn Shell, execute the following command.

sudo apt install ksh 

install korn shell

✅To start Korn Shell, execute the ksh command.
 

ksh

Now, let's have a look at the list of available functions:

abs: It gives the absolute value.

⭐log: To calculate the natural logarithm.

⭐acos: It gives arc cosine value.

⭐sin: It provides the sine value.

⭐asin: It gives the arc sine value.

⭐sinh: For hyperbolic sine.

⭐cos: It provides the cosine value.

⭐sqrt: It gives the square root of a number.

⭐cosh: It provides the value of hyperbolic cosine.

⭐tan: It gives the tangent value.

⭐exp: It provides the exponential value.

⭐tanh: For hyperbolic tangent value.

⭐int: It provides the integer part of a decimal number.

 

The image given below shows the actual implementation of few of the above functions:
 

Implementation of ksh

Frequently Asked Questions

What is the sudo command?

It is one of the essential commands. It gives the user superuser/root privileges. Be careful while using this command, as you can access critical sections of the server using this command.  

How do the Builtin functions benefit the developer?

The Builtin functions are the same across the range of Linux distributions. These are standard commands, and a lot of help is available from the Linux community.

What is the advantage of using commands?

Commands make use of Linux fast. Many operations not available in GUI versions can be performed using commands only. Commands give a powerful way to handle Linux systems.

Conclusion

In this article, we discussed Linux Builtin Commands. We learned how to customize these commands and use them according to our choice. We also installed Korn Shell and saw various mathematical functions available in the Korn Shell.

If you found this blog interesting, please visit these articles:

 

Please refer to our guided pathways on Code studio to learn more about DSACompetitive ProgrammingJavaScriptSystem Design, etc. Enrol in our courses, and use the accessible sample exams and questions as a guide. For placement preparations, look at the interview experiences and interview package.

Please do upvote our blogs if you find them helpful and informative!

Happy Learning!

Previous article
Linux - Decision Making
Next article
Linux - File Security
Live masterclass