carlarogers
Member
I tried looking this up but was getting nowhere. A brief answer would be appreciated immensely. Thank you
$ ll /dev/nvme0n1
brw-rw---- 1 root disk 259, 0 Sep 15 08:34 /dev/nvme0n1
crwxrwxr-x 1 dan www-data 1, 3 2024-03-16 01:45:49 access.log
$ ls -al /dev/null
crw-rw-rw- 1 root root 1, 3 Sep 15 08:34 /dev/null
$ ls -al abs-guide2014.pdf
-rw-r--r-- 1 tom tom 2741648 Nov 21 2023 abs-guide2014.pdf
$ ls -alh abs-guide2014.pdf
-rw-r--r-- 1 tom tom 2.7M Nov 21 2023 abs-guide2014.pdf
Here is additional info read more about device files:I am going to lookup character device
mknod
is used to create a new device file.tty
is used to get device file of the current terminal/dev
directory..Here are some observations about the data provided in posts #3 and #4.
The files have a group ownership of www-data.
The group ID www-data is normally associated with the apache2 web server where it's the default group ownership.
Since apache is not used here I can't say more.
In relation to the "1, 3" in the line:
the numbers refer to device numbers which are used in the kernel. In this case the number 1 is the major device number, and 3 is the minor device number. The number 1 is set as a character device in the kernel, and the number 3 refers to the particular device: /dev/null, as shown here.Code:crwxrwxr-x 1 dan www-data 1, 3 2024-03-16 01:45:49 access.log
Code:$ ls -al /dev/null crw-rw-rw- 1 root root 1, 3 Sep 15 08:34 /dev/null
The list of devices with their major and minor numbers are shown in the kernel docs here:
The /dev/null character device is commonly referred to as "the bit bucket" which means that any characters sent there are discarded, never to be retrieved.
The relationship between /dev/null and the file names "access.log" and "error.log" is not one that makes sense in the output provided in the above posts. There appears to be some corruption in the system for several reasons one may speculate about:
1. access.log and error.log are ordinary files and the normal output of the ls command does not provide device numbers for ordinary files. It does so for device files in the directory /dev as shown above in the case of /dev/null. Further, ordinary files have the dash character at the beginning of the line: -rw-rw-rw-..... and not the c character which is reserved for character devices.
2. The filesystem may actually be corrupted so that when ls is reading files, the inodes with the correct information about the files are somehow unable to provide it correctly.
3. The ls executable itself may be corrupted.
In other words, the output in the data provided is abnormal with no obvious explanation.
Finally, in relation to the file size which is shown in the ls output, it can be shown in a more human readable form than a long string of numbers by using the -h option, for example:
The size of 2.7 megabytes is usually easier to read than the the number shown in bytes.Code:$ ls -al abs-guide2014.pdf -rw-r--r-- 1 tom tom 2741648 Nov 21 2023 abs-guide2014.pdf $ ls -alh abs-guide2014.pdf -rw-r--r-- 1 tom tom 2.7M Nov 21 2023 abs-guide2014.pdf
cp /dev/null access.log
Link to "answer" stating cp /dev/null will empty a filecp /dev/null filename works.
cat /dev/null access.log
$ ll
<snip>
-rw-rw-r-- 1 tom tom 452 Sep 10 11:56 file
<snip>
$ cat > file
$ ll
<snip>
-rw-rw-r-- 1 tom tom 0 Sep 16 06:46 file