Exclude a directory from plocate on Linux? [closed] - linux

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 days ago.
Improve this question
So after using the locate command on Linux Mint a lot, I ran into the issue of every query returning rows upon rows of results in the /timeshift/ directory - what Linux Mint uses as OS save points.
If I used, say, locate anaconda activate.sh, what I might get is:
/home/user/.anaconda3/lib/python3.9/site-packages/spyder/plugins/ipythonconsole/scripts
/conda-activate.sh
/home/user/.anaconda3/pkgs/conda-4.12.0-py39h06a4308_0/info/test/tests/test-recipes/activate_deactivate_package/src/etc/conda/activate.d/activate.sh
/home/user/.anaconda3/pkgs/spyder-5.1.5-py39h06a4308_1/lib/python3.9/site-packages/spyder/plugins/ipythonconsole/scripts/conda-activate.sh
/timeshift/snapshots/2023-01-09_15-00-01/localhost/home/user/.anaconda3/lib/python3.9/site-packages/spyder/plugins/ipythonconsole/scripts/conda-activate.sh
/timeshift/snapshots/2023-01-09_15-00-01/localhost/home/user/.anaconda3/pkgs/conda-4.12.0-py39h06a4308_0/info/test/tests/test-recipes/activate_deactivate_package/src/etc/conda/activate.d/activate.sh
/timeshift/snapshots/2023-01-09_15-00-01/localhost/home/user/.anaconda3/pkgs/conda-4.12.0-py39h06a4308_0/info/test/tests/test-recipes/activate_deactivate_package/src/etc/conda/deactivate.d/deactivate.sh
/timeshift/snapshots/2023-01-09_15-00-01/localhost/home/user/.anaconda3/pkgs/spyder-5.1.5-py39h06a4308_1/lib/python3.9/site-packages/spyder/plugins/ipythonconsole/scripts/conda-activate.sh
/timeshift/snapshots/2023-02-10_04-00-01/localhost/home/user/.anaconda3/lib/python3.9/site-packages/spyder/plugins/ipythonconsole/scripts/conda-activate.sh
/timeshift/snapshots/2023-02-10_04-00-01/localhost/home/user/.anaconda3/pkgs/conda-4.12.0-py39h06a4308_0/info/test/tests/test-recipes/activate_deactivate_package/src/etc/conda/activate.d/activate.sh
/timeshift/snapshots/2023-02-14_20-00-01/localhost/home/user/.anaconda3/lib/python3.9/site-packages/spyder/plugins/ipythonconsole/scripts/conda-activate.sh
/timeshift/snapshots/2023-02-14_20-00-01/localhost/home/user/.anaconda3/pkgs/conda-4.12.0-py39h06a4308_0/info/test/tests/test-recipes/activate_deactivate_package/src/etc/conda/activate.d/activate.sh
/timeshift/snapshots/2023-02-14_20-00-01/localhost/home/user/.anaconda3/pkgs/conda-4.12.0-py39h06a4308_0/info/test/tests/test-recipes/activate_deactivate_package/src/etc/conda/deactivate.d/deactivate.sh
/timeshift/snapshots/2023-02-14_20-00-01/localhost/home/user/.anaconda3/pkgs/spyder-5.1.5-py39h06a4308_1/lib/python3.9/site-packages/spyder/plugins/ipythonconsole/scripts/conda-activate.sh
/timeshift/snapshots/2023-02-15_21-00-01/localhost/home/user/.anaconda3/lib/python3.9/site-packages/spyder/plugins/ipythonconsole/scripts/conda-activate.sh
/timeshift/snapshots/2023-02-15_21-00-01/localhost/home/user/.anaconda3/pkgs/conda-4.12.0-py39h06a4308_0/info/test/tests/test-recipes/activate_deactivate_package/src/etc/conda/activate.d/activate.sh
Only the top three results are relevant, so how would one exclude a directory?

Manually exclude a directory with grep
You can use the -v option to get grep to output all the elements that don't match the supplied Regex, like so:
locate anaconda activate.sh | grep -v "/timeshift/"
This will print only paths which don't contain the string /timeshift/
Permanently exclude a directory
Since the issue with the timeshift directory is a frequently re-occuring one, you might want to permanently exclude it from all plocate queries.
As per the updatedb documentation, you may add /timeshift to PRUNEPATHS= in /etc/updatedb.conf. Once updatedb has been run, all plocatequeries should now exclude the /timeshift directory.

Related

