Linux: Difference between revisions

129 bytes removed ,  30 September 2018
→‎Everything is a file: No need for dangerous commands listed...
(→‎Everything is a file: No need for dangerous commands listed...)
Line 17: Line 17:


==Everything is a file==
==Everything is a file==
In Linux, even things like hardware are represented as files that can be written to. For example, the file for the first hard drive is /dev/sda. This means that if you want to write bytes directly to the drive you can use an app that lays bytes (like dd) to write directly to that file. This can be done by using the app named echo to output something and piping the output to dd which you specify the hard disk's file too. (The exact command is "echo Something | dd of=/dev/sda". '''This will ruin your drive's boot sector so please do not do this.''')
In Linux, even things like hardware are represented as files that can be written to. For example, the file for the first hard drive is /dev/sda. This means that if you want to write bytes directly to the drive you can use an app that lays bytes (like dd) to write directly to that file. This can be done by using the app named echo to output something and piping the output to dd which you specify the hard disk's file too.  


There are also more liberal concepts of devices in /dev. /dev/null, when written to, discards all data sent to it. If you write to /dev/null and then open it it will still be empty.
There are also more liberal concepts of devices in /dev. /dev/null, when written to, discards all data sent to it. If you write to /dev/null and then open it it will still be empty.
Cookies help us deliver our services. By using our services, you agree to our use of cookies.