[root@rocky8 ~]# ls -lha /home/ian/
total 16K
drwx------. 2 ian ian 83 Oct 4 13:42 .
drwxr-xr-x. 3 root root 17 Aug 24 15:47 ..
-rw-------. 1 ian ian 147 Oct 4 13:42 .bash_history
-rw-r--r--. 1 ian ian 18 Apr 12 2022 .bash_logout
-rw-r--r--. 1 ian ian 141 Apr 12 2022 .bash_profile
-rw-r--r--. 1 ian ian 376 Apr 12 2022 .bashrc
the only thing I can think is perhaps during installation you selected a particular security profile? Or maybe this was enabled later or something? Can you confirm if this was the case or not?
Otherwise, there is simply no reason for root not being able to see those files - just like my example shows. Mine was a basic Rocky install, no security profile selected, selinux enabled.
RL8 is installed as a VM running on top of FreeBSd-12.3.
As far as I can recall I did not do anything other than take the defaults during the install. However, if there were required choices then I cannot remember which ones I selected. It was intended to be a plain vanilla install so there was no specific customization that I performed.
The reason you didnât see anything in your first example is that you only had â.filesâ in stromasys and âls -lâ wonât show any of those files. If you had used ls -la first time around you would have seen the dot files.
I have no idea why it doesnât work, looks very weird to me. I have a minimal install, and it works properly. Hopefully someone else will jump in and might be able to help, Iâm out of ideas. Thatâs just not normal behaviour.
Interesting though. Here I created a test directory in /home with a few dot files in it. What seems to through things off is the use of the * character .
[root@t4s ~]# ls -l /home/testuser/*
ls: cannot access '/home/testuser/': No such file or directory
[root@t4s ~]# ls -la /home/testuser/
ls: cannot access â/home/testuser/*â: No such file or directory
[root@t4s ~]# ls -la /home/testuser/
total 8
drwxr-xr-x 2 jbk jbk 4096 Nov 11 13:28 .
drwxr-xr-x. 5 root root 4096 Nov 11 13:26 âŚ
-rw-râr-- 1 jbk jbk 0 Nov 11 13:28 .afile
-rw-râr-- 1 jbk jbk 0 Nov 11 13:28 .anotherfile
-rw-râr-- 1 jbk jbk 0 Nov 11 13:28 .ditto
You do two different commands and get two different outputs.
That is as it should be.
$ ls
$ ls *
ls: cannot access '*': No such file or directory
$ ls -a
. .bash_history .bashrc .local .ssh
.. .bash_logout .emacs.d .lesshst .profile
$ ls -a *
ls: cannot access '*': No such file or directory
Remember that shell does do expansion on command-line, before any command it invoked.
In a directory, where there are at most hidden files, the shell cannot expand the * into words.
Therefore, command ls gets the unexpanded /home/stromasys/* as parameter and attempts
to show that verbatim âfileâ.
You would get that with any non-existent name:
$ ls foo
ls: cannot access 'foo': No such file or directory
$ ls -a foo
ls: cannot access 'foo': No such file or directory
Had you used the same command after creating the file, you would probably got:
[root@vhp3k-06 ~]# ls -la /home/stromasys/*
-rw-rw-r--. 1 stromasys stromasys 0 Nov 11 09:29 touchme
I realize that. Please bear in mind that I was trying different approaches to see if I was doing something wrong. The critical instruction and result that led to the experimentation was this:
[root@vhp3k-06 ~]# ls -la /home/stromasys/*
ls: cannot access '/home/stromasys/*': No such file or directory
Please note that both -l and -a are specified and the glob character * follows the path string.
After I manually added a file to that directory the results from ls were as one expects. I am not saying that I did not make a mistake somewhere. But I do not see it.
Because there are currently only hidden files in the stromasys directory and you need to have shopt -s dotglob set (which is not set by default) in order for bash to expand hidden files.
Youâre using a different command to list them here. Youâre no longer using a glob (*) to expand the files and so ls is expanding them instead, and the -a switch to ls tells it to show hidden files.
Again, it boils down to the command youâre using to list them. You can see them for the same reasons as in your second example.
It doesnât, using ls in different ways changes its behavior, though.
What can I say: I cheat!! I simply use Midnight Commander (mc) and it will show you the hidden f files, and the contents⌠just canât work on them. Canât have everything.