Questions tagged [files]
Manipulating files: copying, renaming, searching, analyzing, archiving, etc. For operating on text in a file, see /text-processing. For questions about the Files file manager (formerly Nautilus), see /nautilus.
4,989
questions
9
votes
2
answers
133k
views
How can I execute any command as a normal user without sudo?
Is it possible to assign the setuid bit to sudo in order to execute any command as a normal user?
Let's suppose that we have the user test and then:
test@test$ apt-get update
But I don't want to use ...
12
votes
4
answers
5k
views
How can I restore my default .bashrc file again?
I accidentally changed all the contents of the .bashrc file and I haven't scripted it yet so there's no problem for now. I added little scripts to it (just a few alias), so I can write them again one ...
0
votes
1
answer
197
views
Is there a case where Applications need to do it's own File corruption checks with file systems like EXT4 and XFS and recent Linux OS like Red-Hat 8
What I presumed is
File systems like EXT4 and XFS. Writes blocks to disk (Could be a Hard Disk or a SSD) along with a checksum.
When Reading back, if checksum fails, read operation will NOT return ...
8
votes
8
answers
4k
views
How to cut a file starting from the line in which a certain pattern occurs?
I have a gazillion files which need to be reduced in size. I found that most (not all) files have an end section which can be cut without losing information:
Data 1
Data 2
something_unimportant_here ...
0
votes
1
answer
522
views
Creating a zip file incrementally
I currently have a large directory on S3 (>100GB). I want to create a zip archive of this directory.
Currently, I download the contents of the directory and create a scratch (temp) directory on the ...
0
votes
0
answers
42
views
How make multiple files available as one, akin to symlinking?
Is there a way to take a list of files and make them available under a single name (in a read-only fashion)?
Let's say I have:
f1.txt
f2.txt
f3.txt
And I would like to read sequentially through all ...
-1
votes
1
answer
209
views
What is the "l" command in Linux?
I just accidentally typed l and hit enter. Then this happened.
I'm not talking about ls -l just l.
Why did this happen?
0
votes
1
answer
289
views
What file compression software/algorithm is best for mixed types of files? [closed]
I am looking to backup a large amount (~400GB) of different types of files (50% images and videos, 30% audio, 20% text). I hesitate to give an amount by which I'd like the size to be reduced, since I ...
203
votes
20
answers
74k
views
Is there an easy way to replace duplicate files with hardlinks?
I'm looking for an easy way (a command or series of commands, probably involving find) to find duplicate files in two directories, and replace the files in one directory with hardlinks of the files in ...
1
vote
1
answer
121
views
How to trace file descriptor duplication?
I am learning to use redirection. the typical operation is like below:
command > file 2>&1
Refer to APUE 3.10 and 3.12, I think the critical syscall sequence is like below:
open(...
0
votes
1
answer
157
views
Temporary symlink in shell - "named process substitution" - rename a file without creating a copy/symlink on the disk?
Thunderbird doesn't open files that don't have .eml extension as email files, but instead starts to compose a new message and adds them as attachments. To use thunderbird in scripts I'm looking for a ...
0
votes
1
answer
59
views
How to find a file and copy its directory without copying the other files in that same directory?
I have a lot of different folders with pdf files and other extensions. I want to copy all the pdf files to another destination. But if I do that with find like this:
"${SEARCHDIR}" -iname &...
73
votes
2
answers
193k
views
What is nobody user and group?
On my server (Synology DS212) some files and folders have nobody nobody users and groups. What are the characteristics of this user and group? Who can write of read this file?
How can I change it? For ...
5
votes
3
answers
5k
views
Find files greater than x kB/MB/GB in size, and also show their size
I'd like a simple command (perhaps using find) which finds all files > some size in bytes, kilobytes, megabytes, or gigabytes, and which prints their size as they are found.
This command, for ...
36
votes
4
answers
51k
views
Find file names that don't contain a specified string
I'd like to execute the opposite of:
find . -name "*2013*"
Find all the files in the current directory that don't contain the string "2013" in their names. How can I do that?
1
vote
2
answers
644
views
What's the POSIX-compliant way to get the size of a file or folder in bytes?
According to the Open Group specs, POSIX du doesn't have the -b option to display the size in bytes. So what is the POSIX-compliant way to get the size of a file or folder in bytes?
0
votes
0
answers
262
views
merging from 1022 files open Too many open files error?
I use samtools for coordinate sort a bam file. This command creates lots of files while running.
I run the following command
samtools sort -o sorted.bam genomic_dataset.bam
But it gives the following ...
20
votes
4
answers
27k
views
cat files in specific order based on number in filename
I have files named file.88_0.pdb, file.88_1.pdb, ..., file.88_100.pdb. I want to cat them so that file.88_1.pdb gets pasted after file.88_0.pdb, file.88_2.pdb after file.88_1.pdb, and so on. If I do ...
-1
votes
5
answers
534
views
Recursively rename all the files without changing their extensions?
How to recursively rename all the files in several layers of subdirectories without changing their extensions?
Below's a toned down version (to save room) of what I've got.
For argument's sake, I ...
1
vote
2
answers
721
views
How to move (image) files to other directories based on files' dates
I have a directory (currdir) with 24000 images on a CentOS/cPanel server.
I want to split this directory by moving images from this directory into other directories (or sub-directories inside currdir) ...
0
votes
1
answer
450
views
What is the max size limit for using split and cat combination?
I have backed up a file in zip format on Ubuntu whose size is 6.5GB. Trying to transfer it to a USB stick so needed to split since I got error “file size too large” while copying. (Ideally I want my ...
18
votes
3
answers
1k
views
How can I be sure that a directory or file is actually deleted?
I know that most files, when deleted, aren't actually removed from the disk, and can be recovered later.
How can I ensure that a directory I had deleted will actually be removed from the disk? Are ...
2
votes
2
answers
2k
views
`du -sh` and `du -sb` gives different result when file being accessed?
I set up a file server with samba and I'm copying files to it from another computer under the same LAN. I set up SSH server and connected to it with my phone to monitor the process.
This is what I ...
13
votes
2
answers
15k
views
Clear recent open file history on Linux Mint
Sometimes others in my household briefly use my computer, when they do I sometimes don't want them to see my file history. I know how to prevent Bash from writing entries to the ~/.bash_history file ...
1
vote
1
answer
47
views
Linux system logs
In one of our AWS Linux virtual machines, the ca-certificate.crt file has been modified, and our private CA has been deleted.
How can I determine who made these changes and deletions?
9
votes
3
answers
100k
views
Move files to different folder based on the creation date [duplicate]
I have a set of files created from Monday to Friday:
a -- > 08/20
a1---> 08/21
a2---> 08/21
a3---> 08/21
a4---> 08/22
a5 --> 08/23
I need to move only the 08/21 files to a different ...
1
vote
1
answer
1k
views
How to speed up awk script that uses several large gzip files?
I have two data files:
file_1.in, containing over 2k lines like "12 AB0001":
10 AB0001
11 AC0002
12 AD0003
...
A list of *.gz gzipped files (about 1 to 3 million lines) I should
extract and parse ...
-1
votes
1
answer
125
views
Why can't list the files ending with tmp?
The are four files ending with tmp in my Desktop directory.
Why can't I list them?
ls -al |rg tmp
#nothing as output
debian@debian:~/Desktop$ ls -al lu12761y6p7ro.tmp
ls: cannot access '...
0
votes
0
answers
101
views
files getting automatically deleted on my dual boot
I have two main partition on my laptop, C: where windows is and E: where my files are and one extra partion which I created by shrinking partition E: where my fidora linux is installed(in total 3 main ...
6
votes
3
answers
26k
views
How can I extract a RAR file on Debian?
I've got a 20GB RAR file to extract with a password on Debian Linux Google Cloud VM.
I first tried sudo apt-get install unrar but the following output was given:
Reading package lists... Done
Building ...
0
votes
1
answer
180
views
Change file name based on contents
I'm trying to rename a set of files based on what is in the file itself. I have likely more than a thousand files to rename by the time I'm done. I have code that will get me the first part of the ...
2
votes
1
answer
759
views
VIM shows ^@ every other character and ^M^@ at the end of line
Sorry if it's answered somewhere, I have no idea how to look for it. I received a series of reports from a bank that I'm supposed to process and they seem to be... badly encoded?
First two lines in ...
6
votes
4
answers
14k
views
Noip “Can't locate configuration file”, but the file is there
I installed Noip and ran the command which created the config file
/usr/local/bin/noip2 -C
and then I ran the run command
/usr/local/bin/noip2
and it returned
Can't locate configuration file /usr/...
14
votes
4
answers
17k
views
How to zip directory excluding symbolic links and the files they point to?
I have a directory with files, subdirectories and symlinks
How to zip only files and folders from that directory without symlinks or files referred to by the symlink?
50
votes
6
answers
36k
views
List files sorted by the number of lines they contain
How can I list the number of lines in the files in /group/book/four/word, sorted by the number of lines they contain?
The ls -l command lists the files but does not sort them.
0
votes
0
answers
29
views
Cannot open files in texlive directory
I've installed texlive 2023 via tlmgr, the directory is /usr/local/texlive/2023/ and update it with sudo tlmgr --self --all --no-auto-remove update as I've been doing it for years. It works perfectly ...
97
votes
7
answers
306k
views
Move all files with a certain extension from multiple subdirectories into one directory
I have a bunch of .zip files in several directories:
Fol1/Fol2
Fol3
Fol4/Fol5
How would I do move them all to a common base folder?
0
votes
1
answer
575
views
Return list using git diff and grep
I'm using git diff to return the file names of files recently changed and i'm trying to pipe the returned file names into a grep expression that searches each file and returns the files that have &...
0
votes
1
answer
2k
views
Sort function doesn't work when scaling up size of input data
So a week ago I asked a question, > here
, The question was about sorting. If I use this code for sorting and creating files:
tail -n +2 File1.txt |
split -l1 --filter='
{
head -n 1 ...
6
votes
5
answers
9k
views
How to add an attribute in a tag in XML file by command-line?
I am trying to add field at the end of tag using sed script. Suppose I have a tag in XML file:
<book name="Sed tutorial" price="250"/>
Now I want to add field as Book_Width="A" after end of &...
0
votes
1
answer
158
views
w3m website dump without line break
I am not a native english speaker, if any grammatical mistakes please forgive me
every one says books are best friend and remove ignorance, so I got a online library but my english is not good, so i ...
1
vote
0
answers
63
views
Best practices for file and directory permissions in a multi-user environment
This is my situation in an experimental environment.
A php script is creating files in a target directory when it's executed from Apache via web request.
It runs as www-data user, the created files ...
83
votes
9
answers
131k
views
How do I shorten the current directory path shown on terminal?
If I am in a deep directory, let's say:
~/Desktop/Dropbox/School/2017/C/A3/
then when I open up terminal, it says
bob@bob-ubuntu:~/Desktop/Dropbox/School/2017/C/A3/$
and then I write my command.
...
-1
votes
1
answer
183
views
Linux Bash Shell Script - To Find Files with Zero Size and Delete
List of files are stored in a variable REMOVEFILES. Script need to verify the list of files one by one and if the file is ZERO in size, it should be deleted. Please help me fixing it.
#!/bin/bash
...
0
votes
1
answer
8k
views
Debian all sudo commands fail with 'user is not in the sudoers file. This incident will be reported.' error [duplicate]
I tried out Linux for the first time. When I installed Bullseye Debian a few hours ago I created a root account and user account. Both of them have a password. However whenever I try to use sudo to ...
3
votes
2
answers
203
views
Is it possible to transfer files between 2 PCs connected to a single router?
I have 2 laptops plugged into a ZTE ZXA10-F660 PON (like a 4 port ethernet router but with a fiber optic WAN connection). One laptop is running Linux Mint 19 Cinnamon (enp4s0) and the other is running ...
0
votes
2
answers
250
views
Why are empty ".z.*" files being created in my home folder and can I safely remove them?
In my home folder, I have realized that plenty of .z.* files are being created, and they are all empty. I have no idea which process created them.
What might be the reason for all these files being ...
0
votes
0
answers
43
views
list all the lines of an output that are not in the contents of another file
I have a directory of files. I want to check which of these files are not listed in the contents of another file, (content.txt).
content.txt contains the file names, but also contains some text before ...
-3
votes
1
answer
426
views
Im trying to run a shell script but I keep getting If: expression syntax. How to I get rid of it
Good afternoon, I'm trying to run my code for assignment 4 but I keep getting an expression syntax error, can you tell me why?
#!/bin/sh
if [ "$#" -ne 1 ] then
echo "Usage: ...
55
votes
3
answers
17k
views
A layman's explanation for "Everything is a file" — what differs from Windows?
I know that "Everything is a file" means that even devices have their filename and path in Unix and Unix-like systems, and that this allows for common tools to be used on a variety of resources ...