Archive for shell

How to Remove “Recent Item” @ Gnome-Shell?

  • rm -fr ~/.local/share/recently-used.xbel
  • touch ~/.local/share/recently-used.xbel
  • chmod ugo-wr ~/.local/share/recently-used.xbel
  • sudo chattr +i ~/.local/share/recently-used.xbel

Option 2

  • rm -fr ~/.local/share/recently-used.xbel
  • mkdir ~/.local/share/recently-used.xbel

Comments off

Linux Command Test to New Hire @ Company :)

I was asked by my manager & team to compose a tiny test of Linux command line for new hire @ development. Share it here:

  1. ssh -X: what does “-X” mean?
    Answer: enable X-window forward over SSH on port 22
  2. What is “authorized_keys2“? What does 2 mean”? Where is it supposed to stay?
    Answer: enable passwordless login in SSH2 protocol in ~/.ssh/
  3. What is “createrepo Server
    Answer: to create a YUM repository in directory of “Server”
  4. How can I know detailed launched kernel in Unix?
    Answer: uname -a
  5. How can I know whether KVM package installed in Redhat and Ubuntu?
    Answer: rpm -qa | grep -i kvm and dpkg -l | grep -i kvm
  6. What does “lvcreate -L5G -n redhat VolGroup00” mean?
    Answer: to create/ new a logical volume (lv) in 5G size, named “redhat”, on top of volume group (vg) named “VolGroup00″.
  7. What does “set -o vi” mean? Where could it be run?
    Answer: to set vi editing mode in shell. Either in a BaSH shell or put it in bottom of /etc/bashrc for login shell
  8. What difference between “rpm -Uvh PACKAGE_NAME” and “yum install PACKAGE_NAME
    Answer: rpm one = install specific & particular rpm package named PACKAGE_NAME. yum install = install rpm package named PACAGE_NAME, and with associating dependent package(s) from repo.
  9. What is “yum install kvm libvirt virt-manager“? What purpose of such command?
    Answer: to install kvm libvirt virt-manager packages. To install/ enable Kernel- based Virtual Machine in Linux
  10. What does “gpg –output doc.gpg –encrypt –recipient blake@domain.org doc” mean?
    Answer: to encrypt “doc” file, by using public key of blake@domain.org, then output result into doc.gpg
  11. What is “iptables -L -n -v?
    Answer: to list (-L) firewall rules in selected chaim in iptables. -n = in numberic, -v = verbose
  12. How can I check default installed java info?
    Answer: java -fullversion
  13. How can I know default java home setting?
    Answer: echo $JAVA_HOME
  14. What is result of “lslpp -l bos.rte.libc” on AIX?
    Answer: rte = runtime environment. To tell runtime libc version, aka AIX version.
  15. What does “chkconfig xinetd off” mean?
    Answer: to disable xinetd daemon from all runlevels.
  16. What is “sysctl -w net.ipv4.ip_forward =’1′“?
    Answer: turn on IP_forward in system control. Take effective immediately without reboot.
  17. What is “tcpdump -i eth1 ‘proto UDP and (port not 53)’“?
    Answer: to capture all UDP traffic packet, but besides on port 53, in tcpdump.
  18. Describe the following block in httpd.conf?
    <virtualhost *:80>
    ServerName
    smallblue4.watson.ibm.com
    Redirect / http://spirit125.watson.ibm.com/smallblue
    </virtualhost>
    Answer: redirect all http traffic hitting smallblue4.watson.ibm.com over port 80 to spirit123.watson.ibm.com/smallblue
  19. What is “echo 0 > /selinux/enforce“?
    Answer: temporarily disable Security Enhancement Linux
  20. What is “/etc/init.d/iptables status“?
    Answer: to check iptables (firewall) running status.

Comments off

What does the string @ site subject mean?

91d437f0fb56cfb5b64de81b60bd6738 ->

$ echo “a man on linux” | openssl dgst

or

$ echo “a man on linux” | md5sum

Comments off

Disable Update Manager Auto-launch in Ubuntu

Disable in gconf-editor

auto_launch

