Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED]"ls" command error
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
iceamber
Tux's lil' helper
Tux's lil' helper


Joined: 06 Jun 2016
Posts: 94

PostPosted: Sat Mar 25, 2017 3:58 pm    Post subject: [SOLVED]"ls" command error Reply with quote

Hi, everyone

There is an error on my system, the first char of directory is missing when run "ls" command, but it's OK in the root user, .e.g
Code:
iceamber@localhost:~ $ ls kernel/
db-7.11  gdb-7.11.tar.gz  inux-0.12  inux-2.6.0  inux-3.18.44  linux-3.18.44.tar  inux-4.7

Code:
iceamber@localhost:~ $ sudo ls kernel/
gdb-7.11  gdb-7.11.tar.gz  linux-0.12  linux-2.6.0  linux-3.18.44  linux-3.18.44.tar  linux-4.7


Is there something wrong in my urxvt config?

Quote:
URxvt.inheritPixmap:true
UURxvt.shading: 60
Rxvt.background:#005f87
URxvt.foreground:#ffffff
URxvt.colorBD:Gray95
URxvt.colorUL:Green
URxvt.color1:Red2
URxvt.color4:RoyalBlue
URxvt.color5:Magenta2
URxvt.color8:Gray50
URxvt.color10:Green2
URxvt.color12:DodgerBlue
URxvt.color14:Cyan2
URxvt.color15:Gray95

URxvt.perl-ext-common: default,selection-to-clipboard,pasta,matcher,keyboard-select
URxvt.keysym.M-u: perl:url-select:select_next
URxvt.urlLauncher:google-chrome
URxvt.matcher.button:1
Urxvt.perl-ext-common:matcher
URxvt.keysym.M-Escape:perl:keyboard-select:activate
URxvt.keysym.Control-Shift-V:perl:pasta:paste
URxvt.clipboard.autocopy:true

URxvt.scrollBar:False
URxvt.scrollBar_floating:False
URxvt.scrollstyle:plain

URxvt.mouseWheelScrollPage:True
URxvt.scrollTtyOutput:False
URxvt.scrollWithBuffer:True
URxvt.scrollTtyKeypress:True

URxvt.cursorBlink:True
URxvt.saveLines:3000

URxvt.borderLess:False

Xft.dpi:96
Xft.antialias: true
Xft.rgba: rgb
Xft.hinting: true
Xft.hintstyle: hintslight
Xft.autohint: false
Xft.lcdfilter: lcddefault
URxvt.font: xft:WenQuanYi Zen Hei Mono:antialias=True:pixelsize=13,xft:WenQuanYi Zen Hei Mono:antialias=True:pixelsize=13
URxvt.boldfont:xft:WenQuanYi Zen Hei Mono:antialias=True:pixelsize=13,xft:WenQuanYi Zen Hei Mono:antialias=True:pixelsize=13
URxvt.letterSpace:-1.5


Last edited by iceamber on Sat Mar 25, 2017 5:40 pm; edited 1 time in total
Back to top
View user's profile Send private message
cboldt
Veteran
Veteran


Joined: 24 Aug 2005
Posts: 1046

PostPosted: Sat Mar 25, 2017 4:12 pm    Post subject: Reply with quote

It's not urxvt. If it was, the output of `ls kernel/` would be the same both times. Assuming the output you provided comes from a single terminal and shell instance, and you didn't change a bunch of things you didn't tell us about.

If the output was the same for all instances of a character (like "ell" or "gee"), I'd have an idea (shell IFS), but with the only output being affected being assigned to directories, the issue lies elsewhere.

Edit to add, what does `ls -l kernel/` report? Again for both users.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21602

PostPosted: Sat Mar 25, 2017 4:17 pm    Post subject: Reply with quote

Also, try ls-command | xxd to get a hexadecimal dump of the ls output. If that dump confirms specific original bytes are missing, this is an ls problem. If pieces of the hexdump are missing, this is a terminal problem.
Back to top
View user's profile Send private message
iceamber
Tux's lil' helper
Tux's lil' helper


Joined: 06 Jun 2016
Posts: 94

PostPosted: Sat Mar 25, 2017 4:24 pm    Post subject: Reply with quote

