Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
0
votes
1
answers
44
views
How to insert metadata in audio cd tracks with Linux?
I have created wav files as this ffmpeg -i 1.wav -codec copy -metadata title="Title1" -metadata author="Author1" -metadata comment="My comment" -y 2.wav Then I burn the audio cd sudo cdrecord -v -pad -dao -speed=4 -audio dev=/dev/sr1 cd/*.wav I try vlc for see audio text and.. [
elbarna
(13690 rep)
Jul 27, 2025, 09:44 PM
• Last activity: Jul 28, 2025, 12:18 PM
6
votes
2
answers
468
views
Can I use grep or strings to find the previous atime of a file still present on my btrfs?
The metadata of this file which resides on my HDD is written by CoW, therefore can I look for it just by using grep or strings, and the filename?
The metadata of this file which resides on my HDD is written by CoW, therefore can I look for it just by using grep or strings, and the filename?
user324831
(113 rep)
Jun 1, 2025, 10:00 AM
• Last activity: Jun 11, 2025, 08:04 PM
0
votes
1
answers
45
views
Can I use grep or strings to seach for deleted file name on btrfs?
Months ago, one of my systemd journal files was purged from my btrfs hdd. Because I couldn't use file carving to check if the content is still on the hdd because unfortunately the format is binary and not text, I can at least look for the metadata of this file (inode is called?). For this, can I jus...
Months ago, one of my systemd journal files was purged from my btrfs hdd. Because I couldn't use file carving to check if the content is still on the hdd because unfortunately the format is binary and not text, I can at least look for the metadata of this file (inode is called?). For this, can I just use grep or strings over my sda1 and search for the filename? If I find something then I will see which blocks it points to and try recover the actual content of the journal file... I know there are btrfs-undelete scripts but I don't see the point of using them at least in this case.
user324831
(113 rep)
May 31, 2025, 09:22 PM
• Last activity: Jun 1, 2025, 07:40 AM
64
votes
7
answers
68068
views
How to strip metadata from image files
[**EDIT #1 by OP:** Turns out this question is quite well answered by exiftool creator/maintainer Phil Harvey in a [duplicate thread on the ExifTool Forum][1]] [**EDIT #2 by OP:** From [ExifTool FAQ][2]: *ExifTool is **not** guaranteed to remove metadata completely from a file when attempting to del...
**EDIT #1 by OP:** Turns out this question is quite well answered by exiftool creator/maintainer Phil Harvey in a [duplicate thread on the ExifTool Forum ]
**EDIT #2 by OP:** From [ExifTool FAQ : *ExifTool is **not** guaranteed to remove metadata completely from a file when attempting to delete all metadata.* See 'Writer Limitations'.]
I'd like to search my old hard drives for photos that are not on my current backup drive. Formats include jpg, png, tif, etc..., as well as various raw formats (different camera models and manufacturers).
I'm only interested in uniqueness of the image itself and not uniqueness due to differences in, say, the values of exif tags, the presence/absence of a given exif tag itself, embedded thumbnails, etc ...
Even though I don't expect to find any corruption/data-rot between different copies of otherwise identical images, I'd like to detect that, as well as differences due to resizing and color changes.
[**Edit #3 by OP:** For clarification: A small percentage of false positives is tolerable (a file is concluded to be unique when it isn't) and false negatives are highly undesirable (a file is wrongly concluded to be a duplicate).]
My plan is to identify uniqueness based on md5sums after stripping any and all metadata.
How can I strip the metadata?
Will
exiftool -all=
suffice?
Jeff
(851 rep)
Sep 27, 2016, 05:09 PM
• Last activity: May 28, 2025, 06:21 AM
1
votes
1
answers
55
views
Forensics to recover the second-to-last access timestamp of a file on btrfs on HDD
I searched online, to no avail. Is there some way to recover the access timestamp of my file on BTRFS, before the access timestamp which appears currently? Using HDD (not SSD). Please let me know. Is this question better suited for superuser? I made no snapshots (willingly), using Fedora and the met...
I searched online, to no avail. Is there some way to recover the access timestamp of my file on BTRFS, before the access timestamp which appears currently? Using HDD (not SSD). Please let me know. Is this question better suited for superuser? I made no snapshots (willingly), using Fedora and the metadata change dates back some two weeks... In fact to be precise I'm interested in two timestamps ago, which happened in rapid succession.
user324831
(113 rep)
May 23, 2025, 06:15 PM
• Last activity: May 23, 2025, 08:35 PM
0
votes
0
answers
73
views
Not able to modify inode metadata
I am working on a ext4 file-system tool that aims to delete files such that they are not recoverable later on. My goal is to clear the inode metadata of a deleted file, but despite my efforts, the changes I make to the inode metadata are not reflecting when I inspect the inode later using stat. Here...
I am working on a ext4 file-system tool that aims to delete files such that they are not recoverable later on. My goal is to clear the inode metadata of a deleted file, but despite my efforts, the changes I make to the inode metadata are not reflecting when I inspect the inode later using stat.
Here's the process I follow to modify the inode:
1. Fetch the inode using ext2fs_read_inode.
2. Modify the inode metadata by setting values like i_mode, i_links_count, etc., to zero or NULL.
3. Write the modified inode back to the filesystem using
ext2fs_write_inode.
void clear_inode_metadata(ext2_filsys &fs, ext2_ino_t inode_num)
{
ext2_inode inode;
ext2fs_read_inode(fs, inode_num, &inode);
inode.i_mode = 0;
inode.i_links_count = 0;
inode.i_size = 0;
inode.i_size_high = 0;
inode.i_blocks = 0;
memset(inode.i_block, 0, sizeof(inode.i_block));
ext2fs_write_inode(fs, inode_num, &inode); // Write the cleared inode back to disk
}
void delete_file(const string &path, ext2_filsys &fs, const string &device)
{
ext2_ino_t inode_num = fetch_file(path, fs, device);
if (inode_num != 0)
{
overwrite_blocks(fs, device, path); // traverses extents and writes random data
clear_inode_metadata(fs, inode_num);
}
}
The inode metadata stays the same even after invoking clear_inode_metadata()
.
Also I have a file recovery module that uses a disk snapshot to recover files and to my surprise it is able to recover the file even after I overwrite the file using overwrite_blocks()
. The snapshot stores extents used by an inode and the total size of the file.
My questions:
1. Why aren't the changes to the inode metadata reflecting after calling ext2fs_write_inode?
2. Why is the file recovery tool still able to recover the file after I overwrite its blocks?
Dhruv
(1 rep)
Apr 27, 2025, 08:14 AM
• Last activity: Apr 27, 2025, 08:16 AM
1
votes
1
answers
103
views
Should we use convert or img2pdf for creating lossless multi-page PDF files out of gray PNM photocopies? And why?
Let's assume that you have 4 scanned pages, created by `scanimage -resolution 1200` and postprocessed by GIMP: each page was rotated so that the text lines were horizontal, the bled-through text was removed, and the margins were removed. You would like to losslessly create a single 4-page PDF docume...
Let's assume that you have 4 scanned pages, created by
scanimage -resolution 1200
and postprocessed by GIMP: each page was rotated so that the text lines were horizontal, the bled-through text was removed, and the margins were removed. You would like to losslessly create a single 4-page PDF document out of the 4 pages. Here is what you tried:
$ sum_sofar=0; for file in $(for i in $(seq 1 4); do echo page_$i.pnm; done | xargs echo); do sum_sofar=$((sum_sofar + $(stat -c%s "$file"))); done; echo "The sum of the sizes of the PNM files is $sum_sofar bytes."
The sum of the sizes of the PNM files is 415300162 bytes.
$ convert $(for i in $(seq 1 4); do echo page_$i.pnm; done | xargs echo) -compress Zip -quality 100 -density 1200 tmp_output_document.convert.pdf && pdftk tmp_output_document.convert.pdf update_info Producer: https://imagemagick.org
> CreationDate: …
> ModDate: …
16,17c16,17
File size: 254364579 bytes
> Optimized: no
(Above, you dropped the timestamps for simplicity.)
Inspection with diffpdf reveals no differences. Both img2pdf and convert produce, in your understanding, lossless files, don't they?
So why do the sizes differ by a factor of 254369508/201800756 ≈ 1,26 ?
What does it mean that file created by img2pdf file is “optimized”, whereas the file created by convert is not? For lossless storage, which method is better: img2pdf or convert+pdftk, and how to use it properly™?
AlMa1r
(1 rep)
Feb 2, 2025, 02:56 AM
• Last activity: Feb 2, 2025, 08:10 PM
2
votes
3
answers
17209
views
How can I find the last 10 modified files
I'm in the root folder and need to find the last 10 modified files of just this folder. Every time I put -mtime like my lecturer said I get 10 days. I need the last 10 modified files, not the last 10 days worth. I have tried find -my time, my time piped with tail. I get a long list of every modified...
I'm in the root folder and need to find the last 10 modified files of just this folder. Every time I put -mtime like my lecturer said I get 10 days. I need the last 10 modified files, not the last 10 days worth.
I have tried find -my time, my time piped with tail. I get a long list of every modified file of the last 10 days. I need just the last 10 modified files of the root directory.
Samuel Mccartney
(21 rep)
Oct 25, 2021, 08:23 AM
• Last activity: Oct 22, 2024, 02:33 PM
1
votes
2
answers
282
views
Copy timestamp and metadata from one file to another
I rotated an MP4-video and in this process lost the correct metadata and timestamp of the file. Is there a way to copy the metadata and timestamp from the original (not roated) file to the new file. (Note, I am not asking how to copy a file preserving the timestamp, but rather how to transfer this i...
I rotated an MP4-video and in this process lost the correct metadata and timestamp of the file.
Is there a way to copy the metadata and timestamp from the original (not roated) file to the new file. (Note, I am not asking how to copy a file preserving the timestamp, but rather how to transfer this information to another file.)
user1583209
(267 rep)
Oct 19, 2024, 10:41 PM
• Last activity: Oct 19, 2024, 10:51 PM
3
votes
2
answers
3048
views
Batch set MP4 create date metadata from filename
On a Linux system, I have a bunch of MP4 files named like `20190228_155905.mp4` but with no metadata. I've previously had a similar problem with some jpg's which I solved manually with ``` exiv2 -M"set Exif.Photo.DateTimeOriginal 2018:09:18 20:11:04" 20180918_201104.jpg ``` but as far as I can see,...
On a Linux system,
I have a bunch of MP4 files named like
20190228_155905.mp4
but with no metadata. I've previously had a similar problem with some jpg's which I solved manually with
exiv2 -M"set Exif.Photo.DateTimeOriginal 2018:09:18 20:11:04" 20180918_201104.jpg
but as far as I can see, the DateTimeOriginal
is only for images, not videos. Videos that do have metadata have a Xmp.video.MediaCreateDate
field that seems like what I want. I guess it contains a Unix timestamp, so I'd need a way to get the date from the filename, convert it to a Unix timestamp and set that value to Xmp.video.MediaCreateDate
. Is that all correct? Or am I overcomplicating things?
Edit:
If I wasn't clear, I want to set creation date metadata on mp4 files using its filename that contains the date, so that programs can sort all my media files by their metadata
Sergey Kasmy
(155 rep)
Jun 17, 2019, 03:03 AM
• Last activity: Oct 17, 2024, 08:16 AM
6
votes
3
answers
598
views
evince opens pdf in "presentation mode"
when opening a particular pdf file, `evince` decides to open it in "presentation mode". I see in the man page that evince has `-s` option to open in presentation mode, but I did not invoke it. I am simply opening all pdfs as `evince file.pdf` Somehow evince has decided on its own, to open this parti...
when opening a particular pdf file,
evince
decides to open it in "presentation mode".
I see in the man page that evince has -s
option to open in presentation mode, but I did not invoke it. I am simply opening all pdfs as evince file.pdf
Somehow evince has decided on its own, to open this particular kind of pdf in presentation mode.
Other pdfs open just fine in normal window.
How can I disable this behavior?
Martin Vegter
(586 rep)
Aug 19, 2023, 05:07 AM
• Last activity: Sep 23, 2024, 09:09 AM
0
votes
2
answers
1285
views
Imagemagick, how to print date the photo was taken on the image
Imagemagick 6.9.11-60 on Debian. How to print date & time the photo was taken on the image? (on existing images). I have set this option in camera settings, but it only applies to new photos. The date is on the image medatada. It should be actual date the photo was taken, not the date it was saved o...
Imagemagick 6.9.11-60 on Debian. How to print date & time the photo was taken on the image? (on existing images). I have set this option in camera settings, but it only applies to new photos. The date is on the image medatada. It should be actual date the photo was taken, not the date it was saved on PC harddrive.
minto
(575 rep)
Nov 11, 2023, 11:43 AM
• Last activity: Aug 9, 2024, 09:03 AM
26
votes
4
answers
31965
views
Removing metadata from a PDF
What commands must I issue irreversibly to remove all metadata from `foo.pdf`? Assume embedded images are already clean. I got the impression from https://gist.github.com/hubgit/6078384 that exiftool -all:all= foo.pdf qpdf --linearize foo.pdf bar.pdf might suffice, but it wasn't clear to me whether...
What commands must I issue irreversibly to remove all metadata
from
foo.pdf
? Assume embedded images are already clean.
I got the impression from
https://gist.github.com/hubgit/6078384
that
exiftool -all:all= foo.pdf
qpdf --linearize foo.pdf bar.pdf
might suffice, but it wasn't clear to me whether it was an
entirely complete method. There was some talk of pdftk
and an
"info dictionary" that I didn't understand.
Toothrot
(3705 rep)
Sep 9, 2020, 10:31 AM
• Last activity: Jun 17, 2024, 10:12 AM
7
votes
2
answers
4463
views
Add image (cover art) to Opus (ogg) audio file using ffmpeg
Question ======== I have 2 files: - `audio.opus` (extension also possible: `.opus.ogg`), - `cover.jpg`. **How can I use `ffmpeg` to put `cover.jpg` as an embedded "cover" image into `audio.opus`?** Constraints ----------- - I don't want to re-encode the audio (so unfortunately, `opusenc --picture` s...
Question
========
I have 2 files:
-
audio.opus
(extension also possible: .opus.ogg
),
- cover.jpg
.
**How can I use ffmpeg
to put cover.jpg
as an embedded "cover" image into audio.opus
?**
Constraints
-----------
- I don't want to re-encode the audio (so unfortunately, opusenc --picture
seems out of scope),
- I don't want to re-encode the image (jpeg), although that's not much of a problem,
- I don't want to transform the image into a video (!),
- I'd really prefer doing it with ffmpeg
and not another tool,
- I don't want to hear about mp3.
Expected result
---------------
Here is how it should look like when it's properly done:
$ opusinfo audio_with_cover.opus
Processing file "audio_with_cover.opus"...
New logical stream (#1, serial: 39a74bbb): type opus
Encoded with libopus 1.3.1
User comments section follows...
ENCODER=opusenc from opus-tools 0.1.10
METADATA_BLOCK_PICTURE=3|image/jpeg||1280x720x24|
ENCODER_OPTIONS=--bitrate 56
Opus stream 1:
Pre-skip: 312
[...]
Or seen from ffprobe
:
$ ffprobe audio_with_cover.opus
[ogg @ 0x55675650ca80] 761 bytes of comment header remain
Input #0, ogg, from 'audio_with_cover.opus':
Duration: 00:02:25.64, start: 0.000000, bitrate: 71 kb/s
Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp
Metadata:
ENCODER : opusenc from opus-tools 0.1.10
ENCODER_OPTIONS : --bitrate 56
Stream #0:1: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 1280x720, 90k tbr, 90k tbn (attached pic)
Metadata:
comment : Cover (front)
Not possible?
-------------
If you know it is not possible, please let me know, I will open a feature request at ffmpeg
.
Totor
(21020 rep)
Sep 20, 2022, 04:10 PM
• Last activity: Apr 20, 2024, 09:10 PM
1
votes
1
answers
163
views
EXIF-based CLI renaming/querying tool for video/mp4?
I currently use [exiv2 0.28.2][1] tool to accomplish the same task on my JPEG/TIFF/Raw picture files from the [command line][2]. It works really great. Unfortunately it doesn't work reliably on `video/mp4` media types as it normally reports: corrupted image metadata Of course this can be considered...
I currently use exiv2 0.28.2 tool to accomplish the same task on my JPEG/TIFF/Raw picture files from the command line . It works really great.
Unfortunately it doesn't work reliably on
video/mp4
media types as it normally reports:
corrupted image metadata
Of course this can be considered *normal* as there is no mention about support for non-picture (e.g. movie) EXIF media type.
Is there any "*similar*" CLI tool that reliably works on media types like video/mp4
?
Even just querying would be OK to me as I could wrap that tool around with a script to emulate exiv2 behavior.
EnzoR
(1013 rep)
Mar 29, 2024, 11:28 AM
• Last activity: Mar 29, 2024, 03:12 PM
-3
votes
2
answers
78
views
Explain to a beginner the meaning of -mtime in simple human language
Of course, I read the meager lines from the manual. I'm still interested in the specifics. For example, the `stat / some_files` command print this: access 2024 (now) modified 2022 changeded 2023 created 2023 This is, for example, a certain program component, driver, library, script, and so on. I'm i...
Of course, I read the meager lines from the manual. I'm still interested in the specifics.
For example, the
stat / some_files
command
print this:
access 2024 (now)
modified 2022
changeded 2023
created 2023
This is, for example, a certain program component, driver, library, script, and so on.
I'm interested in what does modified in 2022 mean?
Does this mean that after downloading the package, unpacking into the appropriate directories / writing to disk occurred at exactly this date / time? And what in this case will “created” mean a year later?
alex099
(17 rep)
Mar 27, 2024, 08:45 AM
• Last activity: Mar 27, 2024, 10:30 AM
2
votes
1
answers
1923
views
Mat: Namespace Poppler not available
I've installed [MAT: Metadata Anonymisation Toolkit][1]. When I tried to run mat, I got following error: user@user ~ $ mat Traceback (most recent call last): File "/usr/bin/mat", line 10, in from libmat import mat File "/usr/lib/python2.7/dist-packages/libmat/mat.py", line 22, in import strippers #...
I've installed MAT: Metadata Anonymisation Toolkit . When I tried to run mat, I got following error:
user@user ~ $ mat
Traceback (most recent call last):
File "/usr/bin/mat", line 10, in
from libmat import mat
File "/usr/lib/python2.7/dist-packages/libmat/mat.py", line 22, in
import strippers # this is loaded here because we need LOGGING_LEVEL
File "/usr/lib/python2.7/dist-packages/libmat/strippers.py", line 9, in
import office
File "/usr/lib/python2.7/dist-packages/libmat/office.py", line 15, in
gi.require_version('Poppler', '0.18')
File "/usr/lib/python2.7/dist-packages/gi/__init__.py", line 102, in require_version
raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Poppler not available
I don't know how to fix this. Help.
Information about my system:
user@user ~ $ uname -a
Linux user 4.13.0-38-generic #43~16.04.1-Ubuntu SMP Wed Mar 14 17:48:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Columnist
(21 rep)
Apr 24, 2018, 08:28 PM
• Last activity: Mar 21, 2024, 03:22 PM
1
votes
2
answers
1658
views
Is there a way to add a "description" field / meta-data that could viewed in ls output (or an alternative to ls)?
I have been using unix systems the majority of my life. I often find myself teaching others about them. I get a lot of questions like "what is the `/etc` folder for?" from students, and sometimes I have the same questions myself. I know that all of the information is available with a simple google s...
I have been using unix systems the majority of my life. I often find myself teaching others about them. I get a lot of questions like "what is the
/etc
folder for?" from students, and sometimes I have the same questions myself. I know that all of the information is available with a simple google search, but I was wondering if there are any tools or solutions that are able to add descriptions to folders (and/or files) that could easily be viewed from the command line? This could be basically an option to ls
or a program that does something similar.
- I would like there to be something like this:
$ ls-alt --show-descriptions /
...
/etc – Configuration Files
/opt – Optional Software
/bin - Binaries
/sbin – System Binaries
/tmp – Temporary Files
...
- Could even take this a step further and have a verbose descriptions option:
$ ls-alt --show-descriptions-verbose /
...
/etc – The /etc directory contains the core configuration files of the system, use primarily by the administrator and services, such as the password file and networking files.
/opt – Traditionally, the /opt directory is used for installing/storing the files of third-party applications that are not available from the distribution’s repository.
/bin - The ‘/bin’ directly contains the executable files of many basic shell commands like ls, cp, cd etc. Mostly the programs are in binary format here and accessible by all the users in the Linux system.
/sbin – This is similar to the /bin directory. The only difference is that is contains the binaries that can only be run by root or a sudo user. You can think of the ‘s’ in ‘sbin’ as super or sudo.
/tmp – This directory holds temporary files. Many applications use this directory to store temporary files. /tmp directories are deleted when your system restarts.
...
I know that there is no default way to do this with ls
, and to add such a feature would probably require a lot of re-writing of kernel code to account for the additional data being stored, so I'm not asking how to do this natively necessarily (unless there is an easy way I am overlooking). **I am more asking if there is a tool that already exists for educational purposes that enables this sort of functionality?** I guess it would take output from ls
and then do a lookup to match directory names to descriptions it has already saved somewhere, but I digress.
BitWrecker
(197 rep)
Sep 10, 2022, 06:45 PM
• Last activity: Jan 5, 2024, 03:30 PM
2
votes
2
answers
1709
views
How do I get song names and artists from mp3 files in a dir?
I have a recovered dir with mp3 and flac files. The names were lost. So all I got is a mess of around 30,000 files iwth names like f30818304.flac I played some and see that the tags in the files are intact. But the thing is, most of it I probably don't need. I just want to see if there's any raritie...
I have a recovered dir with mp3 and flac files. The names were lost. So all I got is a mess of around 30,000 files iwth names like f30818304.flac
I played some and see that the tags in the files are intact.
But the thing is, most of it I probably don't need. I just want to see if there's any rarities in those files. So what I need is a way to massively write the tags to a file. Like "Artist - Song", one per line would be enough.
Anyone know of a way to do this ? command line preferably.
Nelson Teixeira
(470 rep)
Apr 16, 2017, 09:59 PM
• Last activity: Dec 18, 2023, 05:59 PM
5
votes
1
answers
173
views
is stat(2) read-after-write consistent with write(2)?
`man 2 write` states: >POSIX requires that a read(2) that can be proved to occur after a write() has returned will return the new data. Note that not all filesystems are POSIX conforming. In Linux, is this also true for `stat(2)` and `fstat(2)`, in particular, for the `stat.st_size` member? Specific...
man 2 write
states:
>POSIX requires that a read(2) that can be proved to occur after a write() has returned will return the new data. Note that not all filesystems are POSIX conforming.
In Linux, is this also true for stat(2)
and fstat(2)
, in particular, for the stat.st_size
member?Specifically, if you open a file with
O_CREAT
, successfully write 948427 bytes to it, then either stat or fstat it, are you guaranteed to see a st_size
of 948427?(If so, is this a guarantee for POSIX filesystems, or something that typical Linux filesystems provide in practice, or a property of certain filesystems and not others?)
Shivaram Lingamneni
(306 rep)
Dec 3, 2023, 08:12 AM
• Last activity: Dec 3, 2023, 10:58 PM
Showing page 1 of 20 total questions