Tuesday, October 7, 2014

How to Enable Local Menus in Ubuntu 14.04

00_lead_image_enable_local_menu

Ubuntu 14.04 has recently been released and they now include a setting for enabling the local menus, allowing you to easily move the menu bar for each program to that program’s window rather than displaying the menu bar at the top of the screen.

We recently showed you how to disable the Global menu in Ubuntu 13.10. Now that Ubuntu 14.04 has a setting to do this, we will show you how to change this setting.

To enable the local menus, click the System Settings icon on the Unity bar.

01_clicking_system_settings

On the System Settings dialog box, click the Appearance icon in the Personal section.

02_clicking_appearance

On the Appearance screen, click the Behavior tab. Under Show the menus for a window, click the In the window’s title bar option.

03_in_the_windows_title_bar

Click the X button in the upper-left corner to close the Settings dialog box.

04_closing_system_settings

The change is effective immediately. You do not need to log out or restart. The menu bar for each program is moved to the title bar of the respective program.

05_local_menu_in_program

If you decide you want the Global menu back, simply change the setting to the In the menu bar option.

Note that, because the menu bar is on the title bar of each program, the menus disappear when the mouse is not on the title bar. Simply move the mouse over the title bar to access the menus.

source : http://www.howtogeek.com

How to Add a Taskbar to the Desktop in Ubuntu 14.04

00_lead_image_taskbar

If you’ve switched to Ubuntu from Windows, it may take some time to get used to the new and different interface. However, you can easily incorporate a familiar Windows feature, the Taskbar, into Ubuntu to make the transition easier.

A tool called Tint2 provides a bar at the bottom of the Ubuntu Desktop that resembles the Windows Taskbar. We will show you how to install it and make it start every time you log into Ubuntu.
NOTE: When we say to type something in this article and there are quotes around the text, DO NOT type the quotes, unless we specify otherwise.

Press Ctrl + Alt + T to open a Terminal window. To install Tint2, type the following line at the prompt and press Enter.
sudo apt-get install tint2
Type your password at the prompt and press Enter.

01_entering_installation_command

The progress of the installation displays and then a message displays saying how much disk space will be used. When asked if you want to continue, type a “y” and press Enter.

02_do_you_want_to_continue

When the installation has finished, close the Terminal window by typing “exit” at the prompt and pressing Enter.

03_closing_terminal_window

Click the Search button at the top of the Unity bar.

04_clicking_search_icon

Start typing “startup applications” in the Search box. Items that match what you type start displaying below the Search box. When the Startup Applications tool displays, click the icon to open it.

05_opening_startup_apps

On the Startup Applications Preferences window, click Add.

06_clicking_add

On the Add Startup Program dialog box, enter a name for the startup application. This name displays in the list on the Startup Applications Preferences window.

Type “tint2” in the Command edit box, enter a description in the Comment edit box, if desired, and click Add.

07_entering_startup_app_info

Tint2 is added as a startup program and will start every time you log into Ubuntu. Click Close to close the Startup Applications Preferences window.

08_closing_startup_prefs_window

Log out and log back in to make the Taskbar available on the desktop. You do not need to reboot the computer for this change to take effect.

Now, when you minimize a program, an icon for it displays on the Taskbar at the bottom of the screen, just like the Taskbar in Windows.

09_taskbar

If you decide that you don’t want the Taskbar to display every time you log into Ubuntu, you can uncheck the Tint2 startup program on the Startup Applications Preferences window. You don’t need to delete it from the list.

source : http://www.howtogeek.com

How to Enable and Tweak Ubuntu’s Flashy Graphical Effects

ubuntu-desktop-cube

Once upon a time, Linux desktops were full of wobbly windows, desktop cubes, and other over-the-top graphical effects. Ubuntu still includes the Compiz software that makes this possible, but it’s been toned down by default.

Ubuntu includes some basic graphical effects on its desktop, but provides no built-in option for enabling and tweaking more effects. All you need is a third-party tool to unlock the advanced features in Compiz.

This guide was written for Ubuntu 13.04, the latest version of Ubuntu at the time. Some of the steps or commands may be a bit different on other versions of Ubuntu.

Installing CCSM & More Plugins

