How to list all files you can cd to? -(ls -a doesn't work..)

My apologies if this is a question easily found with google.. but I've done some searching, and not found anything yet. Maybe this post can make it easier for the next person.

I can cd to a directory, even if I can't see it with ls. "Irritating" is the best description for this. Particularly when installing a system from a live cd I've become used to certain file system structures that seem to just not be there anymore. Except that I can cd to it. So clearly it is. I've tried ls -a, and a number of other things. Finally I found this which helps confirm that I really am -not- smoking it. ..I'll stop this.. rant? because I'm sure this is a trivial question answerable in moments.. (..by somebody in the know..)
 
This isn't Linux for starts. There are slight differences in FreeBSD file hierarchy to Linux and OpenBSD as well, and some files and directories are hidden by design.

If you use x11-fm/xfe as a file manager you can have it show hidden files and directories.

occult.png


I really don't know if that answers your question but all is well.
 
This isn't Linux for starts. There are slight differences in FreeBSD file hierarchy to Linux and OpenBSD as well, and some files and directories are hidden by design.

If you use x11-fm/xfe as a file manager you can have it show hidden files and directories.

View attachment 10401

I really don't know if that answers your question but all is well.
awesome! that will be very helpful for somebody, maybe even me! ..I'm specifically looking for "the command-line" way of getting it, as I was used to with linux. so you're telling me that here of all places, with freebsd, doing this kind of thing with the command-line is actively discouraged.. you're recommending a gui? ..fascinating..
 
awesome! that will be very helpful for somebody, maybe even me! ..I'm specifically looking for "the command-line" way of getting it, as I was used to with linux. so you're telling me that here of all places, with freebsd, doing this kind of thing with the command-line is actively discouraged.. you're recommending a gui? ..fascinating.
Given the lack of clarity and details in the original question, the response from Trihexagonal was quite reasonable.

If you want answers specific to your situation, you need to provide specific details regarding your problem.
 
Given the lack of clarity and details in the original question, the response from Trihexagonal was quite reasonable.

If you want answers specific to your situation, you need to provide specific details regarding your problem.
right. looking back at it, I didn't explicitly state that I was looking for a solution via the command line. my apologies! I've actually now downloaded xfe, and it looks great! it's better than thunar at least in the sense that it doesn't offer you a button to unmount that doesn't work! 😂
 
mikethe1wheelnut said:
I was looking for a solution via the command line.

The options -a and -A for command ls will show you files and directories starting with a dot too. For command line work mc will show these files just like xfe.
 
You'll have to tell us an example of such a 'mystery' directory. There are some special cases where this is expected (like the .zfs directory on certain ZFS filesystems), and some cases where this indicates a problem (like "overmounted" directories).
 
You'll have to tell us an example of such a 'mystery' directory. There are some special cases where this is expected (like the .zfs directory on certain ZFS filesystems), and some cases where this indicates a problem (like "overmounted" directories).
sure. example:
root@ozzie:~ # ls -a -l
total 32
drwxr-xr-x 2 root wheel 512 Jul 2 13:48 .
drwxr-xr-x 19 root wheel 1024 Jul 2 19:30 ..
-rw-r--r-- 2 root wheel 1089 Oct 23 2020 .cshrc
-rw------- 1 root wheel 1549 Jul 2 13:48 .history
-rw-r--r-- 1 root wheel 149 Oct 23 2020 .k5login
-rw-r--r-- 1 root wheel 392 Oct 23 2020 .login
-rw-r--r-- 2 root wheel 470 Oct 23 2020 .profile
-rw-r--r-- 1 root wheel 2254 Jun 25 20:44 xorg.conf.new
root@ozzie:~ # cd /dev
root@ozzie:/dev #
so, I can cd to /dev, even when it isn't listed by ls..
 
You're inside the directory /root. ls lists everything from that node, but not from the above directory /. So you have two options: Saying ls which directories content you want to see (ls -a /), or first go to the directory you want to see (cd / && ls -a). In which directory you are actually you often can see at the prompt (~ is a home-directory), or by executing pwd.
 
so, I can cd to /dev, even when it isn't listed by ls..
When you're in ~ (which is the same as /root for the root user), ls will not show you /dev, because /dev is not a sub-directory of /root.

It's like saying "What's in this room?" when you're in the living room. It will tell you: TV, sofa, chairs. But it won't tell you what's in the garage. For that, you have to go to the garage first: cd /.
 
ls (without arg) list the current directory.
cd permit to change the current directory.
So ls list directories that you can access with cd only if you do not start the cd argument with '/' or '..'

To show dev in a list with ls, you have to ask the right question 'ls /' (show me all files in the / directory).


Sorry for the presentation, I use my phone and can not select code formating
 
awesome! that will be very helpful for somebody, maybe even me!
Joy...

..I'm specifically looking for "the command-line" way of getting it, as I was used to with linux. so you're telling me that here of all places, with freebsd, doing this kind of thing with the command-line is actively discouraged.. you're recommending a gui? ..fascinating..
If you could read documentation like you read something into what I said, neither of us would have needed to post.

Please show me in any post where I have discouraged use of the command line or recommended a GUI solution when a command would suffice.

And someone who uses a DE complaining about a using a GUI is like an alcoholic complaining they only had Cristal at the liquor store when they wanted MD 20-20.

I've actually now downloaded xfe, and it looks great! it's better than thunar at least in the sense that it doesn't offer you a button to unmount that doesn't work!
Great. Now, dump XFCE and everything that came bundled with it and try a WM like x11-wm/fluxbox that doesn't force the applications on you someone else thinks you need on your desktop. I'm putting the members screenshot section back up on my site as examples of them being used and you can see much the same thing in the screenshot thread.

Oh, and ls, not one of the commands I use on a regular basis. But I don't do a lot of things the way other people do them, edit files everyone seems to do as SOP or even have them on my computer.
I taught myself to use FreeBSD and ports as a PC-BSD beta tester and didn't think the handbook applied to PC-BSD. it works for me the way I want it to the way I do it every time no matter how other people do it.

Life in the real world should work like that for me but it does not.
 
it's better than thunar at least in the sense that it doesn't offer you a button to unmount that doesn't work!
Buttons? We don't need no stinking buttons!

Code:
mount -v -t msdosfs /dev/da0s1 /media/da0s1

umount -v -t msdosfs /dev/da0s1 /media/da0s1

mount -v -t msdosfs -F32 -o large /dev/da0s1 /media/da0s1

umount -v -t msdosfs -F32 /dev/da0s1 /media/da0s1

I'll make a FreeBSD usr of you yet.
 
… looking for "the command-line" way …

… I can cd to /dev, even when it isn't listed by ls.

Code:
% sudo bfs -s -maxdepth 2 -type d / | grep dev
grahamperrin's password:
/dev
/dev/backlight
/dev/dri
/dev/drm
/dev/enc@n3061686369656d30
/dev/fd
/dev/gpt
/dev/input
/dev/led
/dev/msdosfs
/dev/pts
/dev/reroot
/dev/shm
/dev/usb
/etc/devd
%

bfs(1) <https://www.freebsd.org/cgi/man.cgi?query=bfs&sektion=1&manpath=FreeBSD+13.0-RELEASE+and+Ports>

sysutils/bfs
 
..in case anybody wonders, the answers thus far have convinced me that this -is- indeed a non-trivial question (..by my standards..), so my instinct is to properly absorb all the answers before marking it solved.. :)
 
ls (without arg) list the current directory.
cd permit to change the current directory.
So ls list directories that you can access with cd only if you do not start the cd argument with '/' or '..'
Code:
root@bakemono:/ # man ls
*snip*
If no operands are given, the contents of the current directory are
     displayed.  If more than one operand is given, non-directory operands are
     displayed first; directory and non-directory operands are sorted
     separately and in lexicographical order.

The following options are available:

     -A      Include directory entries whose names begin with a dot (`.')
             except for . and ...  Automatically set for the super-user unless
             -I is specified.

Let's test that theory against your theorem:

Code:
jitte@bakemono:~ $ su
Password:
root@bakemono:/home/jitte # cd /
root@bakemono:/ # ls
.cshrc        bin        etc        mnt        sbin
.profile    boot        home        net        sys
.snap        compat        lib        proc        tmp
.sujournal    dev        libexec        rescue        usr
COPYRIGHT    entropy        media        root        var
oot@bakemono:/ #

All is well and working as documented it should.
If you're comfortable enough with the command line to run man ls.
 
Back
Top