Thursday 14 November 2019

linux - Detect all links that exists pointing to /tmp?


I want to find out which file links exist that point to my /tmp folder on Ubuntu.


Background:
I had a problem, that my /tmp folder privileges were changed by some accident to 755. The system wasn't running correctly any more as a user other than root.


Maybe there is a link to /tmp somewhere and the command


chmod 755 . -Rf 

called there in that folder was affecting the main /tmp folder.


I had to repair it with:


chmod 777 /tmp
chmod +t /tmp
sudo chown root:root /tmp

I have only one file system, so there shouldn't be a problem with that.



Answer



try this:


find / -path /proc -prune -o \( -lname '*/tmp' -o -lname '*/tmp/' \) -exec ls -l {} \;

Sample output:


# find / -path /proc -prune -o -lname '*/tmp' -exec ls -l {} \;
lrwxrwxrwx. 1 sergey sergey 4 Sep 22 11:27 /home/sergey/xxx/tmp -> /tmp
lrwxrwxrwx. 1 root root 10 Jun 20 10:28 /usr/tmp -> ../var/tmp
find: `/run/user/sergey/gvfs': Permission denied

No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...