Symbolic Link Edits and differences to hard link [closed] - linux

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 just created a symlink to a directory using:
ln -s /path/to/real/ link
1 - If I then cd into link/ will any changes I make in there be reflected in the original directory?
2 - Additionally, the source directory is a git repo, so can I do the git commands from the symlink'ed directory?
3 - These answers and any general explanation about the differences between sym/hard links (or ln in general) would rock.
Thank you!

Symbolic links work just like another name for the original directory. They are different from hard links because if you replace the original file with a new one of the same name, the symbolic link points to the new file. A hard link would still be linked to the original file, no matter what name it had.
A symbolic link can "dangle" which means that it's target is no longer there. A hard link cannot.
A directory cannot be hard-linked. In the past that was allowed but it creates the possibility of directory loops, and this is a bad thing.
Yes if you cd symlink you can do anything that you want, just as if you were in the actual directory, because you are in the actual directory. Your shell, depending on its configuration settings, will allow you to think you're in the symlink named directory, but all of the operating system functions will return the actual directory names.

When you do cd link/, your current directory becomes /path/to/real and any changes you make in the directory are in 'the real directory'.
Beware of cd -L vs cd -P — see POSIX on cd — and similarly with pwd.

Related

ls command tells me there's no such file or directory when the file does exist? [closed]

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 6 months ago.
Improve this question
when i enter
cd prctcfldr
it tells me that i'm in the directory
~/prctcfldr$
but when i enter
ls prctcfldr
it tells me that there is no such file or directory
ls: cannot access 'prctcfldr': No such file or directory
this is happening with all my other directories including Desktop, which is really confusing since this error has not happened with my directories before, and i havent made any changes to them between now and the last time. i know the folder exists because i can see it and open it from the actual homescreen. i'm new to the linux command line and ive been looking for solutions to this error for a little while.
does anybody have a solution?
cd ..
This command moves above one directory and then you can ls <folder name>
Since you are already inside the folder when you ls again the folder name, it'll show directory does not exist.

Why rsync failed to copy all files? [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 tried to copy 17171 files, but whatever parameters I use, it always copied 17160 which 11 lost.
But same command for another directory, copied accurately. (16545 files).
I also tried use cp, but also lost 11 files.
When I check the folder with finder, it should be 17171 files there...
rsync -arvz src dst
cp src dst
Above is the command I've tried
There can be a number of issues at play:
One of the more common issues is that the target filename is illegal on the remote system, for example trying to copy a file with a colon : in the filename from UNIX to Windows.
There may also be permission issues reading the files that are not copied, check the permissions here.
Finally, you could try zipping (or taring) the bunch of files into a single file, and transfer just that instead. Typically you'll see the problem when unpacking that file on the remote system.
EDIT: Another thought - are the files that did not copy really-really large, too large to store remotely?
If you rsync with the -P option, it should only re-transfer files that were not copied. It will also print progress, that should give you a better idea of what's not copying.

Keep two directories synced in ubuntu in real 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 6 years ago.
Improve this question
My intention is to keep two directories (say dir1 & dir2) synced. So that whenever there is a change in the content of the dir1 (can be addition or deletion of new file or directory or modifying the content of a file in the directory) then the change should be propagated to dir2 and vice versa.
The naive way I can think of doing this is to run rsync periodically via cron in both the machines. But there are fallacies in this approach:-
It might happen that the previous rsysnc is not complete and the cron executed rsync once more while the previous rysnc is still going on.
A new file is added in dir1 and before rsync ran on dir2 rsync on dir1 ran then newly added file might be deleted from dir1 since it is not present in dir2
Also this is not real time.
Can some suggest some better way of doing this?
It strongly depends on the purpose. 'Realtime' is probably not the term you are looking for.
Take a look at https://www.gluster.org/ (Replicated Mode) for a synchronous replication via network.

How to store data permanently in /tmp directory 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 1 year ago.
Improve this question
Is there any way to store any data in Linux tmp directory. As i know Linux clear its /tmp directory when system is rebooted. But I want to store data permanently.
Like #bereal said, this defeats the purpose of the /tmp directory. Let me quote the Linux Filesystem Hierarchy Standard:
The /tmp directory must be made available for programs that require temporary files.
Programs must not assume that any files or directories in /tmp are preserved between invocations of the program.
You'll find a better place to store permanent data.
Since it's linux you are free to do what you want to do (as root). When /tmp is cleared depends on your system and can be changed; there is no particular magic involved. A good summary seems to be here: https://serverfault.com/questions/377348/when-does-tmp-get-cleared.
Of course if you are root you can set up an entirely different global directory, say "/not-quite-tmp" or such. But I assume that some progs not under your control write to tmp and you want to inspect or in any case persist those files.
While you are trying to do wrong things, it’s still possible.
/tmp directory is cleared accordigly to TMPTIME setting. The default is apparently 0, what means “clear on every startup”.
The value might be changed in /etc/default/rcS (value is to be set in days.)

About basic commands in bash (cp, cd,..) [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 8 years ago.
Improve this question
I am trying to learn basic commands in the terminal. I have a couple of quick questions. I know that to make a file and place it in a specific folder, one needs to create the directory and then use touch to create an empty file and place it there by mv:
mkdir folder/sub
touch file.txt
mv file.txt folder/sub
Could we somehow chain these things together and use touch to create a file and place it in a specific directory in just one line?
and then if I am in a sub-directory, in order to get back from there (say: folder/sub) to my home, either of these three commands would work (cd, cd -, cd ..) I am not sure I get the differences among the three. I get that cd .. takes you back one step up but the other two seem to work exactly the same.
and let's say I have already a text file in my home directory named file.txt. If I write this in shell it overrides that existing file:
cp folder/sub/file.txt ~/
How would I go about this if I wanted to keep both files?
You can pass a relative or absolute path in any folder to and command, including touch (although the folder must exist):
touch folder/sub.file.txt
cd - switches to the folder you were last in (like a "Back" button)
. means the current directory
.. means the parent directory

Resources