What linux in command? Several ways to execute commands? How to create your own command?

What linux in the command?

Command is an executable binary program

Execute commands in several ways?

./test.sh # relative path execution

/data/test.sh # absolute path execution

source /data/test.sh # read execution  

. /Data/test.sh # read execution

bash /data/test.sh # perform in sub-shell

How to create your own command?

First, create a script, here it is in many programmers just starting to learn the script code examples

[root@uplooking ~]# vim hello

#!/bin/bash
echo "Hello World !"

Second, add execute permission to the script

[root@uplooking ~]# chmod u+x hello

Third, view the command storage location

[root@uplooking ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

Fourth, copy the script to the next path, note that the above path just put a place like

[root@uplooking ~]# cp hello /usr/local/sbin/  

Fifth, the output of the command

[root @ uplooking ~] # hello
hello world!

 

Guess you like

Origin www.cnblogs.com/github-cn/p/11258167.html