To configure Compiz, we’ll need the CompizConfig Settings Manager, or CCSM. You’ll probably also want to install additional plug-ins for Compiz so you have more advanced effects to play with.
To install CCSM and the extra plug-ins, just open a Terminal window — you’ll find the Terminal application in Ubuntu’s Dash — and run the following commands:
sudo apt-get install compizconfig-settings-manager compiz-plugins-extra
Enter your password, type Y when prompted to confirm, and Ubuntu will automatically download and install the appropriate software.

install-ccsm-on-ubuntu-13.04

Using CCSM

You can now open the CompizConfig Settings Manager application and use it to configure Compiz. Just open the dash and search for CCSM or Compiz to find and launch it.

CCSM warns us that it’s an advanced tool that we could use to break our Compiz configuration. If you do manage to break your Compiz desktop, you can fix it by resetting it to its default values — we’ll cover that later.

CCSM provides a long list of different plug-ins. You should leave “system” plug-ins like “Gnome compatibility,” “Copy to texture,” and “PNG” alone. The most interesting plug-ins for configuring desktop bling are found under the Desktop and Effects categories.

compizconfig-settings-manager

To enable a plug-in, just click the check-box to the left of it. To configure an enabled plug-in, click its name. Different plug-ins have a wide variety of different options — everything from different animations to customizable speeds and hotkeys, depending on the plug-in.

Enabling Wobbly Windows

Check the Wobbly Windows checkbox under Effects and you’ll be prompted to disable the Snapping Windows plug-in.

enable-wobbly-windows-in-ubuntu

Enabling wobbly windows is that simple — your windows will now appear to wobble as you drag them, as if they were made of jello. It looks better animated.

ubuntu-wobbly-windows

If you wanted to configure this plug-in more, you could click the Wobbly Windows name and adjust a variety of settings, such as the key that makes windows snap to the edges of the screen when held — Shift by default — and even the friction value.

ubuntu-wobbly-windows-options

Using the Desktop Cube

The desktop cube requires Ubuntu’s workspaces to be enabled. First, open the Appearance tool from Ubuntu’s Dash and check the Enable Workspaces option.

enable-workspaces-on-ubuntu-13.04

To use the desktop cube, which uses an animated cube-rotation effect when you switch between virtual desktops, as if each of your virtual desktops is located on the side of a three-dimensional cube, enable the Rotate Cube checkbox. You’ll be prompted to enable the Desktop Cube plug-in and disable the Desktop Wall plug-in, which is used by default.

enable-desktop-cube-on-ubuntu

You’ll now need to click the General Options button in the General section.

ccsm-general-options

Click over to the Desktop Size tab, set Horizontal Virtual Size to 4, Vertical Virtual Size to 1, and Number of Desktops to 4.

ccsm-number-of-desktops

Your desktop cube should now be working. Use Ctrl+Alt+Left or Right to switch between cube faces, press Shift+Ctrl+Alt+Left or Right to move windows between cube faces, or hold down Ctrl+Alt and left-click drag to manually rotate around your cube.

ubuntu-desktop-cube[4]

Other Plugins

Some plugins are more practical than others. For example, the Water Effect plug-in allows you to hold Ctrl+Super (Super is the Windows key) and move your mouse to create a water-rippling effect that follows your mouse. It also allows you to press Shift+F9 to toggle a rain effect that makes your desktop appear as a pond rippling as raindrops fall on it.

compiz-water-effect

You’ll find many other plug-ins in CCSM for everything from adding enhanced zoom functions for accessibility to painting fire on your screen for no other reason than to show off. Feel free to explore the available plug-ins and options.

compiz-fire

Resetting Compiz to its Default Settings

When you’re done messing around — or if you managed to break something — you may want to go back to Ubuntu’s default Compiz settings.
To do so, press Ctrl+Alt+T to open a terminal window. This keyboard shortcut may even work if your desktop is somewhat broken.
Run the following command in the terminal window:
dconf reset -f /org/compiz/
reset-compiz-settings

Log out of your Ubuntu desktop, and then log back in — Compiz should be functioning just like it was after you installed Ubuntu.

source : http://www.howtogeek.com

Monday, January 27, 2014

Useful Unix File Find Commands


