Skip to main content

links



Hard Link and Symbolic Link?


the term ‘inode’ .

A Unix file is “stored” in two different parts of the disk—the data blocks and the inodes.|
 The data blocks contain the “contents” of the file. But the information about the file is stored elsewhere—in the inode.
Basically, inode is a file structure on a file system.  More easily, it is a “database” of all file information except the file contents and the file name. Both the inodes and data blocks are stored in a “filesystem” which is how a disk partition is organized.

LINKs are another copy of file.
Coming to Symbolic Links and Hard Links..
Symbolic link (Symlinks/Soft links) are links between files. It is nothing but a shortcut of a file(in windows terms).
·         You can delete the soft links without affecting the actual file or directory it is pointing to. The reason is because the inode of the linked file is different from that of the inode of the symbolic link. But if you delete the source file of the symlink ,symlink of that file no longer works or it becomes “dangling link” which points to nonexistent file .
·         Soft link can span across filesystem.
·         Soft links can link both files and directories.
·         INODE are not same
·         Created for directory
·         A symbolic link shows the character l (file type corresponding to symbolic link) before the permissions for user, group and other users and displays an arrow followed by another file name, meaning it’s a link to another file (see image below).
·          
https://cdn-images-1.medium.com/max/1600/1*HZndjcDVGvJFUUP18SSMYQ.png
To create Symlink ,
ln -s <source><linkname>

Hard link is the exact replica of the actual file it is pointing to .Both the hard link and the linked file shares the same inode .
·         INODE are same
·         Cannot Created for directory
·         If the source file is deleted ,the hard link still works and you will be able to access the file until the number of hard links to file isn’t 0(zero).
·         Hard links cannot span across filesystem . Why? Hard links are sharing the same inode—they point to the hardware location, instead of directory tree. This means that if you were to try to make hard link between ext3 and ext4, then you’d have some problems—these filesystems are different, so they can’t share the inode.
·         Hard links can link only files, not directories. The reason hard-linking directories is not allowed is a little technical. Essentially, they break the file system structure.
·         If the source file of hard line is removed ,the link still works. With hard links, there is no concept of original file and links , both files are equal.
·         Hard links are especially useful in performing “copy on write” applications. They allow you to keep a backup copy of a directory structure, while only using space for the files that change between two versions.
·         A hard link appears as an ordinary file (meaning you won’t see an l, but a “-” that stands for ordinary file, and no arrow will be displayed).
https://cdn-images-1.medium.com/max/1600/0*ftfHLuaF4L63vtCm.
To create Hard link,
ln <source><linkname>

a

Comments

Popular posts from this blog

sed

Sed Command in Linux/Unix with examples SED command in UNIX is stands for stream editor and it can perform lot’s of function on file like, searching, find and replace, insertion or deletion. Though most common use of SED command in UNIX is for substitution or for find and replace. By using SED you can edit files even without opening it, which is much quicker way to find and replace something in file, than first opening that file in VI Editor and then changing it. o     SED is a powerful text stream editor. Can do insertion, deletion, search and replace(substitution). o     SED command in unix supports regular expression which allows it perform complex pattern matching. Syntax: sed OPTIONS... [SCRIPT] [INPUTFILE...] Example: Consider the below text file as an input. $cat > geekfile.txt unix is great os. unix is opensource. unix is free os. learn operating system. unixlinux which one you choose. unix is easy to learn.unix ...

initramfs" file is deleted or corrupted on your RHEL or CentOS 7

Initrd/Initramfs image provides the capability to load a RAM disk by the boot loader. This RAM disk can then be mounted as the root filesystem and programs can be run from it. Afterwards, a new root file system can be mounted from a different device. The previous root filesystem which was mounted from initrd/initramfs is then moved to a directory and can be subsequently unmounted. Their are chances that either you might have accidentally deleted "initramfs" file from the /boot partition or it is corrupted due to some reason.  Then boot process will get interrupted and you will see below error: error: file '/initramfs-3.10.0-957.el7.x86_64.img' not found. Good news is you can still recover this "initramfs" by following below steps: Step 1 :  Mount RHEL or CentOS 7 ISO image on your physical server and boot from it. In case you are using HPE Prolient server you can mount this ISO image on iLO, if this is virtual environment then mount it accordingly and reboot...

acls

Secure Files/Directories using ACLs (Access Control Lists) in Linux As a System Admin , our first priority will be to protect and secure data from unauthorized access. We all are aware of the permissions that we set using some helpful Linux commands like chmod , chown , chgrp … etc. However, these default permission sets have some limitation and sometimes may not work as per our needs. For example, we cannot set up different permission sets for different users on same directory or file. Thus, Access Control Lists ( ACLs ) were implemented. 1. Check Kernel for ACL Support Run the following command to check ACL Support for file system and POSIX_ACL=Y option (if there is N instead of Y , then it means Kernel doesn’t support ACL and need to be recompiled). [root@linux ~]# grep -i acl /boot/config* CONFIG_ EXT4_FS_POSIX_ACL=y CONFIG_ REISERFS_FS_POSIX_ACL=y CONFIG_JFS_POSIX_ACL=y CONFIG_XFS_POSIX_ACL=y CONFIG_BTRFS_FS_POSIX_ACL=y CONFIG...
# # #