Task 3:How can we change colour of file and folder in linux

Tips: Before running any command to change the color of file/folder first save the original color in some variable

ORIGINAL_FILE_COLOR=$LS_COLORS
ORIGINAL_FOLDER_COLOR=$LS_COLORS        


To change the color of file following command can be used

LS_COLORS="fi=var1:var2"        

above var1 defines text properties and it can be

  • 0, for Normal Text
  • 1,for Bold or Light Text
  • 2, for Dim Text
  • 4, for Underlined Text

and var2 defines the colour of the text some color code are as follows

black = 30, red = 31, green = 32, yellow = 33, blue = 34, magenta = 35, cyan = 36, and white = 37.

Now to set the default file color :

LS_COLORS=$ORIGINAL_FILE_COLOR        

To change the color of a directory or folder we simply have to put 'fi' instead of 'di' in the following command

LS_COLORS="fi=var1:var2"        
performed task
Example to change directory color in RHEL 9


I am happy to complete this task successfully thanks to LinuxWorld Informatics Pvt Ltd to give me this task.


usefull

回复

要查看或添加评论,请登录

Vaishali Dewangan的更多文章

社区洞察

其他会员也浏览了