Evernote for Linux

Evernote

Evernote is an awesome app for note taking but unfortunately it isn’t available for Linux yet. So, we can use the Evernote web app as a standalone application using the GNOME web app launcher. Since the Evernote web app is pretty clean, you don’t feel a difference at all.

From Gnome 3.10 onwards, you can launch any web app without the usual browser menus. Two browser currently supports this:

  • Epiphany (Gnome Web)
  • Chrome

Epiphany isn’t a shinny browser like Google Chrome and Firefox. It doesn’t render some pages correctly. And Firefox doesn’t support web app launchers yet. So, I recommend the Google Chrome for this job.

Chrome
1) Go to your Evernote home page (usually https://www.evernote.com/Home.action).
2) In Chrome, Click “Settings -> More tools -> Create application shortcuts…”.
3) It’ll create the necessary Desktop entry and Application Menu entry in the user’s home directory. Just click “Create“.
4) It’ll use the web app’s favicon as the Application Icon which has low resolution and not good.
5) So, to change the application icon, download the evernote icon from the internet (https://cdn4.iconfinder.com/data/icons/free-colorful-icons/360/evernote.png).
6) Go to user’s application settings directory :
cd ~/.local/share/applications/
7) Find the .desktop file which starts with “chrome” as prefix and “evernote” in the file name like “chrome-https___www.evernote.com_Home.action_2.desktop“.
8) Replace the “Icon=” entry’s value with the newly downloaded icon’s path.
9) Just logout and login.
10) Search for Evernote in your GNOME Activities, you’ll get a fancy Evernote app in your menu.

Note : I’m using Fedora 21 with GNOME 3.14.2 on it.

Run shell script as root user (without sudo) using setuid

In the most Linux distributions, setuid doesn’t work on shell scripts because of the security issues associated with it.

But you can use the setuid on binary files and from there you can execute the shell script as root user. And the following steps will help you to do that.

1) Copy the following C program to a file named “runasroot.c” and this program simply runs a script which is passed as command-line argument.

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {                                              
  if (argc != 2) {                                                              
    printf("Usage: %s /path/to/script\n", argv[0]);                             
    printf("Note: '/path/to/script' can be either relative or absolute path.\nE\
xamples:\n%s ./build.sh \n%s /tmp/test.sh\n", argv[0], argv[0]);                
  } else {                                                                      
    printf("Running the script '%s' as root user...\n", argv[1]);               
    setuid(0);                                                                  
    system(argv[1]);                                                            
  }                                                                             
   return 0;                                                                    
}

2) Compile it.

gcc runasroot.c -o runasroot

3) Change the ownership of the compiled executable binary to root

sudo chown root:root runasroot

4) Change the permissions on the binary file with setuid flag

sudo chmod 4755 runasroot

5) Run the script using the executable binary file

./runasroot script.sh

Examples :

./runasroot ./build.sh 
./runasroot /tmp/test.sh

You can even copy this ‘runasroot’ executable file to your home bin directory (i.e., in ‘/home/user/bin‘) so that you can use it anywhere in your scripts. And you can use the ‘runasroot‘ command (without any password prompt) instead ofsudo‘ in your commands. If you want to pass parameters to the commands, you should use single/double quotes to surround it.

runasroot 'fdisk -l'

instead of

sudo fdisk -l

Warning: Make sure you don’t place this script in any common directory (like /usr/bin or /opt) in a multi-user environments.

How to fix the wireless network issues in Fedora?

Issue 1 : NetworkManager asks password each time (even password is saved) when you connect to enterprise wireless network.

Does you fedora (NetworkManager) asks the password each time even when you saved it? I’m also faced it with my ThinkPad Edge (Fedora 20) and found a workaround to fix it.

Continue reading “How to fix the wireless network issues in Fedora?”

Optimize Fedora Booting Process

When I’m checking the performance of my fedora, I found that my fedora takes 36 seconds to boot completely which is double the value of expected (15s) boot-up time. I decided to optimize my fedora boot process to achieve the standard boot-up time.

* Install the ‘systemd-analyze’ package :
$ yum install systemd-analyze

* Check the total boot time :
$ systemd-analyze time | tee total-boot-time.log

Output should look like :
Startup finished in 3167ms (kernel) + 4318ms (initramfs) + 29511ms (userspace) = 36998ms

* Kernel took 3 secs
* RAM Disk took 4 secs
* Userspace programs took nearly 30 secs

We can optimize the userspace programs first.
Note : ‘tee’ command prints & copies the output to a file (for comparison purpose).

* Check the detailed boot time :
$ systemd-analyze blame | tee detailed-boot-time.log

Output should look like :
10583ms udev-settle.service
4762ms fedora-loadmodules.service
3857ms NetworkManager.service
3300ms avahi-daemon.service
2794ms systemd-binfmt.service
2571ms fedora-storage-init.service
1942ms media.mount
1922ms systemd-vconsole-setup.service
1911ms sys-kernel-debug.mount
1894ms dev-hugepages.mount
1863ms fedora-storage-init-late.service
1862ms dev-mqueue.mount
1657ms fedora-readonly.service
1643ms mdmonitor-takeover.service
1587ms udev-trigger.service
1580ms home.mount
1534ms udev.service
.....

To plot these output to a graph :

$ systemd-analyze plot > boot-graph.png

fedora-boot-up-time-graph-before-change
Fedora boot-up time graph

