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.

Jan 072010
 

Disable IPv6 in Linux

Answer:

To disable IPv6 during boot time.

1. edit /boot/grub/menu.lst

# sudo vi /boot/grub/menu.lst

2. append the following line at the end of your targeted kernel, save the file.

ipv6.disable=1

3. Restart your system and verify to see it is now disabled (The following command should return nothing)

# ip a | grep inet6

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
 

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'

Dec 312009
 

Run tasks in parallel with xargs

Answer:

xargs provided a very simple to parallel tasks, e.g. setting P=3 means run 3 processes in parallel

seq 1 10 | xargs -n 1 -P 3 echo

Result:

1
2
3
4
5
7
6
9
8
10

Try to run the command several times, you might notice that number's order might be changed.

Why? Since they are running in parallel and some numbers finished first and some later!