Thursday, January 17, 2013

Linux Tricks

Here are some of the tricks, i'll keep it updating as i'll get something new.

Cheers :)

1. use "ftp 0" or "ssh 0" command instead of typing "ftp" or "ssh localhost" or "ftp localhost" for quickly testing newly configured ftpd or sshd service.

2. See memory and rss usage on your system:
#watch ps -A --sort -rss -o pid,comm,pmem,rss

3. Sample random password generator (put in your ~/.bashrc):

genpasswd() {
 local l=$1
        [ "$l" == "" ] && l=20
       tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs

Run it:
genpasswd 16


4. You can configure any Linux system to automatically log users out after a period of inactivity. Simply login as the root user and create a file called /etc/profile.d/,

# vi /etc/profile.d/

Append the following code:
readonly TMOUT
export TMOUT

Save and close the file. Set permissions:
# chmod +x /etc/profile.d/

5. How do I Find Out If Program Is Compiled With TCP Wrappers Or Not?

To determine whether a given executable daemon /path/to/daemon supports TCP Wrapper, check the man page, or ennter:

# ldd /path/to/daemon | grep

If this command returns any output, then the daemon probably supports TCP Wrapper. In this example, find out of if sshd supports tcp wrappers on not, enter:

# whereis sshd
Sample Output:

sshd: /usr/sbin/sshd /usr/share/man/man8/sshd.8.gz

# ldd /usr/sbin/sshd | grep
Sample Output: => /usr/lib/ (0x0051c000)

ldd is used to see if is a dependency or not. An alternative to TCP Wrapper support is packet filtering using iptables.

No comments:

Post a Comment