Can't see files with Symlink - bash

I need my client to be able to see the file in the directory they are allowed on. So I soft link the directory they are allowed on but can't see the files inside even tho they have the right (rwx).
ex:
/home/user1/project1.link/(couple of files)**
/clients/client_shamwow/project1/(couples of files)
**: Can't see the files.
This is the line I used:
ln -s /clients/client_shamwow/projet_prod /home/user1/projet_prod
is there something wrong that I am doing so they can't see the files in project_prod or I should use something else?

Your command doesn't match your example, but I assume you mean /home/user1/project1.link is a soft (symbolic) link, and when you run ls it lists just that name, rather than the contents of the directory the link points to. If that's the case, add the -L option to your ls command.
ls -lL /home/user1/project1.link
The man page says:
-L, --dereference
when showing file information for a symbolic link, show information
for the file the link references rather than for the link itself
Another way is simply to append /. to the end of your command, as in
ls -l /home/user1/project1.link/.
If that doesn't answer your question, I think you need to be more clear, and perhaps clean up the inconsistencies in your question. Even show some real output and the commands you ran.

Solved. No idea what happend. I just recreated the link the exact same way I did before and now I am able to see AND modify the files as the user1 w/o him being able to go anywhere else than what is in the folder project_prod. Thx for your time :)

Related

Bash: Find which symbolic links exists to a specific file

Given a file somewhere in the file system, can I find out which symbolic links exists that point to that file?
The purpose of this would be to determine if a file can be successfully deleted, or if deleting the file would leave behind a bunch of dead symbolic links.
If you do an "ls -l" in a directory that contains a file which is a symbolic link, the ls command will show you where the link goes. I'm looking for the reverse of that, which is getting a list of symbolic links around the file system which point to a specific file.
For example:
$ ls --optionToFindSymLinks? ./thefile.txt
/home/user/dir/file.txt -> ./thefile.txt
/home/otheruser/dir/file2.txt -> ./thefile.txt
2 symbolic links found
I realise that unmounted file systems might contain links that I won't be able to find, but this would not be a problem in my case.
Edit: Attempt at clarification
There is no reverse search. You have to do the work yourself. Get a list of all the symbolic links in your system and check which of them point to the file you are interested in.

Terminal says there is no file