Is output of a "dir" command same in all distributions of Linux? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I'm preparing a batch compiling sh file in Ubuntu. It is using dir command to get a list of files (and some string processing to extract names). But this may not be the best way (but easy enough) of getting list.
Question: do all Linux distros answer "dir" command same?
dir /usr/lib/nvidia-*
/usr/lib/nvidia-396:
alt_ld.so.conf libnvidia-cfg.so.396.54
bin libnvidia-compiler.so
ld.so.conf libnvidia-compiler.so.1
libEGL_nvidia.so.0 libnvidia-compiler.so.396.54
Yes, the dir tool should work the same across any distribution, provided the distribution doesn't have its own modified version or has this tool missing etc.
You might find this helpful for some background into dir tool
https://www.howtoforge.com/linux-dir-command/
You can use tree command to get all files and filter whatever you want.
tree -f -i .|grep .*\.py$ here it greps all .py files.
here's tree doc
example:
root#fdada3432377:/usr/src/app# tree -f -i conn* |grep .*\.py$
connection/__init__.py

how to deal with file without a name in linux? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I'm a green hand to linux using the vmware called Parallels on my mac and the edition I use is CentOS7.When I use the ls -al command, I found some files don't have name as follow in surprise:
I just want to know as these files are seemingly generated at a same time, what are they? how to delete them?
On *nix system every file has an atrribute called i-node. You can find with command
ls -i
when you have i=node number you can delete file by
find . -inum 782263 -exec rm -i {} \;
You could use any other commands not only rm.
more details you can find here
http://www.cyberciti.biz/tips/delete-remove-files-with-inode-number.html
As the d in drwxr-xr-x states, those are folders (or at least the filesystem thinks they are). You may use Midnight Commander to delete them. You may already have it installed on your machine, try to run mc to see if it's there.

why I can not permanently remove a file from linux? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
Today,I encounter a very tough problem which cost me nearly 6 hours.
When I remove a file called ha_wan.conf using rm -rf ha_wan.conf command under /etc directory,Success.When I use ls -al command to see the result,The file disappear.
But when I reboot the linux system,same file named ha_wan.conf come back,located under /etc/ directory.
I tried to delete it many many times,It is the same result.
What should I do,I want to permanently remove that file.Thanks.
There's no magic. You removed the file. If you still see it after a reboot, it means one of two things:
(very likely) Some service recreates the files on boot, or periodically. You can probably use standard system tools to find out which package contained that file. (for example dpkg -S ha_wan.conf in debian-like systems)
(unlikely) You're running some interesting system which uses a temporary filesystem in /etc. If you're using a standard desktop distribution, that's improbable. But if it's some kind of router / special device, then it could happen.

in linux can't find a file even though "locate" returns its location [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I installed postgis-9.3 on ubuntu 14.04, it should have a function called "shp2pgsql". when I "locate" its location, it returns the results, but actually it's not there.
yang#ubuntu:~$ locate shp2pgsql-gui
/home/yang/shp2pgsql-gui (1).1
/usr/bin/shp2pgsql-gui
/usr/share/man/man1/shp2pgsql-gui.1.gz
yang#ubuntu:~$ /usr/bin/sh
sha1pass sha384sum showconsolefont shred
sha1sum sha512sum showfont shuf
sha224sum shasum showkey
sha256sum shotwell showrgb
yang#ubuntu:~$ /usr/bin/shp2pgsql-gui
-su: /usr/bin/shp2pgsql-gui: No such file or directory
Where can i find shp2pgsql? Thank you
locate tells you which files did exist when its database was last updated; that (not needing to look at the real, current state of the filesystem) is why it's so fast. It doesn't assure you they're still there now. Run sudo updatedb if you want to bring the locate database up-to-date.
Locate query one or more database created by updated and it doesn't check whether the file exists or not. For more details you can read its man page.
If you are not able to find the file at the location returned by locate, you can try the following find command if you still think that the file exists at some other location.
find / -name "shp2pgsql-gui" -type f

Does unix 'find' give the same order every time? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
If I run find (Ubuntu, specifically), can I expect it to give me the same order of results every time? (Assuming, of course, that the actual files haven't changed.)
In other words, if I run
$ find foo
and it gives me
bar.txt
foo.txt
can I expect that it will never give me
foo.txt
bar.txt
?
The answer is "probably" but you shouldn't rely on it because any number of things can affect it.
What order do you want the files in? Decide on that and then use a find command (perhaps piped into sort) which reproducibly gets the result you need.
The order of the files is determined by the fine details of the filesystem format and the filesystem driver. You can't rely on it. Depending on the filesystem and operating system, here are things that might change the order:
A file is created or removed in a traversed directory (even if none of the listed files changed).
The files are moved around (e.g. transfered to a different filesystem or restored from backup).
A defragmenter or filesystem check ran and decided to move things around.
If you want a reproducible order, sort the results. find … | sort will do nicely if none of the file names contain newlines.

Resources