How to make use of sync command in Linux
There are two sorts of garage reminiscences of the method; one is everlasting reminiscence and the opposite one is transient reminiscence which is RAM. The “sync” command is used to synchronize the knowledge of the transient reminiscence to the everlasting garage reminiscence. The pace of RAM is quicker than the everlasting garage gadgets, due to this fact the method makes use of RAM as a substitute of a troublesome disk to procedure the knowledge, and in RAM the method shops the knowledge within the type of cache.
Though storing the knowledge at the RAM improves the velocity of the method, in case of a unexpected crash of the method there’s a chance of shedding the necessary knowledge saved within the type of cache. It is healthier to synchronize the knowledge at the everlasting reminiscence so, in case of any crash, there’s no lack of knowledge.
In this write-up, we will be able to talk about the sync command utilized in Linux to synchronize the knowledge of the RAM within the everlasting garage.
How to make use of the sync command in Linux
The sync command is used for synchronizing the cache knowledge to the onerous disk, the overall syntax of the use of the sync command:
The sync command is used with choices after which the dossier identify of which the knowledge needs to be saved, the choices used with the sync command are:
Options | Explanation |
-d, –knowledge | It is used to synchronize the dossier knowledge of the dossier |
-f, –file-system | It is used to synchronize the entire information which might be connected to a given dossier |
–lend a hand | It shows the lend a hand choices |
–model | It shows the model main points of the command |
To perceive using the sync command, we will be able to carry out some sensible examples. First, we will be able to sync the entire knowledge of the present consumer the use of the command:
It has synced the entire cached information to the everlasting reminiscence which belongs to the present consumer, likewise, we have now a textual content dossier in /house/hammad/mytestfile1.txt, we will be able to sync its cache knowledge the use of the command:
$ sync -d /house/hammad/mytestfile1.txt
To sync the information programs, we use the “-f” choice within the command:
$ sync -f /house/hammad/Downloads
In the above command, we have now synced the entire information associated with the /house/hammad/Downloads, we will be able to additionally sync the cache knowledge of the fixed partition (in our case it’s sda1) the use of the command:
The knowledge of the fixed partition has been synced, likewise, we will be able to additionally sync the log knowledge of the /var/log/syslog the use of the command:
$ sudo sync /var/log/syslog
To take a look at extra main points of the sync command we will be able to use the “–help” choice:
Similarly, the “version” choice is used to test the model of the sync command:
Conclusion
The sync command is utilized in Linux to replicate the knowledge from the risky reminiscence which is within the type of cache to the everlasting garage reminiscence. The method saves the entire knowledge at the transient reminiscence on account of its higher pace as in comparison to the everlasting garage gadgets, it’s useful however every now and then in case of surprising shutdown of the method, a super chance is provide of shedding the knowledge. To keep away from this chance, it is suggested to sync the helpful knowledge from the transient reminiscence to the everlasting reminiscence. In this write-up, we have now mentioned using the sync command in Linux with the assistance of examples for higher working out.