Sunday, August 20, 2017

Create and change hard and symbolic links

Symbolic link:it is simplify a shortcut,that points from one file to another.
It creates a very small file,that it contains it’s own inode and path to its original file.
And it can spans filesystems and drives remote or local,because it has independent inode.

The permissions of symbolic link,however cannot be modified,changes with then attended to
be applied,the original ofcourse providing,the write permission for the user to excute the
command.

Removing the symbolic link,sometimes called the soft link,only removes the small link file and
associated inode and does not effect the original in any shape or anything.

Removing the original file,does not removing the link,but it leaves the link oftened.
We were going to use the ln command:

 ln command creates hard and soft link.
You have a single centos system.
We are creating the tmp directory.

Now lets say I have a scripts file


[ root@tcox1  ~]# mkdir tmp
[ root@tcox1  ~]# ll
total  4
xxxxxxxxxxxxxxxxx         tmp

[ root@tcox1  ~]#  ls -al
total 68
xxxxx

[ root@tcox1  ~]#  echo  "this is my script file" >  myscript.sh

so,from my tmp directory I need to refered to the scripts.sh
that means I need to link that.
---->  
ln –s for creating the symbolic link or soft link.
We have to start with the script name that exists.
(we can do this by relative or absolute path).

[ root@tcox1  tmp]# ls  -i
30530   myscript.sh
[ root@tcox1  ~]#

if I do ls –I on the directory,it will give me the inode.
We can compare that,previous directory and we can see that to:


[ root@tcox1  tmp]# ls  -i   ../myscript.sh
30509   ../myscript.sh
[ root@tcox1  tmp]#  ll
total 0
xxxxxxxxxxxxx    herescript.sh  --->   ../myscript.sh


we have that,particular link to the ../myscript.sh
if I go inside the herescript.sh,
it will allow me,to edit the contents of script file and save it.
















































No comments:

Post a Comment