* Find the failed boot process & fix it :
$ systemctl --failed

Output should look like :
UNIT LOAD ACTIVE SUB JOB DESCRIPTION
systemd-tmpfiles-clean.service loaded failed failed Cleanup of Temporary Directories
systemd-tmpfiles-setup.service loaded failed failed Recreate Volatile Files and Directories
tcsd.service loaded failed failed LSB: Init script for TCSD
vmware.service loaded failed failed SYSV: This service starts and stops VMware services

To fix these failed services, check the status of each one which gives the reason for the failure.

For example :
$ systemctl status systemd-tmpfiles-clean.service
systemd-tmpfiles-clean.service - Cleanup of Temporary Directories
Loaded: loaded (/usr/lib/systemd/system/systemd-tmpfiles-clean.service; static)
Active: failed (Result: exit-code) since Mon, 22 Oct 2012 12:33:18 +0530; 57min ago
Docs: man:tmpfiles.d(5)
Main PID: 2745 (code=exited, status=1/FAILURE)
CGroup: name=systemd:/system/systemd-tmpfiles-clean.service

Oct 22 12:33:18 fedora systemd-tmpfiles[2745]: [/etc/tmpfiles.d/jetty.conf:1] Unknown user 'jetty'.
Oct 22 12:33:18 fedora systemd-tmpfiles[2745]: stat(/run/user/sriram/gvfs) failed: Permission denied

$ [[email protected] ~]$ sudo /usr/bin/systemd-tmpfiles --create --remove
[/etc/tmpfiles.d/jetty.conf:1] Unknown user 'jetty'.

Then, I reinstalled the jetty package which fixed ‘jetty’ user issue.

* Disable the unnecessary services (including non-native services) :

$ systemctl disable mdmonitor.service mdmonitor-takeover.service fcoe.service lldpad.service vmware.service iscsid.service iscsi.service tcsd.service livesys.service livesys-late.service lvm2-monitor.service spice-vdagentd.service

mdmonitor & mdmonitor-takeover – service for RAID devices
fcoe & lldpad – Fiber Channel Over Ethernet service
iscsi & iscsid – service for iSCSI devices
tcsd – Trusted Computing Service
livesys & livesys-late -service for live CD

Again I removed few more services
$ systemctl disable jetty.service sendmail.service ip6tables.service vmware-USBArbitrator.service

* Check the performance again by doing step 2 & 3. :

After these above steps, improved the performance in userspace by 6 secs.
>> Startup finished in 3164ms (kernel) + 4571ms (initramfs) + 22200ms (userspace) = 29937ms

But my expectation was, kernel : 3secs, initramfs : 3secs, userspace programs : 15 secs

If you are not using LVM, RAID or Multipath, then disable the udev-settle, fedora-storage-init, fedora-storage-init-late & fedora-wait-storage services.
$ systemctl mask fedora-wait-storage.service fedora-storage-init-late.service fedora-storage-init.service udev-settle.service
$ systemctl disable plymouth-start.service avahi-daemon.service

Remove abrt completely
$ yum remove abrt*

Advanced Optimization : Skipping RAM disk
Kernel can boot directly from an ext4 partition without initramfs.
Comment the initrd line and add these parameter ‘root=/dev/sda3 rootfstype=ext4’ to your kernel
linux /boot/vmlinuz-3.6.2-4.fc17.i686.PAE root=/dev/sda3 rootfstype=ext4 libahci.ignore_sss=1 raid=noautodetect ro rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0 KEYTABLE=us SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8
#initrd /boot/initramfs-3.6.2-4.fc17.i686.PAE.img

>> Startup finished in 4389ms (kernel) + 22460ms (userspace) = 26850ms

So, Boot-up time reduced upto 10 secs.

Fedora Boot-up time graph after optimization
Fedora Boot-up time graph after optimization

* More Aggressive Optimization :
1) Disable SELinux and auditing services
2) Mask fedora-autoswap.service fedora-configure.service fedora-loadmodules.service fedora-readonly.service
3) Don’t use debug kernels
4) Don’t use LVM

“Cannot open font file True” in Fedora

When you start the fedora 16/17, it will show you an message “Cannot open font file True” in boot screen for few seconds. To fix this, we need to change the sysfont to default.
Steps :
1) Open the grub configuration
** sudo vi /etc/default/grub
2) Update the SYSFONT to latarcyrheb-sun16 and save the file.
** Look for "SYSFONT=True" and replace it with "SYSFONT=latarcyrheb-sun16"
3) Generate the grub configuration
** sudo grub2-mkconfig -o /boot/grub2/grub.cfg

Bugzilla URL : https://bugzilla.redhat.com/show_bug.cgi?id=799401

Enabling Android USB Debugging in Fedora

To Enable USB Debugging, Enable it in the Android device by Applications–>Development–>Enable USB Debugging.

Then you need to add the following file (rule) to the udev rules directory :

su –
vi /etc/udev/rules.d/99-android.rules

Add the following code to this file :

SUBSYSTEM==”usb”,SYSFS{idVendor}==”04e8″,SYMLINK+=”android_adb”,MODE=”0666″

Here idVendor means your device vendor, so change it accordingly. For more details, refer this

http://developer.android.com/guide/developing/device.html

After saving this file, run this command to reload the udev rules.

udevcontrol reload_rules

After that, Everything will work!…