| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read | ![]() |
|
||||||
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Avoid overwriting existing files
Operator ">" and ">>" are used to send output for one command to the specified file. But if accidentally you overwrite any important file which is not suppose to, then you might face serious problems on your server. Suppose we type command as anycommand > /etc/userdomains, then all the ujser accounts on your dedicated server will get messed up. Or in a hurry if you want to append the output with the operator >> but you by mistake type operator > , then the file will get overwrite instead of append that file. To avoid this to be happended on your server, set "noclobber" variable. If you want to set it on the server use following command ----------------------------------- [root@swedenmy ~]# set -o noclobber ----------------------------------- In order to disable it use following command ---------------------------------- [root@swedenmy ~] set +o noclobber ---------------------------------- Just try to run following command if "noclobber" is enabled on your server. --------------------------------------------- [root@swedenmy ~]# ls -l > /etc/userdomains --------------------------------------------- The output will be bash: /etc/userdomains: cannot overwrite existing file and your file is safe Following command will be used for setting "noclobber" variable directly in bachrc file on the server. --------------------------------------------- [root@swedenmy ~]# echo ‘set -o noclobber’ >> ~.bashrc --------------------------------------------- If you want to overwrite a particular file then disable "noclobber" on the server and check twice before firing that command. Make it very sure that the command is correctly written. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|