enter image description here
PLEASE HELP! I can't seem to run my file. I've compiled it so it should run shouldn't it?
It also happens to my other files and I can't seem to fix it.
Ok, so a quick point of notice:
It is usually appreciated if you post your code directly in your question and use the code markup for that. It makes it easier to answer your question and prevents the image from turning into a dead-link at one point in time.
Then, regarding your code: it seems your Topic3ex1.c still has some errors, it always helps to fix them first. Maybe the errors are preventing Topic3ex1 (which I believe you have selected as the output file with the -o option? I am not familiar with gcc's syntax.) from being formed. Check if the file exist first by executing ls -a from the command line.
If you get a message saying "No such file or directory" while it is indeed there, this is usually caused by a lack of user rights. Try executing chmod u+x Topic3ex1.c and then run your command again. This will give your current user the right to execute the file (read up on chmod if you do not know it already, you will need it often).
Final question: is Topic3ex1 supposed to be a file or a folder? For if it is a file, then executing it like ./Topic3ex1 will only work if it is a shellscript (in that case, best rename your file to Topic3ex1.sh, its best to always mention the extension of the file). If it is a folder the ./ command won't do anything and the cd Topic3ex1 (cq. change directory-)command you where experiencing with will activate it as your working directory. If it is a file however, then the change directory command will, of course, be useless.

Can lftp follow symbolic directories?

lftp can get the files which symbolic links point to, but can it get these files if they are in directories represented by symbolic links? For example, I am looking to get files at
ftp://ftp.ncbi.nlm.nih.gov/genomes/genbank/bacteria/Acinetobacter_nosocomialis/all_assembly_versions/GCA_000162375.2_Acin_sp_RUH2624_V1/
where /GCA_000162375.2_Acin_sp_RUH2624_V1/ is a symbolic link to a directory.
I tried adding set ftp:list-options "-La" to ~/.lftprc, ~.lftp/rc, and /etc/lftp.conf.
This is the command I am using:
lftp -c 'open -e "mirror -c -p --no-empty-dirs -I *.gz /genomes/genbank/bacteria/Acinetobacter_nosocomialis/ ~/ncbi_bacteria_mirror" ftp.ncbi.nlm.nih.gov'
This command DOES work on ftp://ftp.ncbi.nlm.nih.gov/genomes/genbank/bacteria/Pseudomonas_sp._URMO17WK12_I11/all_assembly_versions/
where /all_assembly_versions/ is not a symbolic link. It does not however recursively follow the symbolically linked directories contained within and get the files from those directories, which I would like for it to do if possible.
Resolving the file name to the file on disk and thereby resolving symbolic links is done at the server. Thus there is no need for the ftp client to resolve these links, which means it will not even attempt it by trying to guess the format of the directory listing.
I am not sure I understand the question, and the answer is hidden in it: the -L flag is what you want.
Quoting lftp's man page:
-L, --dereference download symbolic links as files
That's really it!

Linux: The command ls -la shows a file pointing to another file. What does that mean?

When I type ls -la to list all the files, I see this:
11 Jul 9 12:04 libcrypto.so -> libcrypto.so.0
I tried to change the name of libcrypto:
mv libcryto.so libpmcrypto.so
And now it shows:
11 Jul 9 12:04 libpmcrypto.so -> libcrypto.so.0
Does that affect anything? And what does the arrow mean?
The file in question is a symbolic link. This is conceptually similar to the idea of a shortcut, but it appears to be the real file if you use it (Open it, copy it, etc.). The symbolic link is another name that "points to" the real file. When you do ls -l it also shows you which file is pointed to by the link. Renaming the link has no effect on the original file, but may break things that rely on the link name, just as with any other file name. Deleting the link just removes the pointer, and has no effect on the original file. Deleting the original file will leave the link in a "broken state" where the link points to nothing.
Edit
You can't really edit what symbolic links point to. You can delete them with rm and then recreate them with the ln -s command. Take a look at the man pages for more information.
-> means libpmcrypto.so is a Symbolic link and the information stored in libcrypto.so.0 is accessible through the libpmcrypto.so file.
How to create a symbolic link:
ln -s [TARGET DIRECTORY OR FILE] ./[SHORTCUT]
for example:
ln -s /usr/local/apache/logs /home/el/logs
If you delete the soft link itself (/home/el/logs), the file (/usr/local/apache/logs) would still be there.
How to find symbolic links:
find ./ -type l
read man ln for more information on links.
ls -la will display files pointing to module using symbolic links
For example in your library directory you have file pointing to the .so files (shared object).
This means it does not need to be recompiled. You have no easy way of telling how files are linked.
Yes that does changes something, in fact you shouldn't change a shared library because when a 3rd-party program tries to call libcryto.so its not going to be there any more.
But if you're sure you want to change the name, I would recommend you to call nautilus in superuser mode:
sudo nautilus /THE/FOLDER/WHERE/YOUR/FILE/IS
And edit it manually, by adding .0 to the end of the symlink name. You're changing part of its name so whenever a program tries to call it, its not going to be able to locate it.

How identify the source file as a hard link? Bash Script

I'm making a shell script that identifies hard links to a directory, but I need to know the source file.
example:
Ln origen1.txt destino1.txt
Ln origen1.txt destino2.txt
Ln origen1.txt destino2.txt
The output should be origen1.txt, because this is the source file for other hard links. This should be in bash. I need help, Thank you.
You can't. If you have a file file1, and you create a hardlink to it using ln:
ln file1 file2
Then the two files are indistinguishable. A "hard link" is really just the same thing as a normal file entry; it just happens to point to the same file as another entry. You can remove either one and you're back to having a single "hard link" to the file.
Like people have pointed out, hard links are all equivalent. However, you can use find to find all the hard links of a file:
find / -samefile destino2.txt
It won't say which link was the first one, but it will tell you all the possible candidates.

Resources