Bug 275369

Summary: the ls command does not work correctly
Product: Base System Reporter: wildzander
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Open ---    
Severity: Affects Many People CC: lwhsu, salvadore, xxjack12xx
Priority: ---    
Version: 14.0-RELEASE   
Hardware: amd64   
OS: Any   

Description wildzander 2023-11-27 07:41:31 UTC
Regards.

System: FreeBSD-14.0-RELEASE-amd64.
The ls command works correctly if I am logged in as root. If I am logged in as a regular user, the ls command does not work properly.

Logged in as root:
------------------------------------------------------------------
/bin/sh
root@fbsd:~ # pwd
/root
root@fbsd:~ # ls
.cache		.cshrc		.local		.profile
.config		.k5login	.login		.sh_history
root@fbsd:~ # ls -l
total 25
drwx------ 3 root wheel    3 25 lis 20:05 .cache
drwx------ 3 root wheel    3 25 lis 20:05 .config
-rw-r--r-- 2 root wheel 1011 10 lis 09:11 .cshrc
-rw-r--r-- 1 root wheel   66 10 lis 09:49 .k5login
drwx------ 3 root wheel    3 25 lis 20:05 .local
-rw-r--r-- 1 root wheel  316 10 lis 09:11 .login
-rw-r--r-- 2 root wheel  495 10 lis 09:11 .profile
-rw------- 1 root wheel 1083 26 lis 10:17 .sh_history
-rw-r--r-- 1 root wheel 1191 25 lis 20:06 .shrc
root@fbsd:~ #
__________________________________________________________________
Logged in as a user:
------------------------------------------------------------------
test@fbsd:~ $ echo $SHELL
/bin/sh
test@fbsd:~ $ pwd
/home/test
test@fbsd:~ $ ls
test@fbsd:~ $ ls -l
total 0
test@fbsd:~ $
__________________________________________________________________

Am I doing something wrong, or is this a bug?

Thank you.
Comment 1 Jack 2023-11-27 07:49:11 UTC
The default for ls running as root is ls -A
The default for ls running as a user doesn't use -A
Comment 2 Li-Wen Hsu freebsd_committer freebsd_triage 2023-11-27 08:06:39 UTC
Thank you for your report. The behavior of the ls command you're observing seems normal. The root user's directory (/root) contains files, so ls lists them. In contrast, the regular user's directory (/home/test) is very possible to be empty, which is why ls shows no output there. This is expected when a directory has no files.

Please check to use the ls with different users to list the same directory, and report if it outputs differently.
Comment 3 wildzander 2023-11-27 13:01:15 UTC
Thank you for your answers. The /home/test/ directory is not empty !. It contains several different files and subdirectories. That's why the ls command seems to work wrong.
Comment 4 Li-Wen Hsu freebsd_committer freebsd_triage 2023-11-27 13:07:40 UTC
(In reply to wildzander from comment #3)
As comment #1 pointed out, can you try with `ls -A` as a normal user?

Also, can you check using root to list what's in /home/test ?
Comment 5 wildzander 2023-11-27 14:24:50 UTC
Thank you. I'll give it a try when I'm on the computer. I'll post the results then.
Comment 6 Lorenzo Salvadore freebsd_committer freebsd_triage 2023-11-28 11:04:13 UTC
I had a similar issue due to my expectations of /home being a symlink to /usr/home (or viceversa, I never remember) and thus I made some mistakes mounting zfs filesystems.

Try "ls /usr/home/test", I think you will find your files there. Then try to fix your mountpoints or create the right symlink.
Comment 7 wildzander 2023-11-29 06:56:05 UTC
Regards.
The ls -A command works well.

test@fbsd:~ $ ls -A
total 33
drwx------ 3 test test	   3 27 lis 17:46 .cache
drwx------ 3 test test	   3 27 lis 17:46 .config
-rw-r--r-- 1 test test	 950 26 lis 09:47 .cshrc
drwx------ 3 test test	   3 27 lis 17:46 .local
-rw-r--r-- 1 test test	 311 26 lis 09:47 .login
-rw-r--r-- 1 test test	  79 26 lis 09:47 .login_conf
-rw------- 1 test test	 289 26 lis 09:47 .mail_aliases
-rw-r--r-- 1 test test	 255 26 lis 09:47 .mailrc
-rw-r--r-- 1 test test	 966 26 lis 09:47 .profile
-rw------- 1 test test	 133 26 lis 13:28 .sh_history	
-rw-r--r-- 1 test test	1003 26 lis 09:47 .shrc
test@fbsd:~ $

I don't understand why the output of ls -A is "total 0"? Either there should be no output (as with the ls command) or the output should be correct, but in any case the output should not be nonsensical.
This can be incomprehensible and confusing for a user coming from Linux.
It might be a good idea to set the ls command to ls -A for the user, just as it is set for the superuser.

Can I have one off-topic question?
I'm from the Czech Republic and I use the cz.kbd keyboard map with freebsd. This keyboard map doesn't suit me very well, so I decided to create another Czech keyboard map.  When this keyboard map is ready, where and to whom can I send it so that it can be integrated into freebsd and used by others? 

Thank you and have a nice day.
Comment 8 wildzander 2023-11-29 07:01:43 UTC
(In reply to wildzander from comment #7)
I spelled it wrong. It should have been"
I don't understand why the output of ls -l is 0 in total? etc......