What does the script /dev/null do?
Solution 1
On UNIX, this is a virtual-file that can be written to. Data written to this file gets discarded. It is similar to the file call NUL on Windows machines.
Key point; When rooting a machine, intruders will often redirect logging to /dev/null
For example, the command ln -s /dev/null
.bash_history
will cause the system to stop logging bash commands.
In layman's terms, it means much the same thing as black hole. Typical usage: if you don't like what I have to say, please direct your comments to /dev/null
.
Think of /dev/null as a "black hole." It is the nearest equivalent to a write-only file. Everything written to it disappears forever. Attempts to read or output from it result in nothing. Nevertheless, /dev/null can be quite useful from both the command line and in scripts.
- It discards all data written to it but reports that the write operation succeeded.
- It means redirecting both standard output and error to
/dev/null
- It prevents the script from displaying anything. like windows "echo off"
script /dev/null
prevent any message from appearing on your screen. It supresses the messages, byt directing them to the "black hole."
Also, have a look at Why does redirecting 'script' to /dev/null/ allow 'screen' to work while su'ed as another user?
Source:Linux Dictionary
Solution 2
Basically script saves all terminal dialogue into a file, when you specify /dev/null as the file all the stuff script would save into a file would be saved into the black hole.
Related videos on Youtube
C1sc0
Updated on September 18, 2022Comments
-
C1sc0 over 1 year
I was
su
ed into another user to run screen, but I got the errorCannot open your terminal '/dev/pts/4' - please check.
I found a solution:
script /dev/null
and after that I can use screen. Why does this work? It creates a new pseudo terminal?-
Lucas almost 11 years@thefourtheye ????
-
-
gosalia almost 11 yearsBut when I do
script /dev/null
it saysScript started, file is /dev/null
. Why is it so? -
gosalia almost 11 years@Mitch I still don't understand how it answers the question. I think the OP wants to know the effect of executing
script /dev/null
and not just about/dev/null
-
hanshenrik almost 4 years
script /dev/null prevent any message from appearing on your screen. It supresses the messages, byt directing them to the "black hole."
- that's bullshit, script makes A COPY OF ALL YOUR MESSAGES in /dev/null, it doesn't hide/supress anything from you