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 4 years ago.
Improve this question
I found a file named '.|rst412slp10lad10_noTopo.png', and I really want to remove this. what should I do?
I tried to use ls -al to get the info of the file then I got this:
ls: cannot access '.|rst412slp10lad10_noTopo.png': No such file or directory
total 0
drwxrwxrwx 1 jinshengye jinshengye 4096 Jun 5 17:10 .
drwxrwxrwx 1 jinshengye jinshengye 4096 Jun 5 16:58 ..
-????????? ? ? ? ? ? .|rst412slp10lad10_noTopo.png
What should I do?
Find the inode number(s) with
ls -li
And remove it with
find . -inum 1234 -delete
OK you can try deleting with quotes
rm ".|rst412slp10lad10_noTopo.png"
but that probably won't work, you may need to set rights and /or reboot (or more)... Have a look at this:
https://serverfault.com/questions/65616/question-marks-showing-in-ls-of-directory-io-errors-too?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Basically, I want to get socket and pipe owners starting from a PID located in the /proc/PID/fd/ directory using the "stat" command:
lrwx------ 1 root root 64 dic 23 17:52 0 -> socket:[9790]
l-wx------ 1 root root 64 dic 23 17:52 1 -> /var/log/messages
l-wx------ 1 root root 64 dic 23 17:52 2 -> /var/log/secure
lr-x------ 1 root root 64 dic 23 17:52 3 -> /proc/kmsg
l-wx------ 1 root root 64 dic 23 17:52 4 -> /var/log/maillog
l-wx------ 1 root root 64 dic 23 17:52 5 -> /var/log/cron
How could I use "stat" to get each socket owner when I just have the socket name (socket:[9790]) instead of its symbolic reference (0,1,2...)?
Thanks for your answer!
For this lsof is much better.
You can use lsof -i -a -p $PID.
There is a similar question on the unix hub on the StackExchange.
https://unix.stackexchange.com/questions/235979/how-do-i-find-out-more-about-socket-files-in-proc-fd
I think that should solve your problem.
I do not think that you can do this with one simple stat instruction. Instead you could try to utilize find in order to search for symbolic links an then print them formatted. You can then, e.g., pipe the result to grep and cut to filter for the information you need:
find /proc/PID/fd/ -type l -printf '%u %l\n' 2>/dev/null|grep "socket:[9790]"|cut -d' ' -f1
You can use find's options (-mindepth, -maxdepth) in order to determine how deep it shall descend into subfolders for its search. If you want the owner's UID instead of the username then use %U instead of %u in -printf.
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 4 years ago.
Improve this question
I am working through this resource: https://cmdchallenge.com
On the following challenge: https://cmdchallenge.com/s/#/search_for_files_containing_string, the problem was:
Print all files in the current directory,
one per line (not the path, just the filename)
that contain the string "500".
When I ran:
ls -al
I got the following:
total 36
drwxr-xr-x. 2 501 dialout 4096 Feb 10 21:08 .
drwxr-xr-x. 39 501 dialout 4096 Apr 18 19:04 ..
-rw-r--r--. 1 501 dialout 204 Apr 29 17:44 README
lrwxrwxrwx. 1 501 dialout 23 Feb 10 20:59 access.log -> ../../common/access.log
lrwxrwxrwx. 1 501 dialout 25 Feb 10 21:08 access.log.1 -> ../../common/access.log.1
lrwxrwxrwx. 1 501 dialout 25 Feb 10 21:08 access.log.2 -> ../../common/access.log.2
I tried a few things, then looked at the user submitted solutions and one of them was:
ls *[^2]
I did some googling and the man page (and here), but I can't see what this is doing, or how it works.
Can anyone point me to a decent resource so I can read up on it, or tell me how it works?
Let me first quote PesaThes comment to what the command does:
The reference you are looking for is in the manual under: pattern matching. * matches any string, [^2] matches any character that is not 2. So the command lists all files that do not end in 2
Now why this is a solution to the problem is not so clear from your question alone. But if you look what the files contain you will notice that indeed, access.log.2 is the only one that does not contain the string 500 and also the only one whose name ends in 2.
For other sets of files the command ls *[^2] will most probably not output all the files without the string 500 in it, but in this case with those specific files it matches the right files. Another solution would have been for example
echo README; echo access.log; echo access.log.1
that's not an answer to your question, the right way of doing it is
$ grep -sl 500 * .*
-s skip errors (caused by directories); l only filenames; search in * all visible files and .* invisible files.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
This does not work:
del "folder\*.dll.config"
However, it does work without specifying a folder
cd folder
del "*.dll.config"
Why?
PS. Also, any workarounds? (beside the one mentioned - changing current dir and then going back)
EDIT: I'm an idiot I had a typo in my code, voting to close my own question now.
On my Windows 10, it works:
C:\>dir folder
Volume in drive C is SYSTEM
Directory of C:\folder
30.03.2017 14.33 <DIR> .
30.03.2017 14.33 <DIR> ..
29.03.2017 13.33 549.341 my.dll.config
29.03.2017 13.33 549.341 my.foo.bar
2 File(s) 1.098.682 bytes
2 Dir(s) 363.317.178.368 bytes free
C:\>del "folder\*.dll.config"
C:\>dir folder
Volume in drive C is SYSTEM
Directory of C:\folder
30.03.2017 14.33 <DIR> .
30.03.2017 14.33 <DIR> ..
29.03.2017 13.33 549.341 my.foo.bar
1 File(s) 549.341 bytes
2 Dir(s) 363.317.809.152 bytes free
C:\>
However, your misspelling of the error message in the comment above made me check something.
It may be completely irrelevant in your case, but sure enough, if I misspell the folder name, I get precisely the error you mentioned:
C:\>dir folder
Volume in drive C is SYSTEM
Directory of C:\folder
30.03.2017 14.33 <DIR> .
30.03.2017 14.33 <DIR> ..
29.03.2017 13.33 549.341 my.dll.config
29.03.2017 13.33 549.341 my.foo.bar
2 File(s) 1.098.682 bytes
2 Dir(s) 363.317.248.000 bytes free
C:\>del "dolder\*.dll.config"
The system cannot find the file specified.
C:\>
You can use thepushd and popd commands like:
pushd folder
del "*.dll.config"
popd
This way you move to the desire location, erase all .dll.config files and return to the previous location.
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
Anywhere I ls -a folder contains files called "." and "..".
Anybody knows what is this stuff? Is this some system files? Is this some kind of a virus or something? I have hard time googling because of such file names.
Here is an example:
drwx------+ 12 mih staff 408 4 янв 16:49 .
drwxr-xr-x+ 91 mih staff 3094 20 мар 15:28 ..
-rw-r--r--# 1 mih staff 6148 4 янв 16:49 .DS_Store
-rw-r--r-- 1 mih staff 0 10 ноя 2011 .localized
-rw-r--r--# 1 mih staff 181 27 ноя 2011 Desktop.ini
-rw-r--r--# 1 mih staff 8198298 29 июл 2013 Dizzee Rascal - Bassline Junkie.mp3
Yes, those are system files.
A subdirectiry contains two directory entries that were used to navigate between folders in the early days of DOS.
The . entry is a directory reference to the same directory.
The .. entry is a directory reference to the parent directory.
Those are like regular subdirectories, but instead they point to directories that already exist.
Nowadays those wouldn't actually be needed, the system could interpret . and .. anyway, but in the early days they were needed for the system to find the way back to the parent directory.
"." is a representation of the current directory in Unix based systems. ".." Is for upper directory.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I want to get the name of the users which executed a command (for example cat).
fc -l will provide a list with the most recent commands executed by the current user but is there an way to find out the history for all users?
I read the manual but i could not find something that would help
Do you know any other commands which would do this job?
I also tried w and who
I found this solution: the super user will search in each dir from "home" in the .bash_history and make a grep on that file for that command. It will work but is this optimal?
Using awk =)
awk -v monitoredcmd=cat '
$1~"^#[0-9]{10,}\s*$"{
sub(/#/,"")
tmpdate=$1
}
$1==monitoredcmd{
"date -d #"tmpdate | getline date
close("date -d #"tmpdate)
print "command [" $0 "] by",
gensub(/\/home\/([^\/]+).*/, "\\1", "", FILENAME),
at,
date
}
' /home/*/.bash_history
Sample Output
command [cat file.txt] by sputnick mer. févr. 13 15:34:44 CET 2013
command [cat l.py] by sputnick mer. févr. 13 15:45:38 CET 2013
command [cat foobar.pl] by marc mer. févr. 13 15:47:54 CET 2013