Tagged Questions

Use this tag for questions about file management and operations on files.

learn more… | top users | synonyms (1)

1
vote
2answers
59 views

How to give sftp access to sub-directory only not to parent

I want to give SFTP access to user tom for directory /var/www/html/my_project/. while I don't want to give any SFTP access to directory /var/www/html/. currently /var/www/html/my_project/ and ...
5
votes
7answers
727 views

Linux command line. Move all files and directories in directory, except some files and directories

I have a folder A which has files and directories, I want to move all those files and directories to another folder B, except file, file2, directory, and directory2. How can this be done?
3
votes
1answer
57 views

chroot into a sshfs folder

I am trying to chroot into a sshfs-mounted directory: mkdir remoteroot sshfs remote:/ remoteroot/ sudo chroot remoteroot/ but I get chroot: cannot change root directory to remoteroot/: Permission ...
11
votes
1answer
136 views

When did directories stop being readable as files?

I have the 1st edition of The Unix Programming Environment book. In chapter 2, the authors state that directories are readable as files, and mention some facts about the format of these files. They ...
1
vote
1answer
57 views

Create a file that's really a network port

I have a program running on a cluster, and the output of the program is written to a log file which I specify. However, instead of writing it to a file, I want to write it to a network port, so that ...
0
votes
1answer
21 views

Convenient way to upload a file to a server's application directory?

I very often need to upload some kind of file to a server, to put some application directory somewhere. Since my user account is of course unprivileged, I generally have to do this: scp file.txt ...
4
votes
3answers
66 views

What is a good strategy to generate and copy files atomically

I have a file myfile that must be re-generated periodically. Re-generation takes some seconds. On the other hand, I have to periodically read the last (or next to last) file generated. What is the ...
1
vote
1answer
32 views

Log new files in a directory

Is there a tool, which lets me know about the last newly created files? The still common way of using a hierarchically file system makes it hard to save files in different places, so sometimes I sort ...
3
votes
1answer
91 views

Run Script at fail login attempt?

Lately, I've been trying to create a Bash script to capture a webcam photo when a fail attempt to login is registered. First of all, I found 2 guides related to this (links at the end), they explained ...
0
votes
0answers
49 views

get time of file in inotifywait tool

for this script: inotifywait -m /path -e create -e moved_to | while read path action file; do echo "The file '$file' appeared in directory '$path' via '$action'" # do something with the ...
1
vote
1answer
52 views

TCL script try catch

I have a TCL script that sets a number of variables and reads several files. The last file it reads may contain sensitive information, so I need to make sure this file gets deleted even if an error ...
1
vote
1answer
35 views

How does ACL calculate the effective permissions on a file?

I ran the following command to give the wheel group rwx permissions on new files and subdirectories created: [belmin@server1]$ ls -la total 24 drwxr-sr-x+ 2 guards guards 4096 Aug 27 15:30 . ...
3
votes
2answers
54 views

How often is the /etc/shadow file backed up?

From man 5 shadow: /etc/shadow- Backup file for /etc/shadow. Note that this file is used by the tools of the shadow toolsuite, but not by all user and password management tools. What I ...
2
votes
2answers
113 views

find file, copy but with different name

I have files with random numbers in /home/user/files folder (every 4 days I have new ones). for example: john20 john25 john40 tom12 tom32 simon2 simon8 simon53 I want to take only last modified ...
3
votes
4answers
131 views

Convenient way to name files in Linux

I'm a beginner in Linux and want to learn to do things properly in this environment. Since the beginning I've noticed that a lot of people involved in Linux (like tutorials and guides) tend to name ...
0
votes
0answers
45 views

How to remove files except a list with names files [duplicate]

I need delete some .desktop files in various directories and a text file with a list of file names. I want to delete all these .desktop files except for those listed in my text file). Example $ ls ...
2
votes
0answers
63 views

Show the time as well as the date that a file was modified? [closed]

How can I allow the file browser, in Ubuntu 14.04, to show the time as well as the date that a file was modified? For example, the image shows the day the files were Modified...but I cannot find an ...
-1
votes
1answer
48 views

