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.

Linux Ask!

Jan 042010
 

How to safety delete a file in Linux?

Answer:

Sometimes, you might have a very sensitive file that don't want others to recover, you might want to use the following command

shred -u password.txt

The command will overwrite the password.txt repeatedly, in order to make it harder for data recovery, and finally delete it.

Jan 042010
 

How to check which directory used up most of the disk space?

Answer:

For example, assume you are at /usr/local, you want to generate a report on disk space usage on all the sub directories, you can use the following command

# du -k * | sort -n

.
.
14564   share/man/man3
14816   share/man
16624   share/perl/5.10.0
16628   share/perl
33060   share

It will give you a very clear and useful report.

Jan 042010
 

Permission denied when redirection with sudo

Answer:

When you are doing redirection with sudo, such as the following command

# sudo echo 1 > /proc/sys/vm/drop_caches

-bash: /proc/sys/vm/drop_caches: Permission denied

You will get permission denied as the redirection will be performed as the user calling sudo, not as the superuser. So if you don't have permission to write to the target file, you will get permission denied.

To solve the problem, use the following method

sudo sh -c 'echo 1 > /proc/sys/vm/drop_caches'