cboldt wrote:
It's not urxvt. If it was, the output of `ls kernel/` would be the same both times. Assuming the output you provided comes from a single terminal and shell instance, and you didn't change a bunch of things you didn't tell us about.

If the output was the same for all instances of a character (like "ell" or "gee"), I'd have an idea (shell IFS), but with the only output being affected being assigned to directories, the issue lies elsewhere.

Edit to add, what does `ls -l kernel/` report? Again for both users.


Here are the report for both users
Code:
iceamber@localhost:~ $ ls -l kernel/

drwxr-xr-x 16 iceamber iceamber      4096 Mar  30 2016 db-7.11
-rw-r--r--  1 iceamber iceamber  35215975 Mar  29 2016 gdb-7.11.tar.gz
drwxr-xr-x 10 iceamber iceamber      4096 Mar  25 2016 inux-0.12
drwxr-xr-x 18 iceamber iceamber      4096 Mar  12 23:34 inux-2.6.0
drwxr-xr-x 24 iceamber iceamber      4096 Mar  19 17:40 inux-3.18.44
-rw-r--r--  1 iceamber iceamber 581160960 Mar 16 08:08 linux-3.18.44.tar
drwxr-xr-x 25 iceamber iceamber      4096 Mar  14 22:47 inux-4.7


Code:
iceamber@localhost:~ $ sudo ls -l kernel/

drwxr-xr-x 16 iceamber iceamber      4096 Mar  30 2016 gdb-7.11
-rw-r--r--  1 iceamber iceamber  35215975 Mar  29 2016 gdb-7.11.tar.gz
drwxr-xr-x 10 iceamber iceamber      4096 Mar  25 2016 linux-0.12
drwxr-xr-x 18 iceamber iceamber      4096 Mar  12 23:34 linux-2.6.0
drwxr-xr-x 24 iceamber iceamber      4096 Mar  19 17:40 linux-3.18.44
-rw-r--r--  1 iceamber iceamber 581160960 Mar 16 08:08 linux-3.18.44.tar
drwxr-xr-x 25 iceamber iceamber      4096 Mar  14 22:47 linux-4.7
Back to top
View user's profile Send private message
iceamber
Tux's lil' helper
Tux's lil' helper


Joined: 06 Jun 2016
Posts: 94

PostPosted: Sat Mar 25, 2017 4:28 pm    Post subject: Reply with quote

Hu wrote:
Also, try ls-command | xxd to get a hexadecimal dump of the ls output. If that dump confirms specific original bytes are missing, this is an ls problem. If pieces of the hexdump are missing, this is a terminal problem.


This is the output in hexadecimal dump
Code:
iceamber@localhost:~ $ ls kernel/ | xxd
00000000: 6764 622d 372e 3131 0a67 6462 2d37 2e31  gdb-7.11.gdb-7.1
00000010: 312e 7461 722e 677a 0a6c 696e 7578 2d30  1.tar.gz.linux-0
00000020: 2e31 320a 6c69 6e75 782d 322e 362e 300a  .12.linux-2.6.0.
00000030: 6c69 6e75 782d 332e 3138 2e34 340a 6c69  linux-3.18.44.li
00000040: 6e75 782d 332e 3138 2e34 342e 7461 720a  nux-3.18.44.tar.
00000050: 6c69 6e75 782d 342e 370a                 linux-4.7.


Last edited by iceamber on Sat Mar 25, 2017 4:30 pm; edited 1 time in total
Back to top
View user's profile Send private message
cboldt
Veteran
Veteran


Joined: 24 Aug 2005
Posts: 1046

PostPosted: Sat Mar 25, 2017 4:28 pm    Post subject: Reply with quote

Thanks for the extended output (-l)

I also wonder if an alias is perhaps involved

For both users, the output of `alias | grep ls=`
Back to top
View user's profile Send private message
cboldt
Veteran
Veteran


Joined: 24 Aug 2005
Posts: 1046

PostPosted: Sat Mar 25, 2017 4:39 pm    Post subject: Reply with quote

Could be a difference (between users) in $LS_COLORS