Or in command line:

To disable >
gconftool -s --type bool /apps/update-notifier/auto_launch false

To enable >
gconftool -s --type bool /apps/update-notifier/auto_launch true

Comments off

Use tcpdump for traffic analysis

Source: http://blogs.techrepublic.com.com/…1

Author: Chad Perrin

The tcpdump tool is an old mainstay of network debugging and security monitoring, and security experts all over the world swear by its usefulness. It is a command line tool that eschews all the makeup and jewelry of other traffic analysis tools such as Ettercap and Wireshark, both of which provide packet sniffing functionality with a convenient captive interface. In contrast to such tools, tcpdump takes a command at the shell, with options specified at that time, and dumps the results to standard output. This may seem primitive to some users, but it provides power and flexibility that isn’t available with the common captive interface alternatives.

Options

The tcpdump utility provides dozens of options, but I’ll just cover a few of them here:

  • -A: Print each packet in ASCII.
  • -c N: Where the letter N is a number, this option tells tcpdump to exit after N packets.
  • -i interface: Capture packets on the specified network interface.
  • -n: Don’t resolve addresses to names.
  • -q: Provide less verbose (”quiet”) output so output lines are shorter.
  • -r filename: Read packets from the specified file rather than a network interface. This is usually used after raw packets have been logged to a file with the -w option.
  • -t: Don’t print a timestamp on each line of output.
  • -v: Provide more verbose output. Verbosity can be increased more with -vv, and even more than that with -vvv.
  • -w filename: Write raw packets to the specified file.

Expressions

The tcpdump utility also supports command-line expressions, used to define filtering rules so that you get exactly the traffic you want to see, ignoring “uninteresting” packets. Expressions consist of a number of primitives and, optionally, modifier terms. The following primitives and modifiers do not constitute a comprehensive list, but they are among the most commonly useful.

Primitives

  • dst foo: Specify an address or hostname to limit captured packets to traffic sent to a particular host.
  • host foo: Specify an address or hostname to limit captured packets to traffic to and from a particular host.
  • net foo: Specify a network or network segment using CIDR notation to limit packet capture.
  • proto foo: Specify a protocol to limit captured packets to network traffic using that protocol.
  • src foo: Specify an address or hostname to limit captured packets to traffic sent by a particular host.

Modifiers

  • and: Use this to chain together primitives when you want to limit captured packets to those that meet the requirements of the expressions on both sides of the and.
  • not: Use this modifier just before a primitive when you want to limit captured packets to those that do not meet the requirements of the following expresssion.
  • or: Use this to chain together primitives when you want to limit captured packets to those that meet the requirements of one or more of the expressions on either side of the or.

Examples

All of these options and expression primitives and modifiers, along with others listed in the tcpdump manpage, can be used to construct very specific commands that produce very precise output.

  • tcpdump -c 50 dst foo can give you information that may help identify the source of heavy incoming traffic targeting an overloaded server with hostname “foo”, dumping the first 50 packets as output.
  • tcpdump -c 500 -w `date +"%Y%j%T"`.log dumps 500 packets to a file named with a current time/date stamp (e.g. 200820715:16:31.log) so that they can later be filtered according to the information you want to see. I have the command date +"%Y %j%T" aliased to stamp in my shell’s rc file, so I can shorten a command like this to tcpdump -c 500 -w `stamp`.log, saving me from having to remember all the formatting options for the date command off the top of my head.
  • tcpdump proto ssh src or dst foo and src and dst not bar produces ongoing output that shows all SSH activity originating from or targeting host “foo” unless it is originating from or targeting host “bar”. If foo is only supposed to be accessed via SSH by bar, this command will allow ongoing monitoring of unauthorized SSH traffic to and from foo. You could even start a number of persistent monitoring processes with tcpdump like this within a tmux session on a dedicated monitoring server.

As you can no doubt see, tcpdump’s expressions capabilities are roughly equivalent to a simple domain specific programming language that is extremely easy to understand. With that kind of power and flexibility at my fingertips, there’s little need to use anything else for general traffic analysis tasks.

Comments off