Following are some bunch of commands that might be useful if you want to find files in unix/linux.

Large Files

Find files larger than 10MB in the current directory downwards…
find . -size +10000000c -ls

Find files larger than 100MB…
find . -size +100000000c -ls

Old Files

Find files last modified over 30days ago
find . -type f -mtime 30 -ls

Find files last modified over 365days ago
find . -type f -mtime 365 -ls

Find files last accessed over 30days ago
find . -type f -atime 30 -ls

Find files last accessed over 365days ago
find . -type f -atime 365 -ls

Find Recently Updated Files

There have been instances where a runaway process is seemingly using up any and all space left on a partition. Finding the culprit file is always useful.
If the file is being updated at the current time then we can use find to find files modified in the last day.
find  . -type f -mtime -1 -ls

Better still, if we know a file is being written to now, we can touch a file and ask the find command to list any files updated after the timestamp of that file, which will logically then list the rogue file in question.

touch testfile
find .  -type f -newer testfile -ls

Finding tar Files

A clean up of redundant tar (backup) files, after completing a piece of work say, is sometimes forgotten. Conversely, if tar files are needed, they can be identified and duly compressed (using compress or gzip) if not already done so, to help save space. Either way, the following lists all tar files for review.
find . -type f -name "*.tar" -ls
find . -type f -name "*.tar.Z" -ls

Large Directories

List, in order, the largest sub-directories (units are in Kb)…
du -sk * | sort -n

Sometimes it is useful to then cd into that suspect directory and re-run the du command until the large files are found.

Removing Files using Find

The above find commands can be edited to remove the files found rather than list them. The “-ls” switch can be changed for “-exec rm {}\;”=.

find . -type f -mtime 365 -exec rm {} \;

Running the command with the “-ls” switch first, is always prudent to see what will be removed.

The “-ls” switch prints out summary information about the file (like owner and permissions). If just the filename is required then swap “-ls” switch for “-print”.

Find and Replacing words using Find

The below find command finds and replaces the word 'apple' with 'orange' in all the occurrences in each files in the test directory.

find ./test -exec sed -i 's/apple/orange/g' {} \;

Tuesday, January 21, 2014

Packet Analyzer - TCPDUMP Command Examples

tcpdump command is also called as packet analyzer.
tcpdump command will work on most flavors of unix operating system. tcpdump allows us to save the packets that are captured, so that we can use it for future analysis. The saved file can be viewed by the same tcpdump command. We can also use open source software like wireshark to read the tcpdump pcap files.
In this tcpdump tutorial, let us discuss some practical examples on how to use the tcpdump command.

1. Capture packets from a particular ethernet interface using tcpdump -i

When you execute tcpdump command without any option, it will capture all the packets flowing through all the interfaces. -i option with tcpdump command, allows you to filter on a particular ethernet interface.

$ tcpdump -i eth1
 
14:59:26.608728 IP xx.domain.netbcp.net.52497 > valh4.lell.net.ssh:
 . ack 540 win 16554
14:59:26.610602 IP resolver.lell.net.domain > valh4.lell.net.24151:
 4278 1/0/0 (73)
14:59:26.611262 IP valh4.lell.net.38527 > resolver.lell.net.domain:
 26364+ PTR? 244.207.104.10.in-addr.arpa. (45)

In this example, tcpdump captured all the packets flows in the interface eth1 and displays in the standard output.

Note: Editcap utility is used to select or remove specific packets from dump file and translate them into a given format.

2. Capture only N number of packets using tcpdump -c

When you execute tcpdump command it gives packets until you cancel the tcpdump command. Using -c option you can specify the number of packets to capture.
 
$ tcpdump -c 2 -i eth0 
 
listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
14:38:38.184913 IP valh4.lell.net.ssh > yy.domain.innetbcp.net.11006:
 P 1457255642:1457255758(116) ack 1561463966 win 63652
14:38:38.690919 IP valh4.lell.net.ssh > yy.domain.innetbcp.net.11006:
 P 116:232(116) ack 1 win 63652
2 packets captured
13 packets received by filter
0 packets dropped by kernel

The above tcpdump command captured only 2 packets from interface eth0.

