The setup program will add stuff to the win32 registry file. You could always manualy hack the wine registry and create the key yourself but it be much simpler to just run the gw setup and copy the Gw.dat over. For example: mount /dev/hdX /mnt cp /mnt/Program Files/Guild Wars Gw.dat ~/.wine/drive_c/Program Files/Guild.
I am using a ZFS system that has reached its disk quota. As a result, the rm
command no longer is available to me. However, I am able to copy /dev/null
to particular files to effectively remove them.
The issue is that the directory I am trying to clear out is roughly 40GB in size, and each file that has any girth is buried within 3 levels.
Is there a command line way to easily search and replace those files with /dev/null
? I could do it pretty easily in Python/Perl, however I want to try via the command line.
2 Answers
Edit: this is the better answer found in the comments:
find $DELDIR -type f -exec cp /dev/null '{}' ;
The old answer is here:
find $DELDIR -type f xargs cp /dev/null
where $DELDIR
is the name of the directory to start in. The -type f
option targets only files, not directories. And of course xargs
just finishes off cp /dev/null
with the file names from each line of find output.
Not the answer you're looking for? Browse other questions tagged linuxcommand-linezfs or ask your own question.
When trying to move a test_dir
directory to /dev/null
, I get the message
Then why do people say 'Don't run the command sudo mv ~ /dev/null
, it will move your home directory to a hole?'
But /home
is also a directory.
4 Answers
Because people assume. I was one of those people until I tested it. It's easy to understand why people assume... It looks dangerous...
... but you can't actually move things to /dev/null
— It's a special file that just absorbs redirects (and sends them into nothingness). If you try to move a directory to it, the filesystem will verbosely explode in your face and if you try to move a file to it, you will probably end up replacing it.
The first link will deal with directories, but here's a separate test just for overwriting it with a file. As Rmano points out in the comments, this is probably something you shouldn't do without adult supervision. There is risk involved.
/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. That being said you could never run this command:
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.
Example
You can't copy onto /dev/null
either, given it's a character file, if you try to copy a regular file onto it.
About the only thing you can do to this file is copy mv
over it another file or delete it.
After this command, /dev/null
is a regular file. 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
is equivalent to say 'nothing'. 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.
RmanoYou can write files or other input streams to /dev/null
but not directories. If you try moving a directory to /dev/null
it would report an error since /dev/null
is not a directory but a file.
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:
As suggested by @Rmano 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. So, let's create /tmp/null
and use it for our experimentation purposes:
Now onwards, /tmp/null
is our /dev/null
for all purposes:
Let us create a test_file
and a test_dir
inside a directory called ask_ubuntu
.
The following shows the contents of ask_ubuntu
directory:
Now try to move our test_file
to /tmp/null
and see the contents of ask_ubuntu
:
The command succeeds and test_file
is no longer available. Now try to move test_dir
to /tmp/null
which doesn't succeed:
test_dir
is still present inside ask_ubuntu
:
Now, let us figure if we can recover our test_file
from /tmp/null
:
So, it is still there and /tmp/null
which was a special file has been overwritten and it has become like any other normal file. We can recover our file by copying /tmp/null
just like any other file:
File recovered.
Note:
If you didn't create /tmp/null
and tried those commands directly using /dev/null
; make sure you recover the file (if you need to) by running cp /dev/null our_test_file
; and restore /dev/null
for the purposes it exists on our system by running the following commands as given in the linked question as soon as possible:
Conclusion:
So, it is impossible to move a directory to
/dev/null
and hence there is no question of recovering the directory from there.As far as files are concerned, if you directly move files to
/dev/null
, you can still recover it as demonstrated above. However, there are two exceptions:During the period you run
sudo mv test_file /dev/null
andcp /dev/null our_test_file
, if any root script in the system overwrites it by runningecho 'Whatever text the root script wants to send to /dev/null' > /dev/null
(or other similar commands). Then we do not have any easy way to recover our file.If you reboot the system between running those two commands.
/dev/null
gets re-created at boot, so our file gets lost when we shut down the computer.
But if you want to recover input streams like
echo 'Stream this line to /dev/null' > /dev/null
, you cannot recover that since/dev/null
is a special file to dispose off unwanted files and input streams and as the Wikipedia article mentions, it doesn't provide any data to a process that reads from it.
Reference: Wikipedia Article on /dev/null
Dev Null In Linux
Everything sent to /dev/null
is silently discarded.If you type:
you get Hello World
on the screen.If you type:
you don't get anything on the screen.
But in the case of the move command, the command mv
try to replace the file /dev/null by the directory, what is not possible. Because everything is a file in Linux, /dev/null is a file. A special one of course (a device file), a special file allowing accessing piece of hardware (like disks, partitions, sound cards, serial ports, ...). In the case of /dev/null, this is not linked to any piece of hardware so the data sent to it is silently discarded. This is why 'they' may have called it a blackhole.