Sunday, March 27, 2016

Basic Unix Terminal Commands

Getting the current directory
pwd
command එකෙන් කියන්නේ print working directory කියන එක.ඒකෙන් වෙන්නේ අපි දැනට වැඩ කරන directory එකේ path එක print වෙන එක.




Listing files
Directory එකක තියෙන files terminal එකේ බලන්නෙ ls command එකෙන්.
ls~   command එකෙන් home directory එකේ files list කරනව.
ls -l   command එකෙන් long format එකෙන් files වල details ලැබෙනව.

Changing the directory
cd මගින් තමයි අපිට ඕන folder එකට එහෙම නැත්තං directory එකට යන්නේ.cd වලත් options කීපයක් තියෙනවා
cd/  root directory එකට යනවා
cd    home directory එකට යනවා
cd .. දැනට ඉන්න directory එකෙන් එක level එකක් උඩට යනවා
cd - කලින් directory එකට යනවා
ඊට අමතරව cd (directory name) දුන්නාම ඒ directory එකට navigate කරන්න පුළුවන්

Copying a file or a directory
cp command එකෙන් අපිට file වගේම directories copy කරන්න පුළුවන්.
File එකක් copy කරන කොට,
cp filename newfilename කියන පිළිවෙළට තමා type කරන්න ඕන.
cp filename newfilepath වලින් අපිට ඕන තැනකට file එක copy කරන්න පුළුවන්.
directory එකක් copy කරන කොට ඒකෙ තියෙන සේරම files හා subdirectories copy කරන්න recursive method ඒකක use කරන්න ඕන.ඒකට අපි use කරන්නේ මේ විදිය.
cp -r directory nameofnewdirectory
Moving
mv තමයි moving වලට ගන්න syntax එක.
mv filename newdirectory
Removing or deleting
Directory එකක් හරි file එකක් delete කරන්න නම් rm command එක තමා use කරන්න ඕන.
File එකක් delete කරන්න නම්,
rm filename
Directory එකක් delete කරන්න නම්,
rm -r directoryname
-r කියන එකෙන් වෙන්නෙ recursive විදියට directory එකේ තියෙන සේරම දේවල් delete කරන එක.
rmdir directoryname වලින් empty directory එකක් delete කරන්න තමා පුළුවන්. Empty නැති එකක් සම්පූර්ණයෙන් delete කරන්න තමා උඩින් කියපු -r use කරන්නෙ.
rm -f  වලින් කරන්නෙ force removal එකක්.
rm -rf  ඇතුළෙ තියෙන දේවල් එක්ක මුළු directory එකම delete කරන්න තමා force recursive යොදා ගන්නෙ.
Displaying a file
cat filename එකෙන් file එකක තියෙන දේවල් terminal එකේ read only ආකාරයට පෙන්නනව.

Making a directory
mkdir directoryname
chmod command එක ගැන වෙනම post එකකින් විස්තර දාන්නම්.

No comments:

Post a Comment