That variable is typically set via the command "dircolors" which refers to /etc/DIR_COLORS and ~/.dir_colors, and is called from shell setup scripts, e.g., /etc/bash/bashrc and ~/.bashrc

Edit to add, if you `echo $LS_COLORS` for both users, the part of interest will be ...

Code:
:di=44;33;01:


Which is the color assigned to directories. Although I am at a loss how a strange color sequence would eat one character, it is one place where the output of `ls` is easily varied between users.
Back to top
View user's profile Send private message
cboldt
Veteran
Veteran


Joined: 24 Aug 2005
Posts: 1046

PostPosted: Sat Mar 25, 2017 4:46 pm    Post subject: Reply with quote

What do you get on `ls kernel/g*` and `ls kernel/l*` ... Based on what I've seen so far, it would be the same as your initial report. Directories will be reported without the first character for the regular user, and reported correctly for root.

For both users, `echo $TERM`
Back to top
View user's profile Send private message
iceamber
Tux's lil' helper
Tux's lil' helper


Joined: 06 Jun 2016
Posts: 94

PostPosted: Sat Mar 25, 2017 4:57 pm    Post subject: Reply with quote

cboldt wrote:
What do you get on `ls kernel/g*` and `ls kernel/l*` ... Based on what I've seen so far, it would be the same as your initial report. Directories will be reported without the first character for the regular user, and reported correctly for root.

For both users, `echo $TERM`


