Tagged Questions

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

learn more… | top users | synonyms (1)

0
votes
1answer
32 views

Why the size of an empty directory in Linux is 4KB? [duplicate]

I'm using Ubuntu 14.04 and I made an empty directory on /tmp with the mkdir command: cd /tmp mkdir foo and then I checked it's size using ls: ls -ldh foo and the result shows that the size of ...
1
vote
0answers
25 views

open() sys call [on hold]

Process A wants to open a file fd1 = open("/var/file1", O_RDONLY); In the process of opening file1 which table is referred first system wide file table or file descriptor table or in-core inode ...
3
votes
3answers
26 views

Add text with echo but start with new line if file not empty

I'm trying to create next script echo "#!/bin/sh" >/script echo "del x.txt" >>/script witch is ok if /script file is empty, if not - will append first line to last text #!/bin/sh del ...
1
vote
3answers
61 views

How to use all the inodes

Without creating a file can I use any inode which is free? I want to write a script that will use all free inodes in the system. is it possible?
1
vote
3answers
47 views

Find and delete duplicate txt files

I have a folder with around 300 text files, is there any command that reads every every file indivdually and deletes the duplicate files? I mean the content and not the file names.
0
votes
0answers
20 views

Change encoding of a text file in-place: iconv alternative? [duplicate]

Apparently, iconv is unable to use the same file as input and output file. Other tools, e.g. sed, have an -i switch that allows "updating" a file in-place. (Under the hood, temporary files are ...
2
votes
1answer
53 views

How do I choose a file names with consecutive numeric suffixes?

I like to preserve things, so I want to preserve .bash_history. I would like to copy it into a directory using a script. Like here #!/bin/bash #Something here? number=~/Desktop/Coding/Bash\ ...
2
votes
1answer
41 views

Add content one file to another

FILE1=$1 FILE2=$2 if [ ! -e "$FILE2" ] then touch $FILE2 fi while read line; do if grep -q "$line" $FILE2 then echo else echo $line >> $FILE2 fi done < $FILE1 I want ...
4
votes
1answer
53 views

Why doesn't inotifywatch detect changes on added files?

I'm trying to monitor my /tmp folder for changes using inotifywatch: sudo inotifywatch -v -r /tmp After creating couple of files (touch /tmp/test-1 /tmp/test-2), I'm terminating inotifywatch (by ...
1
vote
3answers
44 views

How to access temporary file straight after creation?

I've script which is connecting to remote host via SSH, creates temporary file and executing the following command: Calling system(mysql --database=information_schema --host=localhost < ...
1
vote
1answer
9 views

What files does affect apt-get purge¿?

I want to know before doing apt-get purge <packet> what files thats gonna have effect on. The reverse thing would be, what packet do I have to do purge if I want to remove that file (apt-file ...
1
vote
4answers
35 views

How to do grep even if the file is not present?

I am doing something like this in my code file_nm=`ls -latr *abc*` if [ `grep "search_txt" "$file_nm" | wc -l` -gt 0 ] then echo "string found" else echo "string not found" fi If the file_nm is ...
1
vote
1answer
51 views

How to output the directory structure to Json format [duplicate]

I have been using 'find' to output the directory structure from the root down and I don’t mind that it takes a while. My problem is that I want to cut down on the redundant info of repeating every ...
2
votes
1answer
41 views

In a Virtualbox VM how do I set the filesystem permissions?

I have a virtualbox VM with arch Linux running on my windows PC (which I unfortunately have to use for work). I use this to work on my windows PC with a Linux environment as an alternative to Cygwin. ...
21
votes
2answers
946 views

Is it safe to move a file that's being appended to?

I have a node.js process that uses fs.appendFile to add lines to file.log. Only complete lines of about 40 chars per lines are appended, e.g. calls are like fs.appendFile("start-end"), not 2 calls ...
4
votes
1answer
47 views

How to make sure only one instance accessing the file at a time in a folder?

I have a shell script which will be executed by multiple instances and if an instance accessing a file and doing some operation how can I make sure other instances are not accessing the same file and ...
0
votes
2answers
39 views

How to disallow file modification time change for non root users

I don't want anybody to create a file then change the creation date to backward date(For example using touch or system call). In my Ubuntu hosting account I'm getting many hacked php code getting ...
6
votes
2answers
351 views

Finding a file type assuming wrong extension

I have an image archive I keep up. Sometimes, the sites I pull them from reformat the file while keeping the extension the same, most often making PNG images into JPG's that are still named ".png". ...
1
vote
0answers
50 views

File of Doom freezes any computer that attempts interaction

I have a file on an internal server that causes any machine that interacts with it to immediately and irrecoverably freeze. By interaction, I mean just about anything: rm, mv, cp, cat, vi, gedit, ...
6
votes
3answers
269 views

Is it possible to create an edited copy of a file without using up extra disk space?

If I have a large file, I can use ln to make make "copies" of it that don't use up extra disk space. But what if I don't want an exact copy of the file? Is there a way to create a new version of a ...
2
votes
3answers
85 views

print the /etc/shadow file in the console

How do I change the permissions of an executable file to access the /etc/shadow file? So far I have the following bash script: #!/bin/bash gcc print.c -o print chmod +s print ./print exit 0 and ...
2
votes
1answer
24 views

Which types of files can have a shared library dependency?

I'm trying to find a way to let the find command only find files, that could possibly have a shared library dependency (meaning they produce output when called with ldd). To find all dependencies of ...
2
votes
3answers
85 views

How to remove file with mv command?

I started to study Solaris in my university. Teacher told me to remove a file with mv command. I tried to move a file to /dev/null. But that did not work. How can I remove file with mv command?
0
votes
1answer
31 views

Is it possible to access these directories?

I'm trying to recover data from my Ready NasDuo which is Spark based with a 16kb block size. I've followed another post and successfully mounted the drive using a command like sudo fuseext2 -o ...
1
vote
0answers
24 views

Command that can find files that are not referenced by other files and then delete them

I was wondering if anyone knew how I could go about writing a grep command that recursively finds files that are not being referenced/used in a specific file and/or a directory of files, and then ...
3
votes
3answers
60 views

Sorting directories by last modified date/time of the same-named contained file

Is it possible, using grep, find, etc, to sort a list of directories by the last modified date of the same-named file (e.g., file.php) within? For example: domain1/file.php (last modified 20-Jan-2014 ...
1
vote
1answer
19 views

Hexdump binary file while honoring separators

I have a binary file where records are separated by newlines. hexdump just dumps everything with a fixed column width. Is there a tool to hexdump this file, while honoring the newline separator? (Any ...
0
votes
1answer
44 views

How to move a file to another directory, as soon as it is created, in linux? [duplicate]

I want to move all the *.xxx file created in a directory to another directory. But, I want that as soon as the files are created, they should move to another directory. Please Help. Thanks in advance. ...
3
votes
1answer
30 views

How to find the file corresponding to a pipe opened by a process? [duplicate]

I created this script, which listens for characters received on a hardcoded pipe, and tries to eval those characters. I call my script loop_executor.sh This is all it contains: !/bin/bash while : do ...
2
votes
1answer
41 views

How can I encrypt a file?

I would like to download some files from my server into my laptop, and the thing is that I want this communication to be as stealth and secure as it can be. So, far I came up using VPN, in that way I ...
0
votes
0answers
31 views

Delete a file in GSX Trade Guide [closed]

I have HP-UX System as a Backend and Trade guide from Gxs.com as Front end. I'm able to delete a .byp file in the back end. However deleted files are not reflected in the Front end Trade Guide. By ...
6
votes
2answers
997 views

What is the result of running `chmod 7` on a file?

I know chmod 777 allows read, write, and execute for user, group, and others but what if I just do chmod 7? Is that only rwx for the user?
0
votes
1answer
29 views

What has priority - owner/user vs group permission? [duplicate]

I have just run into the case in which the owner-group of a file has more permissions than the owner-user of a file. user1@pc:/tmp$ ls testfile -l ----rw---- 1 user1 user1 9 Okt 16 13:16 testfile ...
0
votes
1answer
21 views

file command to show “for GNU/LINUX 2.x.x” also for shared libraries

Using the command file my_executable_binary I get information like this: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.34, dynamically linked (uses shared libs), stripped ...
1
vote
0answers
17 views

Configuring group access across a LAN

I have created a group called engineers on two VMs on the same 192.168.56.0/24 LAN. Is there any way the members from VM1 in engineers can view files created by engineers from VM2? I was thinking of ...
1
vote
0answers
34 views

Can Linux be configured to wait for USB storage to be reattached instead of returning I/O error

If a usb_storage device is physically detached from an Ubuntu machine while it is still mounted, any attempt to access the file system will produce an I/O error. Is there some way to configure Linux ...
1
vote
1answer
26 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 ...
1
vote
1answer
48 views

Understanding grep and pipes in linux

I came across this post which explains my problem. Suppose there is a file called file.txt which contains "foo World". The answer posted by Tyler explains a lot however I am confused as to how cat ...
1
vote
1answer
78 views

Linux split separate files on disk but see as one

Is there is a functionality in Linux that allows you to reference multiple files as one? For example: linux.txt.0, linux.txt.1, linux.txt.2, linux.txt.3 can be seen as separate files or as linux.txt ...
5
votes
3answers
195 views

Is there any way to tell exactly what files a command is accessing?

I'm working on a piece of software that requires me to know what files and resources any certain launched process are accessing. I'm not planning on attempting to track what every single script, ...
3
votes
1answer
19 views

Check for missing files in two directories and their respective subdirectories

Folder alpha has one subfolder, and files in both root and in subfolder. Folder beta has 25 subfolders with files in them. How would I compare the file contents of alpha and beta, checking for ...
3
votes
2answers
50 views

ack/grep search and sort by modification date

Is there any way to have ack sort the results found by date of modification? (ideally showing the date next to the result?). It doesn't look like ack has a date option, but just in case. If this ...
0
votes
1answer
40 views

File tranfer from the server

I want move (not copy with scp) my file from the server to the local repository and finally delete it on the server after transfer. I use next command from the repository, where I want have the file: ...
5
votes
2answers
594 views

How do I delete all of a set of files in a random order?

I have a set of files, all that are named with the convention file_[number]_[abcd].bin (where [number] is a number in the range 0-size of drive in MB). i.e there is file_0_a.bin, file_0_b.bin, ...
1
vote
0answers
18 views

File path in audit log instead of inode number

When I do: echo "#TEST" >> /etc/passwd I get the following in audit logging: node=kayak.office.local type=SYSCALL msg=audit(1412687666.054:62033): arch=c000003e syscall=2 success=yes ...
3
votes
5answers
201 views

How to create a simple .txt (text) file using terminal? [closed]

I'm just trying to review basic terminal commands. Having said that, how do I create a text file using the terminal only?
1
vote
1answer
57 views

Open file over ssh in local X window [duplicate]

How can I open html file in local internet browser? I am connected under /ssh://user@server.... I'm thinking about something like firefox file_from_remote_server.
2
votes
1answer
69 views

How to let a user create a directory although not create a sub directory

I'm trying to create a Bash shell script that allows for the transfer of files from a flash device to a archive in which the user will specify. Although I'd like to restrict this user from not being ...
1
vote
0answers
25 views

Files associated with Thunderbird - Security mechanism for local storage

I am trying to know how Thunderbird stores the mails, associated files in the local machine. I use Ubuntu 13.10 and Thunderbird 24.6.0. When I see in the local profile folder in the location in ...
8
votes
2answers
501 views

How to non-invasively test for write access to a file?

In a shell script, how do I easily and non-invasively test for write access to a file without actually attempting to modify the file? I could parse the output of stat, but that seems really complex, ...