wikipedia

Support Wikipedia
Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Friday, March 27, 2015

Accessing samba bookmarks from linux command line

You can setup bookmarks to any folder on a host running samba with something like this
smb://DOMAIN-NAME;username@host/folder-name/

After providing the credentials. you can browse through the folder on file explorer(for example nautilus on ubuntu).

To access the same from command line, you don't need to mount any network drives, it's already mounted for you.


Try

ls -l /var/run/user/1001/gvfs/

where 1001 happens to be the folder assigned for my user id.Yours could be different.

This should list all the samba shares that are active.

$ ls -l /var/run/user/1001/gvfs/
total 0


drwx------ 1 myuser myuser 0 Mar 19 11:07 smb-share:domain=mydomain,server=host,share=,user=myuser
drwx------ 1 myuser myuser 0 Feb 16 13:29 smb-share:domain=mydomain,server=host,share=,user=myuser


To access the different shares all you have to do is cd to it. That's it, job done.

Wednesday, January 19, 2011

Unable to login to Ubuntu. Screensaver unresponsive!

Generally I don't power off my machine at the end of the day or for that matter anytime unless there are updates that prompt me to restart. Also I leave firefox ON with 10-15 tabs! So the system is ON for weeks sometimes even a month or two! Ofcourse some of the processes start getting slower and slower. especially Firefox. But then all I need to fix that is to restart Firefox.
But in the last 6 months or so I have been encountering this weird problem.
when I come to work the next day...many times I couldn't get to the login dialog screen, no matter how hard I tried with the mouse or keyboard. Seemed like the gnome screen saver had gone into the weeds! The machine was ON and everything was running. The solution to this is to login through a command line session CTRL-ALT-F6 and kill the gnome-screen saver process. I used top utility to find the process id (look for gnome-screensaver in the command column) and also kill it. and then try ALT-F7 and everything is fine.

Thursday, July 9, 2009

Java System Tray icon in Ubuntu

Download JDIC.
  • Using Synaptic package manager
    search for jdic and download both libjdic -java and libjdic-bin packages.
  • downloading from JDIC website
    download the linux distribution from here.
    Say you extract it to the directory /home/myuser/jdic
    You should see a linux folder which has jdic.jar and some .so files.
Here is a code example for creating a tray icon.


// Start Tray Icon Code
SystemTray tray = SystemTray.getDefaultSystemTray();
TrayIcon ti;

try {
if (Integer.parseInt(System.getProperty("java.version").substring(2, 3)) >= 5)
System.setProperty("javax.swing.adjustPopupLocationToFit", "false");
menu = new JPopupMenu("MY APP Menu");

// "Quit" menu item
menuItem = new JMenuItem("Exit");
menuItem.addActionListener(this);
menu.add(menuItem);

ImageIcon i = new ImageIcon(MyClass.class.getResource("/images/appImage.png"));

ti = new TrayIcon(i, "Welcome to My App", menu);

ti.setIconAutoSize(true);
ti.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MyApp.this.setVisible(!MyApp.this.isVisible());
if (MyAppFrame.this.isVisible() == false) {
ti.displayMessage(
"Welcome to MyApp",
"To open MyApp Application click the icon. To exit the application right click the icon and click the Quit menu item.",
0);
}
}
});

tray.addTrayIcon(ti);

// Construct the GUI for balloon message.
ActionListener al = new ActionListener() {

public void actionPerformed(ActionEvent e) {
MyApp.this.setVisible(!MyApp.this.isVisible());
if (MyApp.this.isVisible() == false) {
ti.displayMessage(
"MyApp",
"To open the MyApp Application click the icon. To exit the application right click the icon and click the Quit menu item.",
0);
}
}
};
exitMnu.addActionListener(al);

} catch (Exception e) {
logger.error("Unhandled error", e);
}

try {
this.setIconImage(new ImageIcon(MyApp.class
.getResource("/images/myApp.png")).getImage());
} catch (Exception e) {
logger.error("Unhandled error", e);
}
// End Tray Icon Code



For this to work, you need to add jdic jar to the build path and also add share library files location(/usr/lib/jni for the first case and /home/myuser/jdic/linux for the second) to the native library path for the project as shown in the picture below.

Monday, July 6, 2009

Mounting windows partition at bootup in Ubuntu

I have a dual booting linux system at work. I share the java projects (located on the windows partition) on both windows and Linux. But when I launch eclipse, all the projects show up closed since the windows partition is not mounted yet. The solution to this is to mount windows partition at boot up time.

To mount a windows partition at startup, you need to do the following.
- get the UUID of the device

blkid
/dev/sda1: UUID="9044866844865140" TYPE="ntfs"
/dev/sda2: LABEL="GHOST DATA" UUID="FCF8-3D81" TYPE="vfat"
/dev/sda5: UUID="b2293182-981b-4291-96ff-dba50f73510d" TYPE="ext3"
/dev/sda6: TYPE="swap" UUID="1d3b683c-c559-43e2-ac46-f3500e27dbfd"
- create an entry in /etc/fstab file for the windows NTFS drive
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
UUID="9044866844865140" /media/disk ntfs-3g defaults,locale=en_US.utf8 0 0
Instead of UUID specifying the device also works. see below
/dev/sda1 /media/disk ntfs-3g defaults,locale=en_US.utf8 0 0 
Note : both ntfs and ntfs-3g works fine for a windows partition.

The options for fstab are clearly explained in the ubuntu help docs here.

Friday, January 30, 2009

Search and grouping results in command line unix

Ever wanted to extract some metrics from log files and group the results. Also print the count for each group. All this without using a loop statement!!!
Just using command line. Here is how it can be done.

In the results, the first number is the count and the second is the group.

For starters here is a bit of explanation...The grep is looking for the string Failed to connect in service.log file. sed is used to make a group. In this case it is the station number. Then the results are sorted, finally uniq gives the unique rows and the -c gives us the count for each group.
BTW this was done on Ubuntu.

$ grep 'Failed to connect' service.log | sed 's/.*Station :\(.*\)/\1/' | sort | uniq -c
count
station
  69    10 - Host : 123.456.103.106 -  Failed to connect - Error :java.net.ConnectException: Connection timed out: connect
356 11 - Host : 123.456.103.105 - Failed to connect - Error :java.net.ConnectException: Connection timed out: connect
24 1 - Host : 123.456.103.107 - Failed to connect - Error :java.net.ConnectException: Connection timed out: connect
24 2 - Host : 123.456.103.98 - Failed to connect - Error :java.net.ConnectException: Connection timed out: connect
23 3 - Host : 123.456.103.99 - Failed to connect - Error :java.net.ConnectException: Connection timed out: connect
24 4 - Host : 123.456.103.100 - Failed to connect - Error :java.net.ConnectException: Connection timed out: connect
25 5 - Host : 123.456.103.101 - Failed to connect - Error :java.net.ConnectException: Connection timed out: connect
25 6 - Host : 123.456.103.102 - Failed to connect - Error :java.net.ConnectException: Connection timed out: connect
23 7 - Host : 123.456.103.97 - Failed to connect - Error :java.net.ConnectException: Connection timed out: connect
34 8 - Host : 123.456.103.104 - Failed to connect - Error :java.net.ConnectException: Connection timed out: connect
28 9 - Host : 123.456.103.103 - Failed to connect - Error :java.net.ConnectException: Connection timed out: connect