Why doesn't rsync take advantage of the mv command when --remove-source-files is specified?

Assume I want to move a tree in the filesystem, e.g. /path/to/a a.txt b.txt to another location with rsync (3.0.9 protocol version 30), e.g. with rsync -a --remove-source-files /path/to/a/ ...
2
votes
2answers
56 views

How do you get a count of all file extensions on a hard drive using the gnu+linux terminal?

On windows I have a program that can count all the files on a hard drive and the output shows a list of file extensions and a number (which showed how many files on the drive were for example are ...
0
votes
1answer
36 views

how to change where a symlink points [duplicate]

Can you tell me what is this in red marker area. ? and if want to change /media/files/tb-prod/files to some other path, then how it will be .. ?
0
votes
1answer
37 views

What dev folder allows you tell the OS to cache something?

Someone told me that there is a sub folder off of dev that basically allows you to tell the OS to keep the contents of that folder cached in RAM. So if I put some files & directories in ...
1
vote
2answers
58 views

How use minimum number of commands to copy all .txt files from all subdirectories to one directory?

I have more than 90 subdirectories and inside each one, there will be a number of .txt files. What I need to do is to copy all those txt files out to one single directory. How can I do that?
2
votes
2answers
57 views

Is reading a file on UNIX faster than writing a file?

Sorry for the sheer simplicity of this question. A rather obtuse performance bottleneck has boiled down to this very small query. I have done some empirical analysis and I think I might be getting ...
3
votes
5answers
182 views

efficient cross-os file size shell function

I'm looking for a simpler way to have a cross-os-unix file size check. I could use wc -c but I'm concerned the performance may suck on large files (I'm assuming it just counts chars and doesn't do a ...
3
votes
1answer
173 views

“tail -f” show old file after file has been rotated [duplicate]

I have a script running continuously, reading tail -f /var/log/daemon.log The problem is, when the file /var/log/daemon.log gets rotated by logrotate, tail still has "file handle" for the old ...
0
votes
1answer
49 views

File not found: Beautiful Soup

I am trying to run a program that I downloaded in Ubuntu latest version, but I continue getting an error everytime I try to run the program. It says: File Not Found: BeautifulSoup So in order to ...
18
votes
5answers
1k views

Is there a way to tell sudo to set my username as owner for the files created instead of root?

If I do a sudo cp /etc/foo.txt ~/foo.txt, the new file is created with root as the owner. Right now, I see no way around this other than using the last two commands (ls to clarify use-case): ...
3
votes
4answers
111 views

How to remove text matching specific patterns from a file

I want to compare two files to check for differences between them, fileA and fileB. fileA is like a template file and fileB is the file which I want to compare to it. Anytime I find a difference I ...
3
votes
1answer
52 views

Recover atime after vim

I've vimed a file, and only afterwards realised that I need the atime (last access time) for the file. Is there any way to recover the atime for a file after accessing it inadvertently? The ...
0
votes
2answers
44 views

execute command from txt file

I have file and in this file i have this lines: ssh root@server1.com ssh root@server2.com etc.... And i have script that i like to go on every server and execute the ls command on each of this ...
4
votes
2answers
112 views

Why does 'find -delete ' delete all files in a directory recursively

So the following behaviour of unix find just cost me dearly: > touch foo > touch bar > ls bar foo > find . -name '*oo' -delete > ls bar > touch baz > ls bar baz > find . ...
1
vote
2answers
34 views

Remove all files without a keyword in the filename

I have a list of files in the following fashion: > file1.jpg > file1_orig.jpg > file2.jpg > file2_orig.jpg I want to keep all the files with the extension _orig.jpg and discard those ...
2
votes
3answers
57 views

What is the system-level effect of file permissions? [closed]

I know that r means read permission, w means write permission, and x means execute permission in the output of ls -l, like -rwxr-xr-x. But My question is what is behavior difference on operation ...
5
votes
1answer
1k views

How can two files in one of my folders have the same name?

I downloaded two files, they were both saved to the same filename and then I transferred them with scp to another computer. Why didn't they become one when the second was saved?
2
votes
1answer
32 views

How do I search files without certain extensions in their names?

I would like to search recursively in all the files and directories under a directory for some strings e.g. library. I also would like to exclude files and directories which store downloaded ...
3
votes
1answer
40 views

Methods to find out which (configuration) files are read by executable when started

What are the clever ways to find out which (configuration) files are read by executable if started? For example snmpd or sshd. One option is probably to check the CONFIGURATION FILES or FILES section ...
1
vote
3answers
126 views

Joining files on disk

Say I have several file with the following naming: 000001 000002 000003 ... Each of these files is a csv file (may include escape characters). In total the folder has ~20GB of data. How can I ...
0
votes
5answers
410 views

Move files to multiple folders [closed]

I've searched for this function, and there are lots of answers, but I haven't been able to find anything that works for me. I have a folder with about 30,000 files, and I want a terminal command or ...
-1
votes
3answers
41 views

Split a file into multiple based on selected lines [duplicate]

I have a file in which more than 50,000 lines are there. How can I split the file into two or more based on the selected lines? Suppose I want to split a file from line 10,000 to line 40,000.
0
votes
1answer
267 views

Accessing file from the Windows host in a VirtualBox virtual machine

I am running Ubuntu 14.04 as the guest operating system in a VirtualBox virtual machine. The host runs Windows 8 (24GB). I want to access a folder of the host inside the guest. Since the source is ...
3
votes
2answers
205 views

Deleted /tmp accidently

Accidently, I ran sudo rm -r /tmp, is that a problem ? I recreated it using sudo mkdir /tmp, does that fix the problem ? After I recreated the directory, In the places section in the sidebar in ...
2
votes
4answers
162 views

print capital words in first column of file

I want my output : VDD. GND AGNDSUB VMEASPOS. VMEASNEG VREFEXT File1 having following information : Power and signal VDD Digital Power This pin provides power supply connection for the digital ...
3
votes
2answers
85 views

Cannot delete File on Fedora

I have a file with following permission: -rwSr-s---. 1 1634630331 1818884080 118784 Jun 29 1970 DailyUpdateClass.class If I try to delete this file with root login, I get error. rm: cannot remove ...
1
vote
3answers
111 views

merging all files into one file?

I was trying to merge all the text files in to one file. All the text files has one column and equal number of rows. My data file names are data_1.txt, data_2.txt, data_3.txt, . . . data_n.txt. ...
1
vote
3answers
104 views

Unable to delete files as a root user using RS232 serial cross cable

I have a device(CCTV decoder) which was rebooting itself, so cant login using LAN cable. It has RS232 port only, no VGA and keybord/USB port(Embeded PC). I connected RS232 cross cable and used ...
4
votes
2answers
203 views

Convert file with integers written in ascii to binary file of integers

I have a file that contains a long list of integers written in ascii separated with newlines, like such: -175 2 -19345 345592 -45 2355 etc... I want to convert this file into a "binary" file ...
28
votes
6answers
2k views

How does Linux choose which application to open a file?

If a file tells the OS its file format, how does the OS choose which application to open it by default? In Windows, is the association stored in the registry table? How does Linux choose which ...
1
vote
1answer
74 views

Replace a string in a file and overwrite the file

I wrote my script using the the directory ~/deleted (it's a long script). after using ~/deleted for the whole script. I want to let the user choose the directory by putting the path in ~/.rm.cfg. My ...
0
votes
0answers
36 views

What are some preferred methods to efficiently edit files on a remote Unix server?

I'm looking for a more efficient GUI-based solution to edit root-owned and root-only writable files than using either nano or vim, both of which of course limit your cursor to navigate one character ...
2
votes
1answer
103 views

Compare file size of multiple files in an array [closed]

Scenario: Ftp site has 100s of files. Once a day, all the .gz files are copied to an AWS site then renamed. Only the date is kept in the file name. Some of the files corrupted during copy. A txt ...