Skip to content

SSHMenu: SSH connections manager for GNOME

SSHMenu: SSH connections manager for GNOME

Answer:

SSHMenu is a GNOME panel applet* that keeps all your regular SSH connections within a single mouse click.

Highly recommended if you need to manage a lot of SSH sessions.

Official homepage: http://sshmenu.sourceforge.net/

Generate dummy file in Linux

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).

Disable reply to ping

Disable reply to ping

Answer:

To stop other machine from pinging your machine, you the following command

# sysctl -w net.ipv4.icmp_echo_ignore_all=1

To turn it on again:

# sysctl -w net.ipv4.icmp_echo_ignore_all=0

How to check if a file is locked in Linux?

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

How to perform syntax check for Python program

How to perform syntax check for Python program

Answer:

Assume you have a simple Python script hello.py, you want to perform syntax check. You can use the following method

# python -c 'import hello'

Traceback (most recent call last):
  File "", line 1, in 
  File "hello.py", line 1
    echo "Hello, World!"

If there is any syntax error, it will prompt out to the screen.