2

I have an embedded device with wdlinux (White Dwarf 2.0). I can access this linux using ssh or ftp.

Yesterday I performed "updatedb 1>/dev/null 2>/dev/null" manually. (It will be performed as cronjob everyday morning). Today the linux system behaves strangely: (1) the command "ls" list no files any more. (If I log in using ftp, I can see all files) (2) The command "netstat" shows nothing as well.

I just executed "updatedb" without any arguments again. After that "ls" worked one time and then does not work again.

I am now totally confused. Any hints are appreciated.

2
  • When "ls" doesn't work (exits without any output I assume), what does "pwd" show? Have you tried giving "ls" a file, that you know is there, as argument?
    – Inshalla
    Jul 16, 2009 at 8:22
  • Try cd / followed by echo * .
    – kmarsh
    Jul 16, 2009 at 12:24

9 Answers 9

4

updatedb is not related to ls. It is used for locate. Check for where is ls located using command

which ls

or

type ls

Which ls should tell you it is in '/bin/ls' and the alias for ls command if it exists. Try dir command if it is present on that Linux. Just to see if someone messed up ls to create some kind of backdoor or ls executable is corrupted. dir might still be working perfectly. If dir is not there or gives strange output, I would suggest running fsck on the filesystem.

2
  • Executing /bin/ls might work, if there is an alias for it..
    – Dentrasi
    Jul 19, 2009 at 10:00
  • Agreed, If it is problem with bad alias then executing ls with full path '/bin/ls' might work. Jul 20, 2009 at 12:44
8

Are they hidden files? If so try:

ls -la
3
  • 1
    If your version was correct, the ftp command would not display it without an extra option. FTP clients normally hide hidden files per default.
    – please delete me
    Jul 16, 2009 at 8:26
  • @guerda - With some FTP servers, the behaviour can also be configured on the server side. For example proftpd with ListOptions "-a" will list hidden files by default (See: proftpd.org/docs/directives/linked/config_ref_ListOptions.html)
    – StackKrish
    Jul 16, 2009 at 9:42
  • StackKrish: K, haven't said anything. :)
    – please delete me
    Jul 16, 2009 at 11:26
2

You did not mention what file system you are using.

If the current directory disappears "ls" will show nothing. For example:

$ mkdir tmp
$ cd tmp
$ cp /etc/passwd /etc/group .
$ ls
passwd group

$ rm -rf  $(pwd)
$ ls
(empty)
$ mkdir $(pwd); cp /etc/passwd /etc/group $(pwd)
$ ls
(empty)
$ ls $(pwd)
passwd group
$ ls -lid . $(pwd)
(show different inodes)
$ cd $(pwd)
$ ls
passwd group

For netstat to succeed, I believe you need to have /proc mounted.

Is there some strange side effect in the way you run the updatedb? If this is reproducible, maybe you would like to run updatedb without discarding the output, especially stderr, to see if you see something interesting?

1

Any chance your machine has been hacked? It's a bit blatant, but I've seen attacks that disable things like netstat to hide themselves.

Do you have disk space free? (df -h)

1

Run find and see if it shows anything. If it does then something is wrong with your ls.

0

Compare the result of the following command if ls works and if not:

which ls

If the output change, something is very wrong with your system. If the output is the same, propably the file permissions are wrong.

0

Suspend this answer for now... I am trying to figure out what this implies.
Arjan makes a correct comment, you should hit a 'command not found' error if path resolution fails.


Old.
Many times embedded linuxes do not come with a proper environment setting and you could be running without any PATH references. First thing to do should be,

echo $PATH

if that does not show anything (which is what i suspect), you need to set up path properly before any command outside the shell (echo is part of the shell) will work.

2
  • I'd say that "ls list no files any more" indicates that the command is executed without any output? So, I guess there's no "command not found" but empty output.
    – Arjan
    Jul 19, 2009 at 10:48
  • 1
    @Arjan, I think, I did not read the question quite well...
    – nik
    Jul 19, 2009 at 11:34
0

This issue can be solved by moving the directory to a new directory:

Example: I have a directory olddir/ that contains files foo.txt and bar.txt, typing ls shows no files present

mv olddir/ newdir

now when I type ls in the new directory, foo.txt and bar.txt appear.

You can then move newdir/ back to olddir/ if you wish and the files will be present

-1

below steps has helped me to fix the no output issue for ls -l

for this you need to update command related rpm packages in your system.

check the binary file for ls command.

[root@tst-11 bin]# which ls
/usr/bin/ls

Get the rpm for any binary/configuration file

[root@tst-11 bin]# rpm -qf /usr/bin/ls
coreutils-8.22-23.0.1.el7.x86_64

update the rpm installed in your linux system.

[root@tst-11 bin]# yum update coreutils-8.22-18.0.1.el7.x86_64

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .