Skip to content

Custom Linux Command in Bin Directory

September 17, 2012


This will explain how to create a custom command, inside the core binary folder of linux, which can be used in a linux terminal. This is useful if you are constantly executing the same commands such as changing to a certain directory and printing out the contents, running a script and then checking the contents of the directory again. Having a dedicated command can help to shorten such procedures.

Create Command

$ cd /usr/bin
$ sudo nano {command-name}

#change permission to execute command
$ sudo chmod 755 {command-name}

Add bash script which will be executed when the command is typed into the command prompt and save.

Remove Command

$ sudo rm /usr/bin/{command-name}

Example Scenario

Say you want to create a command which will: Print out the current directory and the contents.

For this we will create a command called ‘printdir’

cd /usr/bin
sudo nano printdir

Add the following to the created file:



Save and try executing in the /u01 directory:

[username@c55555555 u01]$ printdir
total 14
drwxr-xr-x 7 root root 1024 Jul 10 15:55 accts
drwxr-xr-x 3 root root 1024 Jun 10 17:14 app
drwx—— 2 root root 12288 Dec 10 2010 lost+found

Useful Links:

Also See:


From → Guide

  1. Thanks for every other informative web site. The place else could I am getting that kind of information written in such a perfect manner? I have a undertaking that I’m just now working on, and I have been at the glance out for such information.

  2. I just like the helpful information you supply on your articles. I’ll bookmark your blog and test once more right here frequently. I am relatively sure I’ll learn plenty of new stuff proper right here! Good luck for the next!

  3. I’m really enjoying the design and layout of your site. It’s
    a very easy on the eyes which makes it much more enjoyable for
    me to come here and visit more often. Did you hire out a developer to create your theme?
    Exceptional work!

Trackbacks & Pingbacks

  1. Custom Linux Command with Alias « SoftwareSanders

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: