Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

What filesystem(s) my Linux supports?

Answer:

E.g. To see what ext filesystems it support, use

# cat /proc/filesystems  | grep ext
        ext3
        ext2
        ext4

Kill all processes accessing the a particular file/folder

Answer:

To kill all processes accessing the a particular file/folder, you can use the follow command:

# /sbin/fuser -k /data/backup

It is very useful when you want to unmount a filesystem but Linux reported the device is busy.

How to convert ext2 partition to ext3?

Answer:

Firstly, you need to create a journal on it. This can be done either the file system is mounted or unmounted.

# tune2fs -j /dev/hdaX

Then, mount the filesystem as ext3

# mount -t ext3 /dev/hdaX /mnt/somewhere

Reference: http://batleth.sapienti-sat.org/projects/FAQs/ext3-faq.html

Generate dummy file in Linux

Answer:

To generate random files of fixed size (e.g. 1GB) in Linux:

dd if=/dev/zero of=test.bin bs=1000000000 count=1

You can adjust the file size by setting the bs parameter (byte size).

How to check if a file is locked in Linux?

Answer:

Suppose a file test.txt is being locked by a program, e.g. using the flock system call, how can we know if this file is really being locked?

# lsof test.txt
COMMAND  PID USER   FD   TYPE DEVICE SIZE   NODE NAME
perl    5654 john 3uW  REG    8,1    1 983057 test.txt

The W means the file is currently held by an exclusive lock. You can find more information in the link below:

http://linux.die.net/man/2/flock