Hello Friends, Thank you for visiting my blog. Now in this post I'll share how you can add more commands other than default commands in Linux distros. First you have to understand that all basic commands that you know for Linux are stored in /bin directory as a binary files.
You can write any program on any Language and compile it to have the binary file, and after having the binary file you have to place that file to /bin directory.
Important Note:Please make sure to rename the compiled binary file to command you want to make.
Down there is a Example of a C++ Program for make new command.
Here I wrote the program for make a command 'lsl' which is a short form of command 'ls -l'
as 'ls' command shows the directory and files of current working directory in a non listed way, and 'ls' with '-l' argument it shows the directory and files in a listed way.
----C++ program----
#include<iostream>
#include<windows.h>
using namespace std;
int main(){
system("ls -l");
//Actual command here, system function make a system call here with 'ls -l' command
return 0;
}

No comments:
Post a Comment