We will continue our Linux journey by talking about two important components of the File System:
links (soft and hard links)
This would be an important step to further understand how this OS works and what are the main concepts behind its functionality. I will try as best as I can to explain these two concepts so please post a comment if you think that things were not described properly.
A Linux partition is composed of several elements. In the following section I will try to explain the role of each component:
boot block – the location of the boot loader. We’ve described the Linux bootloader in a previous article.
super block – contains information like number of data blocks, mount-points, File system type, Size, Status, Information about other metadata structures, etc.
inode list – the list of inodes contained by a partition. Note that this is a finite number.
data blocks – this is where file content is stored. A file can contain one ore more data blocks and inodes are the ones who store the information about where is each data block located.
In Linux, one file can be seen in multiple locations without multiplying its content. Practically, you can view the same resource in multiple locations but, all will have the same source file. This feature is handled in Linux using links. When talking about links in the UNIX/Linux Systems, we’ll need to specify the two concepts behind this technology:
soft link also known as symbolic link – it’s a redirection from one file to another. They have similar functionality as Windows shortcuts. To create a new symbolic link you’ll need to use the following command:
hard link – an association between file name and inode. As we’ve talked previously, the name information is not stored in the inode but, instead it’s located in the directory which contains the file. If you want to create a new hard link for an existing file you’ll need to use the following command:
The command will basically create a new association which will contain another name and the existing inode.
To view the number of hard links for a file you can use the ls -l command (we’ve talked about this in a previous article)
Metacharacters are mainly used for filtering the output of a command. By parsing information before manipulating a command’s result, offers System Administrators a powerful way to manipulate data within the File System. You will see that there are special characters reserved in the OS which have a distinct functionality and can often be used to simplify administrative operations. Regex (regular expressions) are build using metacharacters so, this part may sound familiar. I will try to explain the role of each metacharacter within the OS, please add more if you think are relevant on this topic:
> Used to redirect the output of a command to file. If the file does not exist, it will create a new one, if the file already exists its content will be replaced
>> Redirects the output of a command but, unlike the > character, it will append the new results to an existing file.
< used to redirect input
* wildcard used to substitute 0 or more characters. Example ls -al f* will output any file which begins with f
? wildcard used to substitute only one character. Example: ls -al f??e will output any file that starts with “f”, contains any two characters and then ends with “e”
; used to separate multiple commands that are written on the same line
&& AND conditional execution
“$ preceeds the name of a variable to be expanded.
The variables are either assigned using “=” or are one of the pre-defined variables (which cannot be assigned to):
$0 name of the shell or the shell script being executed.
$# number of the positional parameters to the command
$1 the value of the first positional parameter passed to the command. $2 is the second positional parameter passed to the command. etc. up to $9.
$* expands to all positional parameters passed to the command
$@ expands to all positional parameters passed to the command, but individually quoted when “$@” is used. ” from About.com