Linux Tip #3 – Terminal commands customize කරමු

Share with your friends!

Linux Tip #3 වලින් කියන්න හදන්නේ terminal commands අපි කැමති විදියට වෙනස් කරගන්නේ කොහොමද කියලා. වෙනස් කරනවා කිව්වට ඇත්තටම කරන්නේ නම වෙනස් කරන එක. මේකෙදි අපි කැමති සරල නම් වලට commands convert කරනවා. මේකෙන් අපි දිගට type කරන commands short form එකක් විදියට use කරන්න පුළුවන්. එහෙනම් බලමු කොහොමද වැඩේ කරන්නේ කියලා.

උදාහරණයක් විදියට මොකක් හරි install කරනවා කියල හිතමු.

sudo apt-get install package_name

නිතරම install කරද්දී මේ විදියට type කරන්නේ නැතුව ඒ වෙනුවට මේ වගේ දෙයක් තිබුනොත්,

install package_name

වැඩේ ගොඩක් simple වෙනවා.
මේවට කියන්නේ aliases කියලා. ඒ වගේම තමන්ගේ linux os එකේ තමන්ගේම commands වලින් වැඩ කරද්දී අනිත් usersලට වැඩිය වෙනස්නේ. 🙂

එහෙනම් බලමු වැඩේ කරන්නේ කොහොමද කියලා.

මුලින්ම මේ file එක open කරගන්න. (gedit හරි nano හරි අවුලක් නැහැ)

gedit ~/.bash_aliases

ඊටපස්සේ file එක open වෙයි. දැනට empty file එකක් ඇති. මෙතැනදී තමයි අපි customization එක කරන්නේ. ඒක කරන්නේ මේ විදියට. මම දැනට package list එක update කරන command එකයි, අලුත් package එකක් install කරන command එකයි ගන්නවා.


alias install='sudo apt-get install'
alias update='sudo apt-get update'

මෙතන install කියන්නේ use කරන්න ඕන නම. අනිත් side එකේ තියෙන්නේ අලුත් නමක් දෙන්න ඕන command එක. ඊටපස්සේ file එක save කරලා මේ command එක දෙන්න.

source ~/.bash_aliases

දැන් terminal එකේ update කියල දීල බලන්න. password එකත් දෙන්න. package list එක කලින් වගේ update වෙයි. මේ තියෙන්නේ ඒ වගේ හදාගත්ත command set එකක්.


alias update='sudo apt-get update'
alias shutdown='sudo init 0'
alias reboot='sudo init 6'
alias install='sudo apt-get install'
alias remove='sudo apt-get remove'
alias cls='clear'

මේ විදියට application උනත් run කරන්න පුළුවන් terminal එකෙන්. දැනගන්න ඕන application එකේ path එක විතරයි. default path එක වෙන්නේ /usr/share/. මෙතනින් install කරපු application එකේ folder එකට ගිහින් .sh file එක තියන path එක හොයාගන්න.

PyCharm application එකේ .sh file එක තියෙන්නේ /usr/share/pycharm/bin කියන path එකේ දැන් pycharm run කරන්න alias එකක් ලිව්වොත් මේ විදියට ලියන්න පුළුවන්.

alias pycharm='/usr/share/pycharm/bin/./pycharm.sh'

ඊටපස්සේ කලින් විදියටම save කරගන්න. මේ වගේ ඕනෑම application එකක් use කරන්න පුළුවන්.

 

Linux is a cancer that attaches itself in an intellectual property sense to everything it touches. – Steve Ballmer

FOSS වලට ජයවේවා !!

Share with your friends!

6 comments

Leave A Comment

shares