LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Manjaro
User Name
Password
Manjaro This forum is for the discussion of Manjaro Linux. Note: This forum does not have any official participation.

Notices


Reply
  Search this Thread
Old 10-10-2021, 07:30 AM   #1
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix
Posts: 345

Rep: Reputation: 15
"GREP_COLORS=" cannot work so long as preceded by sudo


Why "GREP_COLORS=" set cannot work if grep family, i.e. more actually pcre2grep, preceded by sudo ?

though fact is other Linux, i.e. MX, simply go working
please help out to work here too
 
Old 10-10-2021, 08:19 AM   #2
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Most probably, you have defined an alias somewhere in your shell startup files for regular user. Something along the lines
Code:
alias pcre2grep='pcre2grep --color=auto'
This alias is not defined for root. Compare the output of
Code:
alias
and
Code:
sudo alias
Same goes for the environment variable GREP_COLORS. By default, sudo sanitizes most of the environment. GREP_COLORS set for the regular user won't be seen by root unless included in the env_keep list.

This is actually the case where cat abuse otherwise known as UUOC might make sense:
Code:
sudo cat file_accessible_only_by_root|pcre2grep RE
Or just specify the --color option explicitly (this will use default colors though):
Code:
sudo pcre2grep --color RE file_accessible_only_by_root

Last edited by shruggy; 10-10-2021 at 09:07 AM.
 
1 members found this post helpful.
Old 10-10-2021, 01:40 PM   #3
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix
Posts: 345

Original Poster
Rep: Reputation: 15
EXCELLENT
Thanks, more importantly must God reward you..

Last edited by BudiKusasi; 10-13-2021 at 05:38 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: The Ultimate Sudo FAQ — To Sudo Or Not To Sudo? LXer Syndicated Linux News 13 04-13-2013 01:36 AM
Aboout "with very long lines",how long is very long? yun1st Linux - Newbie 4 07-20-2012 03:38 PM
long long long: Too long for GCC Kenny_Strawn Programming 5 09-18-2010 01:14 AM
getopts fails if $1 isn't preceded by - Nergar Linux - General 1 05-23-2008 06:43 AM
cannot "sudo apt-get uptate" or "sudo" anything! plz help mdguy21061 Linux - Newbie 7 04-13-2008 11:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Manjaro

All times are GMT -5. The time now is 04:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration