Tag Info

Hot answers tagged

43

The correct syntax in bash is the following: rm /tmp/!(lost+found) As @goldilocks wrote in the comments, the original command makes an expansion on the query (it deletes all the files in the /tmp folder, then goes on, and deletes all the files in the current working folder, in your case the home folder). You can try to check if you can recover some of ...


26

The !(lost+found) in your rm command was probably the fatal mistake: 1978 rm -rf /tmp/* !(lost+found) 1979 sudo rm -rf /tmp/* !(lost+found) I don't know exactly bash is doing with that, but this command prints everything in my /tmp and also everything my current directory, which is currently ~: echo /tmp/* !(lost+found)


5

I think df . is your best bet. The filesystem usage check is not that expensive (it doesn't have to count any blocks on disk, that information is readily available and stored in memory once the filesystem is mounted). Alternatives like comparing the current path against mount points by using a script would be more expensive.


3

You can optimize the directory using fsck.ext4 -D on an unmounted filesystem: -D Optimize directories in filesystem. This option causes e2fsck to try to optimize all directories, either by reindexing them if the filesystem supports directory indexing, or by sorting and compressing directories for smaller ...


2

You should never ever modify a file in place. The only safe ways to write a file are: if you are the first one to create the file (O_EXCL). by writing to a new temporary file and then performing an (atomic) rename(2). by opening the file in append-only mode (O_APPEND). Otherwise, you will lose data all the time, either when your program crashes (don't ...


2

If you are looking for directories that are using up space, and are not on a different partition, then you want du -hx --max-depth=1 /. The -x tells it not to descend into directories that are on other filesystems ( partitions ). The --max-depth=1 asks to only print a line ( listing the total space for that directory and all subdirectories ) for each ...


2

I am not aware of any good way to do this. The technically cleanest way would be a FUSE file system which does that. Of course, a lot of work if nobody has done that yet. Alternatives: Use samba. samba has the force user parameter. You can export a directory locally and mount it locally. Doesn't make accesses faster but may be acceptable as only loop back ...


2

Your question suggests that Debian uses temp files for all writes, which isn't the case. This is simply the default for mp3gain. In version 1.4.3-2, the package maintainer (Stefan Fritsch) decided that as writing to a temp file is much quicker on ReiserFS, then this would be the default on Debian. This was sourced from the patch at ...


1

fuse-zip is an option and claims to be faster than the competition. # fuser-zip -r archivetest.zip /mnt archivemount is another: # archivemount -o readonly archivetest.zip /mnt Both will probably need to open the whole archive, therefore won't be particularly quick. Have you considered extracting the ZIP to a HDD or USB-stick beforehand and simply ...


1

You can use fuse-zip to mount zip as read only. 1 -- Install fuse-zip on your system. UBUNTU sudo apt-get install fuse-zip CENTOS/REDHAT/FEDORA yum install fuse-zip 2 -- Run below command to mount zip as read only. fuse-zip -o ro /path/abcd.zip /path/to/mount/directory 3 -- Use below command to unmount directory fusermount -u ...


1

Changing a file in place is not always that easy. If you add date in the middle of a file, the size will grow and any data after the change has to be written to a new location. If you first write the data in the middle of the file, you have to store the old data in order to move it, and hope not to crash in the middle of that process. It is much easier to ...


1

If I am reading this question correctly, there is a program called tree. This would list all directories in a tree like structure. With it installed, you can do something like: tree -x Where -x Stay on the current file-system only. Ala find -xdev. UPDATE: I have tried tree -P /dev/xvda and it seemed to have shown directories under that filesystem. The -P ...


1

You should look at the output of dmesg and at the /var/log/syslog to see when this switch is happening and what messages preced it. I have seen this happen with drives that had intermittent access problems, particularly with USB drives that had bad connectors/cables.


1

Sir I33tname gave you the answer. However you should be running separate cron job that checks for nearly full disks. This is an idea how to do that, NOT necessarily a perfect solution for your situation Use cronjob -e to add this (example change names of directories and files): 0,10,20,30,40,50 * * * * /path/to/my/script.sh 2>>/path/to/logfile script.sh ...


1

Setting a default owner "automatically" would require a directory setuid behaving like setgid. However, while this can be configured on FreeBSD, other UNIX & Linux systems just ignore u+s. In your case however, there might be another solution. What I want is to have a directory that can be shared by adding a group to a user. Anything created in this ...


1

There is a smarter way to do this. It uses a combination of set-gid and default acls. Obviously, you will need an acl enabled file system. Let's assume the directory you want shared is at /var/grpdir and that members of group sharing should be able to access it. chown root:sharing /var/grpdir chmod 2770 /var/grpdir #other can't read or traverse into the ...


1

The symptoms are very consistent with a mostly saturated IO system, however having for the most part ruled out IO load from the OS/userspace side, another possibility is the drive running self-tests on itself, which may include reading from all the sectors. This should be queryable/tunable from smartctl (At least one place being smartctl -c for querying). ...


1

Not sure what you mean by "what filesystem". If it means what instance of a filesystem, then using df $(pwd) may be your best bet, except when you know that the file you are inspecting actually is a mountpoint on its own, than using mountpoint $(pwd) may be a better idea. If it means what type of filesystem, then use the common Linux utility stat, it only ...


1

Problem solved. I had to run resize_reiserfs /dev/sda4


1

cat /proc/mounts|sort|awk '{print $1 "\011" toupper(substr($4,0,2))}' Produces tab delimited output with mount name and mode.



Only top voted, non community-wiki answers of a minimum length are eligible