Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I may be asking a basic question, but I could not find a satisfactory explanation online.
I use an Ubuntu 18.04 Operating System and I was in search of a folder that I knew it should have been there, but it was not, or at least it did not appear in the list when I was typing the command "ls". Then I used the command "find" {folder_name} and the folder suddenly appeared there after typing "ls".
Could someone explain to me why this happened and if it is really related to the command "find"?
By default, ls searches only the current directory (-R changes this). On the other hand, by default, find searches everything under the current directory. Therefore, if you have this structure:
/dir1/dir2/myfile
and you do 'ls' or 'ls myfile' from /dir1 (or from /), you will not find it. However, 'find myfile' will find it, but only show you the filename, not which directory it was found in. A more useful command in this situation would be 'ls -R|grep myfile'.
From your description, I'm not sure if this fits your problem, but maybe it'll help.
are you trying to find out if this is normal behavior?
if your description of events is correct...
when you entered these commands in this order: ls, find foldername, ls
these were your results:
ls ---you did not see? the file listed
find foldername ---i am not sure what your result were?
ls ---for some strange reason the folder is now listed!
as long as you did not change directories, i would say this is not normal behaviour
am i on the right track? [i am far from an expert]
The only thinkable mechanism is an automount.
Check with df foldername if it's a separate (mounted) filesystem.
If yes:
The classic autofs always shows the folder. Only ls -l shows arbitrary attributes when not mounted.
I am not yet familiar with the x-systemd.automount - check for this option in /etc/fstab!
Another "late mount" mechanism might exist.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,800
Rep:
Quote:
Originally Posted by serenap
Dear all,
I may be asking a basic question, but I could not find a satisfactory explanation online.
I use an Ubuntu 18.04 Operating System and I was in search of a folder that I knew it should have been there, but it was not, or at least it did not appear in the list when I was typing the command "ls". Then I used the command "find" {folder_name} and the folder suddenly appeared there after typing "ls".
Could someone explain to me why this happened and if it is really related to the command "find"?
Thank you very much in advance!
Try:
Issue 'ls' as '\ls'. This will ignore any alias that's defined.
If the above works, issue "alias | grep ls" and see if there's an unusual alias defined that's affecting the way 'ls' is working. (For example, using some odd switch like '--hide=...'.) If you find an alias defined for 'ls', do you really need it? If it's defined systemwide and you can't -- or do not wish to -- remove it, you can override with an alias of your own:
Code:
alias ls='\ls' # The plainest vanilla ls you can get
alias ls='\ls <other switches you prefer> # Plain vanilla but customized by you
alias ls='_ls' # Vanilla but uses /etc/DIR_COLORS
(I ran across that last one in some documentation ages ago. Don't ask where; I've forgotten the source.)
You'd need to put one of those in a file and source it in your .profile or simply include it in the .profile directly.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.