Note: Mergecap and TShark: Mergecap is a packet dump combining tool, which will combine multiple dumps into a single dump file. Tshark is a powerful tool to capture network packets, which can be used to analyze the network traffic. It comes with wireshark network analyzer distribution.

3. Display Captured Packets in ASCII using tcpdump -A

The following tcpdump syntax prints the packet in ASCII.
 
$ tcpdump -A -i eth0 
 
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
14:34:50.913995 IP valh4.lell.net.ssh > yy.domain.innetbcp.net.11006:
 P 1457239478:1457239594(116) ack 1561461262 win 63652
E.....@.@..]..i...9...*.V...]...P....h....E...>{..U=...g.
......G..7\+KA....A...L.
14:34:51.423640 IP valh4.lell.net.ssh > yy.domain.innetbcp.net.11006:
 P 116:232(116) ack 1 win 63652
E.....@.@..\..i...9...*.V..*]...P....h....7......X..!....Im.S.g.u:*..O&....^#Ba...
E..(R.@.|.....9...i.*...]...V..*P..OWp........

Note: Ifconfig command is used to configure network interfaces

4. Display Captured Packets in HEX and ASCII using tcpdump -XX

Some users might want to analyse the packets in hex values. tcpdump provides a way to print packets in both ASCII and HEX format.
 
$tcpdump -XX -i eth0 
 
18:52:54.859697 IP zz.domain.innetbcp.net.63897 > valh4.lell.net.ssh:
 . ack 232 win 16511
        0x0000:  0050 569c 35a3 0019 bb1c 0c00 0800 4500  .PV.5.........E.
        0x0010:  0028 042a 4000 7906 c89c 10b5 aaf6 0f9a  .(.*@.y.........
        0x0020:  69c4 f999 0016 57db 6e08 c712 ea2e 5010  i.....W.n.....P.
        0x0030:  407f c976 0000 0000 0000 0000            @..v........
18:52:54.877713 IP 10.0.0.0 > all-systems.mcast.net: igmp query v3 [max resp time 1s]
        0x0000:  0050 569c 35a3 0000 0000 0000 0800 4600  .PV.5.........F.
        0x0010:  0024 0000 0000 0102 3ad3 0a00 0000 e000  .$......:.......
        0x0020:  0001 9404 0000 1101 ebfe 0000 0000 0300  ................
        0x0030:  0000 0000 0000 0000 0000 0000            ............

5. Capture the packets and write into a file using tcpdump -w

tcpdump allows you to save the packets to a file, and later you can use the packet file for further analysis.
 
$ tcpdump -w 08232010.pcap -i eth0 
 
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
32 packets captured
32 packets received by filter
0 packets dropped by kernel

-w option writes the packets into a given file. The file extension should be .pcap, which can be read by any network protocol
analyzer.

6. Reading the packets from a saved file using tcpdump -r

You can read the captured pcap file and view the packets for analysis, as shown below.
 
$tcpdump -tttt -r data.pcap 
 
2010-08-22 21:35:26.571793 00:50:56:9c:69:38 (oui Unknown) > Broadcast,
 ethertype Unknown (0xcafe), length 74:
        0x0000:  0200 000a ffff 0000 ffff 0c00 3c00 0000  ............<...
        0x0010:  0000 0000 0100 0080 3e9e 2900 0000 0000  ........>.).....
        0x0020:  0000 0000 ffff ffff ad00 996b 0600 0050  ...........k...P
        0x0030:  569c 6938 0000 0000 8e07 0000            V.i8........
2010-08-22 21:35:26.571797 IP valh4.lell.net.ssh > zz.domain.innetbcp.net.50570:
 P 800464396:800464448(52) ack 203316566 win 71
2010-08-22 21:35:26.571800 IP valh4.lell.net.ssh > zz.domain.innetbcp.net.50570:
 P 52:168(116) ack 1 win 71
2010-08-22 21:35:26.584865 IP valh5.lell.net.ssh > 11.154.12.255.netbios-ns:
 NBT UDP PACKET(137): QUERY; REQUEST; BROADC

7. Capture packets with IP address using tcpdump -n

In all the above examples, it prints packets with the DNS address, but not the ip address. The following example captures the packets and it will display the IP address of the machines involved.
 
$ tcpdump -n -i eth0 
 
15:01:35.170763 IP 10.0.19.121.52497 > 11.154.12.121.ssh:
 P 105:157(52) ack 18060 win 16549
15:01:35.170776 IP 11.154.12.121.ssh > 10.0.19.121.52497: 
P 23988:24136(148) ack 157 win 113
15:01:35.170894 IP 11.154.12.121.ssh > 10.0.19.121.52497: 
P 24136:24380(244) ack 157 win 113

8. Capture packets with proper readable timestamp using tcpdump -tttt

$ tcpdump -n -tttt -i eth0

2010-08-22 15:10:39.162830 IP 10.0.19.121.52497 > 11.154.12.121.ssh: 
. ack 49800 win 16390
2010-08-22 15:10:39.162833 IP 10.0.19.121.52497 > 11.154.12.121.ssh: 
. ack 50288 win 16660
2010-08-22 15:10:39.162867 IP 10.0.19.121.52497 > 11.154.12.121.ssh: 
. ack 50584 win 16586

9. Read packets longer than N bytes

You can receive only the packets greater than n number of bytes using a filter ‘greater’ through tcpdump command
 
$ tcpdump -w g_1024.pcap greater 1024

10. Receive only the packets of a specific protocol type

You can receive the packets based on the protocol type. You can specify one of these protocols — fddi, tr, wlan, ip, ip6, arp, rarp, decnet, tcp and udp. The following example captures only arp packets flowing through the eth0 interface.
 
$ tcpdump -i eth0 arp 
 
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
19:41:52.809642 arp who-has valh5.lell.net tell valh9.lell.net
19:41:52.863689 arp who-has 11.154.12.1 tell valh6.lell.net
19:41:53.024769 arp who-has 11.154.12.1 tell valh7.lell.net

11. Read packets lesser than N bytes

You can receive only the packets lesser than n number of bytes using a filter ‘less’ through tcpdump command
 
$ tcpdump -w l_1024.pcap  less 1024

12. Receive packets flows on a particular port using tcpdump port

If you want to know all the packets received by a particular port on a machine, you can use tcpdump command as shown below.
 
$ tcpdump -i eth0 port 22 
 
19:44:44.934459 IP valh4.lell.net.ssh > zz.domain.innetbcp.net.63897: 
P 18932:19096(164) ack 105 win 71
19:44:44.934533 IP valh4.lell.net.ssh > zz.domain.innetbcp.net.63897: 
P 19096:19260(164) ack 105 win 71
19:44:44.934612 IP valh4.lell.net.ssh > zz.domain.innetbcp.net.63897: 
P 19260:19424(164) ack 105 win 71

13. Capture packets for particular destination IP and Port

The packets will have source and destination IP and port numbers. Using tcpdump we can apply filters on source or destination IP and port number. The following command captures packets flows in eth0, with a particular destination ip and port number 22.
 
$ tcpdump -w xpackets.pcap -i eth0 dst 10.181.140.216 and port 22

14. Capture TCP communication packets between two hosts

If two different process from two different machines are communicating through tcp protocol, we can capture those packets using tcpdump as shown below.
 
$tcpdump -w comm.pcap -i eth0 dst 16.181.170.246 and port 22

You can open the file comm.pcap using any network protocol analyzer tool to debug any potential issues.

15. tcpdump Filter Packets – Capture all the packets other than arp and rarp

In tcpdump command, you can give “and”, “or” and “not” condition to filter the packets accordingly.
 
$ tcpdump -i eth0 not arp and not rarp 
 
20:33:15.479278 IP resolver.lell.net.domain > valh4.lell.net.64639: 
 26929 1/0/0 (73)
20:33:15.479890 IP valh4.lell.net.16053 > resolver.lell.net.domain: 
 56556+ PTR? 255.107.154.15.in-addr.arpa. (45)
20:33:15.480197 IP valh4.lell.net.ssh > zz.domain.innetbcp.net.63897: 
P 540:1504(964) ack 1 win 96
20:33:15.487118 IP zz.domain.innetbcp.net.63897 > valh4.lell.net.ssh:
. ack 540 win 16486
20:33:15.668599 IP 10.0.0.0 > all-systems.mcast.net: igmp query v3 [max resp time 1s]