Mar 21 15:59:56 loong kernel: [ 364.376809] communicator[5399]: segfault at 273c6 ip 00000000000273c6 sp 00007fc0c8a15818 error 14 in communicator (deleted)[400000+29000]
When you delete a file currently in use, it gets marked deleted and is no longer listed but can still be used until the process currently having it open closes it.
$ cat > foo &
[1] 13566
$ rm foo
[1]+ Stopped cat > foo
$ ls foo
ls: cannot access foo: No such file or directory
$ ls -l /proc/13566/fd
total 0
lrwx------ 1 pterjan pterjan 64 Mar 22 21:17 0 -> /dev/pts/4
l-wx------ 1 pterjan pterjan 64 Mar 22 21:17 1 -> /tmp/foo (deleted)
lrwx------ 1 pterjan pterjan 64 Mar 22 21:17 2 -> /dev/pts/4
So, the communicator executable had been deleted before it crashed (maybe it was replaced by a new one during an update, or it was just deleted).
Related
I was running a simulation on a terminal and the simulation did not go through due to disk space issue. (It reported "No space left on device")
Then we cleaned up some space and ran simulation on the same terminal.
However, it still complained the space issue.
When we ran on a new terminal, the simulation went through.
Hence I want to understand the cause of this.
Please help
Thank you.
This is a common issue in linux.
If a process has opened a file and not closed it, removing the file only removes the directory entry (think name) from the directory it is in. Until the file is closed by the process or the process terminates the disk space will not be reclaimed.
To find these files you can look through the /proc file system. Every running process can be found in there by it process id (pid).
Here I'm running a python program that opened a file and is doing nothing. If I use ps to find the pid of the process and cd int /proc/<pid>/fd I can see the open file descriptors and the names of the files that are open:
$ pwd
/proc/38246/fd
$ ls -l
total 0
lrwx------ 1 x x 64 Sep 8 15:39 0 -> /dev/pts/0
lrwx------ 1 x x 64 Sep 8 15:39 1 -> /dev/pts/0
lrwx------ 1 x x 64 Sep 8 15:39 2 -> /dev/pts/0
lr-x------ 1 x x 64 Sep 8 15:39 3 -> /tmp/test
If I remove the file /tmp/test I see this:
$ rm /tmp/test
$ ls -l
total 0
lrwx------ 1 x x 64 Sep 8 15:39 0 -> /dev/pts/0
lrwx------ 1 x x 64 Sep 8 15:39 1 -> /dev/pts/0
lrwx------ 1 x x 64 Sep 8 15:39 2 -> /dev/pts/0
lr-x------ 1 x x 64 Sep 8 15:39 3 -> /tmp/test (deleted)
Search through /proc/*/fd/ for files that say deleted.
I have some 1080x1920 png files and I want to crop them into 1080x1728 with offset-y 65, so I tried and it returns this:
gimp -i -b '(gimp-image-crop "*.png" 1080 1728 0 65)' -b '(gimp-quit 0)'
$ ll
total 1796
drwxrwxr-x 2 cat cat 4096 Jul 25 15:06 ./
drwxrwxr-x 4 cat cat 4096 Jul 25 14:37 ../
-rwxrwxr-x 1 cat cat 278356 Jul 9 10:56 1.png*
-rwxrwxr-x 1 cat cat 278356 Jul 9 10:56 Screenshot_20210709-105437.png*
-rwxrwxr-x 1 cat cat 58088 Jul 9 10:56 Screenshot_20210709-105445.png*
-rwxrwxr-x 1 cat cat 108385 Jul 9 14:54 Screenshot_20210709-145331.png*
-rwxrwxr-x 1 cat cat 130486 Jul 9 22:18 Screenshot_20210709-221631.png*
-rwxrwxr-x 1 cat cat 133602 Jul 9 22:20 Screenshot_20210709-221834.png*
-rwxrwxr-x 1 cat cat 153976 Jul 9 22:22 Screenshot_20210709-222035.png*
-rwxrwxr-x 1 cat cat 149365 Jul 9 22:23 Screenshot_20210709-222039.png*
-rwxrwxr-x 1 cat cat 124369 Jul 11 17:01 Screenshot_20210711-165959.png*
-rwxrwxr-x 1 cat cat 138719 Jul 24 23:06 Screenshot_20210724-230338.png*
-rwxrwxr-x 1 cat cat 88272 Jul 24 23:06 Screenshot_20210724-230346.png*
-rwxrwxr-x 1 cat cat 104779 Jul 24 23:06 Screenshot_20210724-230356.png*
-rwxrwxr-x 1 cat cat 63867 Jul 24 23:05 Screenshot_20210724-230408.png*
$ gimp -i -b '(gimp-image-crop "*.png" 1080 1728 0 65)' -b '(gimp-quit 0)'
batch command experienced an execution error:
Error: Invalid type for argument 1 to gimp-image-crop
$
It always returns Invalid type for argument 1 to gimp-image-crop.
I check in Procedure Browser in GIMP and it tells:
The argument 1 is "THE IMAGE". I also tried "1.png" and ".+png" but it always returns the same error: Error: Invalid type for argument 1 to gimp-image-crop
I don't understand which part I do wrong.
My OS is Linux Mint 20.2 Cinnamon and GIMP version is 2.10.18.
Please help.
The image argument of gimp-image-crop is the handle of a loaded image in Gimp, not an image file. So you have to gimp-file-load the image (this gives you a handle), apply your operations, and then gimp-file-save. Note that saving an image to a "flat" format (JPG, PNG...) is actually saving a layer, so if your image is more than one layer you may have to first create a layer to save using gimp-layer-new-from-visible.
This said, agreed that in most cases it is faster to use ImageMagick.
I have a bunch of MP4 files that look like this:
-rw-rw-r-- 1 116M Apr 19 06:08 lULIqx9Akn4.mp4
These are youtube videos. When I try to do anything with all of them, I get a weird error. Every command I try says that I'm using invalid options (that I am not using). Here are some examples.
$ ls *.mp4
/bin/ls: invalid option -- '7'
Try '/bin/ls --help' for more information.
$ mv *.mp4 videos/
mv: invalid option -- 'L'
Try 'mv --help' for more information.
$ cp *.mp4 videos/.
cp: invalid option -- '7'
Try 'cp --help' for more information.
It doesn't do the same thing with a different extension (*.mp3, *.txt, *.sh).
What's going on? How do I fix this?
I used this as a cheap workaround,
find . -name "*.mp4" -exec mv {} videos/. \;
but I want to understand what's happening, not just get the job done.
One of your filenames starts with a hyphen, e.g,. -7 or -L. Try ls -- *.mp4 or cp -- *.mp4 videos. Also, allow me to suggest UNIX and Linux Stack Exchange for shell questions :) .
Solution:
Either move the files,
mv -- *.mp4 ./videos
or rename the files in situ...
for file in -*.mp4; do mv -- "$file" "${file:1}"; done
Explanation:
My sense is you have a file with a leading - in the directly... most commands stop you creating such files but if you copy them from another operating system it can occur. Thus, you need to rename any files with a leading - in their filename...
Let me explain with an example...
Let's try to create a file with a leading -:
touch "-7ULIqx9Akn4.mp4"
touch: illegal option -- 7
we can get around this as follows:
>touch -- "-7ULIqx9Akn4.mp4"
> ls -al -- -*.mp4
total 0
-rw-r--r--# 1 n staff 0 Apr 29 13:02 -7ULIqx9Akn4.mp4
ok, now lets set up an example and demonstrate a solution...
> ls -la
total 0
-rw-r--r--# 1 n staff 0 Apr 29 12:49 -75438752.mp4
-rw-r--r--# 1 n staff 0 Apr 29 12:49 -85438750.mp4
drwxr-xr-x# 7 n staff 238 Apr 29 12:49 .
drwxr-xr-x# 6 n staff 204 Apr 29 11:18 ..
-rw-r--r--# 1 n staff 0 Apr 29 12:36 75438750.mp4
-rw-r--r--# 1 n staff 0 Apr 29 12:33 7ULIqx9Akn4.mp4
-rw-rw-r--# 1 n staff 0 Apr 29 11:19 lULIqx9Akn4.mp4
next:
ls -- -*.mp4
-75438752.mp4 -85438750.mp4
ok, lets now rename these files...
A little explanation here, the following command uses mv to remove the leading character. i.e. Find files with a leading - and remove the leading character {$file:1} from the filename...
for file in -*.mp4; do mv -- "$file" "${file:1}"; done
Result:
> for file in -*.mp4; do mv -- "$file" "${file:1}"; done
> ll
total 0
drwxr-xr-x# 7 n 238 Apr 29 12:52 ./
drwxr-xr-x# 6 n 204 Apr 29 11:18 ../
-rw-r--r--# 1 n 0 Apr 29 12:36 75438750.mp4
-rw-r--r--# 1 n 0 Apr 29 12:49 75438752.mp4
-rw-r--r--# 1 n 0 Apr 29 12:33 7ULIqx9Akn4.mp4
-rw-r--r--# 1 n 0 Apr 29 12:49 85438750.mp4
-rw-rw-r--# 1 n 0 Apr 29 11:19 lULIqx9Akn4.mp4
Note
The above does not account for duplicate file names...
I want to find out IP of ssh connection using kernel code. However, I'm unable to find any suitable reference on Internet.
I tried using usermodehelper API but it seems it doesn't provide the output back in kernel.
Any help is much appreciated!
Let's assume 3298 is the pid of the process you are interested in. In userpsace, I can call
ls -l /proc/3298/fd
It will list something similar like
lrwx------ 1 name name 64 Apr 6 11:27 0 -> /dev/pts/2
lrwx------ 1 name name 64 Apr 6 11:27 1 -> /dev/pts/2
lrwx------ 1 name name 64 Apr 6 11:27 2 -> /dev/pts/2
lrwx------ 1 name name 64 Apr 6 11:27 3 -> socket:[50256]
lrwx------ 1 name name 64 Apr 6 11:37 4 -> /dev/pts/2
lrwx------ 1 name name 64 Apr 6 11:37 5 -> /dev/pts/2
lrwx------ 1 name name 64 Apr 6 11:37 6 -> /dev/pts/2
We now know that fd 3 (and only fd 3) is the file descriptor you are looking for. Your information should be in fd 3. You should be able to do the same thing in kernelspace by looking at the kernel sources how /proc/pid/fd is implemented.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I have two files in my home folder named "'?" and "'?;?" (without the double quotes). How can I delete them? I've tried to use escape, but it doesn't work.
Use single or double quotes to avoid wildcard expansion. A ? is a wildcard which indicates to the shell to match with any one single character. By placing it in quotes you are telling the shell not to perform wildcard expansion.
rm '?' '?;?'
rm "?" "?;?"
This will remove the two files named "?" and "?;?"
You can also use a backslash to quote the individual characters that have special meaning to the shell, so you could do this
rm \? \?\;\?
Notice you have to quote the '?' to prevent pathname expansion and you have to quote the ';' so the shell doesn't interpret that as separating commands.
If you leave out the quotes, then the shell parses it differently. Here's an experiment I ran.
$ for i in {1..4}; do for j in {a..c}; do touch "$i;$j" $j '?' '?;?';done;done
$ ls
1;a 1;b 1;c 2;a 2;b 2;c 3;a 3;b 3;c 4;a 4;b 4;c ? ?;? a b c
$ rm ? ?;?
rm: cannot remove `?': No such file or directory
rm: cannot remove `a': No such file or directory
rm: cannot remove `b': No such file or directory
rm: cannot remove `c': No such file or directory
bash: ?: command not found
$ rm `echo "?" "?;?"`
rm: cannot remove `?': No such file or directory
$
What happened here is the shell did pathname expansion, so
rm ? ?;?
became
rm ? a b c ? a b c;? a b c
The rm command removed files a b c ? then complained that the following files were not found (they had already been deleted). The semicolon separated commands, so it then tried to invoke the '?' command passing arguments "a" "b" "c" ... but there is no '?' command - the file named '?' had just been deleted, and it wasn't executable anyway - so the shell complains that the "?" command is not found.
If you want to remove all files matching "?" and "?;?" you need to trick the shell into expanding those, which I did like this
rm `echo "?" "?;?"`
This was expanded by the shell in two steps, first it runs echo "?" "?;?" which results in two strings, "?" and "?;?", then it does pathname expansion using those strings to produce the arguments for rm, which results in
rm ? 1;a 1;b 1;c 2;a 2;b 2;c 3;a 3;b 3;c 4;a 4;b 4;c ?;?
Notice that the wildcard expansion for '?' didn't produce any matching files this time (they had already been previously deleted), so the shell passes '?' as an argument to rm, which successfully removes all files passed as arguments except for '?' so it complains about that.
Here's another experiment
$ for i in {1..4}; do for j in {a..c}; do touch "$i;$j" $j '?' '?;?';done;done
$ ls
1;a 1;b 1;c 2;a 2;b 2;c 3;a 3;b 3;c 4;a 4;b 4;c ? ?;? a b c
$ rm "?" "?;?"
$ ls
1;a 1;b 1;c 2;a 2;b 2;c 3;a 3;b 3;c 4;a 4;b 4;c a b c
$ rm `echo "?" "?;?"`
$ ls
$
For more information consult the man page on globbing
man 7 glob
Wildcard Matching
A string is a wildcard pattern if it contains one of the characters '?', '*' or '['. Globbing is the operation that
expands a wildcard pattern into the list of pathnames matching the pattern. Matching is defined by:
A '?' (not between brackets) matches any single character.
A '*' (not between brackets) matches any string, including the empty string.
Note that ls can report a question mark for arbitrary non-printable characters, so there's a chance that what you've got as a file name does not contain a question mark.
You can spot this with the ls -b command, or with ls | cat.
As a convoluted example, complete with remedy, I created a script convolvulus like this:
set -x
mkdir convoluted &&
(
cd convoluted
cp /dev/null "$(ls -la | sed 1d)"
ls
ls -b
ls | cat
ls -la | cat
cp /dev/null $'\n'
cp /dev/null $'\n;\n'
ls -als | cat
ls -lab
ls
ls | cat
rm $'\n' $'\n;\n' d*
ls -a
)
rm -fr convoluted
When run, it yielded:
$ bash convolvulus 2>&1 | so
+ mkdir convoluted
+ cd convoluted
++ ls -la
++ sed 1d
+ cp /dev/null 'drwxr-xr-x 2 jleffler staff 68 Mar 9 11:58 .
drwxr-xr-x 240 jleffler staff 8160 Mar 9 11:58 ..'
+ ls
drwxr-xr-x 2 jleffler staff 68 Mar 9 11:58 .
drwxr-xr-x 240 jleffler staff 8160 Mar 9 11:58 ..
+ ls -b
drwxr-xr-x 2 jleffler staff 68 Mar 9 11:58 .\ndrwxr-xr-x 240 jleffler staff 8160 Mar 9 11:58 ..
+ ls
+ cat
drwxr-xr-x 2 jleffler staff 68 Mar 9 11:58 .
drwxr-xr-x 240 jleffler staff 8160 Mar 9 11:58 ..
+ ls -la
+ cat
total 0
drwxr-xr-x 3 jleffler staff 102 Mar 9 11:58 .
drwxr-xr-x 240 jleffler staff 8160 Mar 9 11:58 ..
-rw-r--r-- 1 jleffler staff 0 Mar 9 11:58 drwxr-xr-x 2 jleffler staff 68 Mar 9 11:58 .
drwxr-xr-x 240 jleffler staff 8160 Mar 9 11:58 ..
+ cp /dev/null '
'
+ cp /dev/null '
;
'
+ ls -als
+ cat
total 0
0 -rw-r--r-- 1 jleffler staff 0 Mar 9 11:58
0 -rw-r--r-- 1 jleffler staff 0 Mar 9 11:58
;
0 drwxr-xr-x 5 jleffler staff 170 Mar 9 11:58 .
0 drwxr-xr-x 240 jleffler staff 8160 Mar 9 11:58 ..
0 -rw-r--r-- 1 jleffler staff 0 Mar 9 11:58 drwxr-xr-x 2 jleffler staff 68 Mar 9 11:58 .
drwxr-xr-x 240 jleffler staff 8160 Mar 9 11:58 ..
+ ls -lab
total 0
-rw-r--r-- 1 jleffler staff 0 Mar 9 11:58 \n
-rw-r--r-- 1 jleffler staff 0 Mar 9 11:58 \n;\n
drwxr-xr-x 5 jleffler staff 170 Mar 9 11:58 .
drwxr-xr-x 240 jleffler staff 8160 Mar 9 11:58 ..
-rw-r--r-- 1 jleffler staff 0 Mar 9 11:58 drwxr-xr-x 2 jleffler staff 68 Mar 9 11:58 .\ndrwxr-xr-x 240 jleffler staff 8160 Mar 9 11:58 ..
+ ls
;
drwxr-xr-x 2 jleffler staff 68 Mar 9 11:58 .
drwxr-xr-x 240 jleffler staff 8160 Mar 9 11:58 ..
+ ls
+ cat
;
drwxr-xr-x 2 jleffler staff 68 Mar 9 11:58 .
drwxr-xr-x 240 jleffler staff 8160 Mar 9 11:58 ..
+ rm '
' '
;
' 'drwxr-xr-x 2 jleffler staff 68 Mar 9 11:58 .
drwxr-xr-x 240 jleffler staff 8160 Mar 9 11:58 ..'
+ ls -a
.
..
+ rm -fr convoluted
$
Have fun!
The -b option to ls works for GNU ls and for Mac OS X and BSD ls (but is not defined by POSIX).
The '$'\n' notation is Bash ANSI-C Quoting.
Use quotes around the file names:
$ ls
? ?;?
$ rm '?'
$ ls
?;?
$ rm "?;?"
$ ls
$