The output of `ls kernel/g*`is
Code:
eadliner@localhost:~ $ ls kernel/g*
^[[?1;2cChangeLog               config.status  libtool.m4      serdep.tmp
MAINTAINERS             config.sub     ltgcc.m4        im
Makefile                configure      ltmain.sh       src-release.sh
Makefile.def            configure.ac   ltoptions.m4    symlink-tree
Makefile.in             pu            ltsugar.m4      tags-if-change
Makefile.tpl            depcomp        ltversion.m4    exinfo
README                  djunpack.bat   lt~obsolete.m4  ylwrap
README-maintainer-mode 
                        tc            md5.sum         lib
fd                     db            missing
compile                 nclude        mkdep
iceamber@localhost:~ $ 1;2c1;2c


When the `ls kernel/l*` is
Code:
s             modules.order    oolsers        m               tagsrt tags
ocumentation    rch             clude   modules.builtin  srndcurity
Kbuild          lock           nclude        et              irtd
Kconfig         erts           nit           run              vmlinux
MAINTAINERS     rypto          pernel         cripts         vmlinux.o
Module.symvers  cscope.out      ib            ecurity
README          cscope.po.out   linux-0.2.img  ound
iceamber@localhost:~ $ 1;2c1;2c1;2c1;2c


The report of `echo $TERM` is
Code:
iceamber@localhost:~ $ echo $TERM
rxvt-unicode-256color
iceamber@localhost:~ $ sudo echo $TERM
rxvt-unicode-256color
iceamber@localhost:~ $
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Sat Mar 25, 2017 5:07 pm    Post subject: Reply with quote

iceember ...

I would suspect the locale ... please provide the output of the following:

Code:
$ env -i /bin/ls kernel/
$ LANG=C /bin/ls kernel/
$ LANG=C ls kernel/
$ LANG=C busybox ls kernel/
$ locale
$ sudo locale

best ... khay
Back to top
View user's profile Send private message
cboldt
Veteran
Veteran


Joined: 24 Aug 2005
Posts: 1046

PostPosted: Sat Mar 25, 2017 5:08 pm    Post subject: Reply with quote

And for both users, the output of these two commands:

alias | grep ls=
echo $LS_COLORS
Back to top
View user's profile Send private message
iceamber
Tux's lil' helper
Tux's lil' helper


Joined: 06 Jun 2016
Posts: 94

PostPosted: Sat Mar 25, 2017 5:14 pm    Post subject: Reply with quote

khayyam wrote:
iceember ...

I would suspect the locale ... please provide the output of the following:

Code:
$ env -i /bin/ls kernel/
$ LANG=C /bin/ls kernel/
$ LANG=C ls kernel/
$ LANG=C busybox ls kernel/
$ locale
$ sudo locale

best ... khay


Code:
iceamber@localhost:~ $ env -i /bin/ls kernel/
gdb-7.11  gdb-7.11.tar.gz  linux-0.12  linux-2.6.0  linux-3.18.44  linux-3.18.44.tar  linux-4.7

iceamber@localhost:~ $ LANG=C /bin/ls kernel/
gdb-7.11  gdb-7.11.tar.gz  linux-0.12  linux-2.6.0  linux-3.18.44  linux-3.18.44.tar  linux-4.7

iceamber@localhost:~ $ LANG=C ls kernel/
db-7.11  gdb-7.11.tar.gz  inux-0.12  inux-2.6.0  inux-3.18.44  linux-3.18.44.tar  inux-4.7

iceamber@localhost:~ $ LANG=C busybox ls kernel/
gdb-7.11           linux-0.12         linux-3.18.44      linux-4.7
gdb-7.11.tar.gz    linux-2.6.0        linux-3.18.44.tar

iceamber@localhost:~ $ locale
LANG=zh_CN.UTF-8
LC_CTYPE=zh_CN.UTF-8
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE=C
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=

iceamber@localhost:~ $ sudo locale

LANG=zh_CN.UTF-8
LC_CTYPE=zh_CN.UTF-8
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE=C
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=
Back to top
View user's profile Send private message
iceamber
Tux's lil' helper
Tux's lil' helper


Joined: 06 Jun 2016
Posts: 94

PostPosted: Sat Mar 25, 2017 5:18 pm    Post subject: Reply with quote

cboldt wrote:
And for both users, the output of these two commands:

alias | grep ls=
echo $LS_COLORS


Code:
iceamber@localhost:~ $ alias | grep ls=
alias ls='ls --color=auto'

localhost iceamber # alias | grep ls=
alias ls='ls --color=auto'

iceamber@localhost:~ $ echo $LS_COLORS
rs=0:di=\e[38;2;00;00;255;1:ln=01;36:mh=00:pi=40;33:so=01;35:
do=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:
su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:
*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:
*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:
*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:
*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:
*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:
*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:
*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:
*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:
*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:
*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:
*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:
*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:
*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:
*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:
*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:
*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:
*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:
*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.pdf=00;32:*.ps=00;32:
*.txt=00;32:*.patch=00;32:*.diff=00;32:*.log=00;32:*.tex=00;32:
*.doc=00;32:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:
*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:
*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:
*.spx=00;36:*.xspf=00;36:

iceamber@localhost:~ $ sudo echo $LS_COLORS
rs=0:di=\e[38;2;00;00;255;1:ln=01;36:mh=00:pi=40;33:so=01;35:
do=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:
su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:
*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:
*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:
*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:
*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:
*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:
*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:
*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:
*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:
*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:
*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:
*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:
*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:
*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:
*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:
*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:
*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:
*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:
*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.pdf=00;32:*.ps=00;32:
*.txt=00;32:*.patch=00;32:*.diff=00;32:*.log=00;32:*.tex=00;32:
*.doc=00;32:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:
*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:
*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:
*.spx=00;36:*.xspf=00;36:

Broke the 'LS_COLORS' lines to make the forum layout behave.Chiitoo
Back to top
View user's profile Send private message
cboldt
Veteran
Veteran


Joined: 24 Aug 2005
Posts: 1046

PostPosted: Sat Mar 25, 2017 5:31 pm    Post subject: Reply with quote

Try this for the usual user

LS_COLORS="" ls kernel/

By the way, when I run that, I expected no color on the output, but the directories are still colored. I do not know the source of this.

One other experiment, again just as the regular user

ls --color=never kernel/

If the output is still mangled for the normal user, this experiment rules out the cause being any setting on $LS_COLORS, although the color assigned for "di" in $LS_COLORS is strange, but the same way for both users.
Back to top
View user's profile Send private message
iceamber
Tux's lil' helper
Tux's lil' helper


Joined: 06 Jun 2016
Posts: 94

PostPosted: Sat Mar 25, 2017 5:39 pm    Post subject: Reply with quote

cboldt wrote:
Try this for the usual user

LS_COLORS="" ls kernel/

By the way, when I run that, I expected no color on the output, but the directories are still colored. I do not know the source of this.

One other experiment, again just as the regular user

ls --color=never kernel/

If the output is still mangled for the normal user, this experiment rules out the cause being any setting on $LS_COLORS, although the color assigned for "di" in $LS_COLORS is strange, but the same way for both users.


It's OK with the script `LS_COLORS="" ls kernel/`,I remember that the LS_COLORS was set when using xterm

Thank you very much
Back to top
View user's profile Send private message
cboldt
Veteran
Veteran


Joined: 24 Aug 2005
Posts: 1046

PostPosted: Sat Mar 25, 2017 5:51 pm    Post subject: Reply with quote

LS_COLOR is set by the shell, bash, csh, zsh, or whatever. I don't know of settings by a TERM that would affect the output of the `ls` command.

Look in the file /etc/DIR_COLORS

Code:
# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
#NORMAL 00      # no color code at all
#FILE 00        # regular file: use no color at all
RESET 0         # reset to "normal" color
DIR 01;34       # directory


When I type `echo $LS_COLORS`, one section of it mirrors the "DIR 01;34" part of /etc/DIR_COLORS

Code:
di=01;34


As a certain user, who happens to have a ~/.dir_colors file with this line

Code:
DIR 44;33;01        # directory


The interesting part of $LS_COLORS follows the setting

Code:
di=44;33;01


That section (di=) of LS_COLORS for both of your users is VERY STRANGE. You should find out where it comes from. I suggested that it might come from /etc/DIR_COLORS, but there are MANY other places where that could be inserted.

The fact that LS_COLORS affects and seems to fix the issue, still does not get to the bottom of why your regular user and root get different reports from the `ls` command. And fixing LS_COLORS does not get to the bottom of the difference either, although I suspect it will fix it.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21602

PostPosted: Sat Mar 25, 2017 6:01 pm    Post subject: Reply with quote

cboldt wrote:
That section (di=) of LS_COLORS for both of your users is VERY STRANGE. You should find out where it comes from.

The fact that LS_COLORS affects and seems to fix the issue, still does not get to the bottom of why your regular user and root get different reports from the `ls` command. And fixing LS_COLORS does not get to the bottom of the difference either, although I suspect it will fix it.
Actually, we only know what value is used for the unprivileged user. Since iceamber used sudo instead of an actual root shell, both echo commands showed us the unprivileged user's value. This can be seen by comparing the output of echo $HOME and sudo echo $HOME. No difference will be observed, even though root's actual home is not the user's home. The takeaway is: beware blind use of sudo.
Back to top
View user's profile Send private message
iceamber
Tux's lil' helper
Tux's lil' helper


Joined: 06 Jun 2016
Posts: 94

PostPosted: Sat Mar 25, 2017 6:18 pm    Post subject: Reply with quote

cboldt wrote:
LS_COLOR is set by the shell, bash, csh, zsh, or whatever. I don't know of settings by a TERM that would affect the output of the `ls` command.

Look in the file /etc/DIR_COLORS

Code:
# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
#NORMAL 00      # no color code at all
#FILE 00        # regular file: use no color at all
RESET 0         # reset to "normal" color
DIR 01;34       # directory


When I type `echo $LS_COLORS`, one section of it mirrors the "DIR 01;34" part of /etc/DIR_COLORS

Code:
di=01;34


As a certain user, who happens to have a ~/.dir_colors file with this line

Code:
DIR 44;33;01        # directory


The interesting part of $LS_COLORS follows the setting

Code:
di=44;33;01


That section (di=) of LS_COLORS for both of your users is VERY STRANGE. You should find out where it comes from. I suggested that it might come from /etc/DIR_COLORS, but there are MANY other places where that could be inserted.

The fact that LS_COLORS affects and seems to fix the issue, still does not get to the bottom of why your regular user and root get different reports from the `ls` command. And fixing LS_COLORS does not get to the bottom of the difference either, although I suspect it will fix it.


I didn't find the place where LS_COLORS was set, I just set the LS_COLORS with the script `export LS_COLORS=""`, and the issue fixed.
Back to top
View user's profile Send private message
cboldt
Veteran
Veteran


Joined: 24 Aug 2005
Posts: 1046

PostPosted: Sat Mar 25, 2017 7:04 pm    Post subject: Reply with quote

Where did you put the script `export LS_COLORS=""`?

LS_COLORS is customarily set by the command `dircolors`, which reads /etc/DIR_COLORS and ~/.dir_colors

The command `dircolors` is set, on my system, in /etc/bash/bashrc ... but that is not then end of the possibilities.

Hu wrote:
Quote:
Actually, we only know what value is used for the unprivileged user.


That is a good point. the `sudo ls` command definitely does NOT us $LS_COLORS (I get a color-free display), but 'echo $LS_COLORS` always shows $LS_COLORS of the person invoking sudo.
Back to top
View user's profile Send private message
iceamber
Tux's lil' helper
Tux's lil' helper


Joined: 06 Jun 2016
Posts: 94

PostPosted: Sat Mar 25, 2017 7:58 pm    Post subject: Reply with quote

cboldt wrote:
Where did you put the script `export LS_COLORS=""`?

LS_COLORS is customarily set by the command `dircolors`, which reads /etc/DIR_COLORS and ~/.dir_colors

The command `dircolors` is set, on my system, in /etc/bash/bashrc ... but that is not then end of the possibilities.

Hu wrote:
Quote:
Actually, we only know what value is used for the unprivileged user.


That is a good point. the `sudo ls` command definitely does NOT us $LS_COLORS (I get a color-free display), but 'echo $LS_COLORS` always shows $LS_COLORS of the person invoking sudo.



Just run the script in unprivileged user
Back to top
View user's profile Send private message
cboldt
Veteran
Veteran


Joined: 24 Aug 2005
Posts: 1046

PostPosted: Sat Mar 25, 2017 9:00 pm    Post subject: Reply with quote

The problem will come back then, when you login again, or when you reboot.
Back to top
View user's profile Send private message
Tony0945
Watchman
Watchman


Joined: 25 Jul 2006
Posts: 5127
Location: Illinois, USA

PostPosted: Sat Mar 25, 2017 9:20 pm    Post subject: Reply with quote

Quote:
Code:
iceamber@localhost:~ $ LANG=C /bin/ls kernel/
gdb-7.11  gdb-7.11.tar.gz  linux-0.12  linux-2.6.0  linux-3.18.44  linux-3.18.44.tar  linux-4.7

iceamber@localhost:~ $ LANG=C ls kernel/
db-7.11  gdb-7.11.tar.gz  inux-0.12  inux-2.6.0  inux-3.18.44  linux-3.18.44.tar  inux-4.7


ls and /bin/ls are giving different results. What is the result of "which ls"? It should be "/bin/ls"
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Sat Mar 25, 2017 9:34 pm    Post subject: Reply with quote

Tony0945 wrote:
ls and /bin/ls are giving different results. What is the result of "which ls"? It should be "/bin/ls"

Tony0945 ... it's not the path, it's what's in the env, for some reason $LS_COLORS has garbage control character's in it ... why, I can't say.

best ... khay
Back to top
View user's profile Send private message
Tony0945
Watchman
Watchman


Joined: 25 Jul 2006
Posts: 5127
Location: Illinois, USA

PostPosted: Sat Mar 25, 2017 9:40 pm    Post subject: Reply with quote

khayyam wrote:
Tony0945 wrote:
ls and /bin/ls are giving different results. What is the result of "which ls"? It should be "/bin/ls"

Tony0945 ... it's not the path, it's what's in the env, for some reason $LS_COLORS has garbage control character's in it ... why, I can't say.

best ... khay
But the commands cited are absolutely identical except for path. That makes me suspect that ls is not pointing to /bin/ls but something else, maybe /usr/local/bin/ls. I do know that the hunt seems to have settled on the enviornment which is also logical.
Back to top
View user's profile Send private message
cboldt
Veteran
Veteran


Joined: 24 Aug 2005
Posts: 1046

PostPosted: Sat Mar 25, 2017 9:49 pm    Post subject: Reply with quote

`ls` could well be aliased. it is here, `alias ls=ls --color=auto`
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum