![]() $ echo "Let us test if we can recover our test_file." > test_file Let us create a test_file and a test_dir inside a directory called ask_ubuntu. Now onwards, /tmp/null is our /dev/null for all purposes: So, let's create /tmp/null and use it for our experimentation purposes: sudo mknod -m 0666 /tmp/null c 1 3 ![]() I can read from /dev/null how to fix it?Īs suggested by in this answer to that question, in order to experiment with /dev/null we should rather create a copy of it and then do our experimentation.However, since you want to experiment with /dev/null, you are first suggested to know the consequences to moving a file to overwrite /dev/null and how to recover from that situation: If you try moving a directory to /dev/null it would report an error since /dev/null is not a directory but a file. You can write files or other input streams to /dev/null but not directories. Having this assumption broken can lead to random data (well, the data the last process wrote to `/dev/null') inserted in system files all around the system - which could lead to an utterly broken and unrecoverable system. The most dangerous effect of this change is that /dev/null is supposed to never output any data, so a number of shell script will assume that `. $ mv /path/to/afile /dev/nullĪfter this command, /dev/null is a regular file. $ cp ~/bzip2_1.0.6-4_b /dev/nullĬrw-rw-rw- 1 root root 1, 3 Mar 16 14:25 nullĪbout the only thing you can do to this file is copy mv over it another file or delete it. You can't copy onto /dev/null either, given it's a character file, if you try to copy a regular file onto it. Mv: cannot overwrite non-directory ‘afile’ with directory ‘dir’ The mv command won't allow this since you're moving a directory to a file, that just doesn't make sense contextually and mv knows this. That being said you could never run this command: $ mv ~ /dev/null She is also the author of “Linux System Administration Recipes: A Problem-Solution Approach” (Apress, 2009)./dev/null is just a file, it's a "special character" file but it's non the less still bound by the rules that files must follow. Juliet Kemp has been messing around with Linux systems, for financial reward and otherwise, for about a decade. You may well already have a nobody user in /etc/passwd (one with a nonexistent home directory and no login shell), which you can use in place of devnull in /etc/aliases otherwise you can set up a devnull user to operate similarly. One last gotcha: On some systems, the /etc/aliases change may not work unless that user ( devnull) already exists on the system. You should see the correct alias returned. You can check if the alias is properly set up with the command: postmap -q /etc/postfix/virtual/dbfile However, what you can do is set up an alias user in /etc/aliases: devnull: /dev/nullĪnd then point to that in your virtual domain database file (which should be somewhere in /etc/postfix/virtual/, or it may be the /etc/postfix/virtualfile itself): devnullĪfter you’ve made the change, run postmap /etc/postfix/virtual/dbfileand reload Postfix. It must go to a user or an email address, like this: With virtual domains/users, you can’t forward mail to a file. However, if you’re using Postfix virtual domains, it gets a little more complicated. The usual solution is to forward to /dev/null, and in a local-only setup you could do that in /etc/aliases: do-not-reply: /dev/null Here’s an easy way to add a Postfix virtual alias to /dev/null. Tip of the Trade: Sometimes you want to use a “do-not-reply” type of email address and you don’t want to have to mass-delete the mailbox at intervals. But sometimes you want to use a “do-not-reply” type of email address, and you don’t want to have to mass-delete the mailbox at intervals. It’s poor practice to send out email from email addresses that don’t resolve, and may mean your mail ends up in a spamtrap.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |