Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Connecting to USC Secure Wireless on Linux

Dec 23, 2014
Tested on: Ubuntu 14.04, Linux Mint 17, Linux Mint 17.1

USC (Univ. of Southern California) updated its wireless service to have an encrypted and faster connection available to USC faculty, staff, and students with name 'USC Secure Wireless'. Unfortunately for students like me, USC did not document how to use Linux computers with this service.

Following configuration has worked for me to connect to USC Secure Wireless during past couple of months. The basic idea is to use 'WAP2' or 'WAP Enterprise' security and use Protected EAP (PEAP) authentication along with GTC as secondary authentication. Same idea works on Android phones as well.

Create a new connection by right-clicking on 'Network connection' icon in notification area and choosing 'Edit Connections...' It will pop a 'Network connection' window. Click on the 'Add' button on the right side and choose 'Wi-Fi' as connection type. Then follow the settings described in the images below (click on the images to enlarge them). Note that the USC-id must be entered without @usc.edu.



And here is how the connection information looks like after being connected to USC Secure wireless.



Read more ...

LaTeX to word document

Jan 24, 2014
Tested on: Linux Mint 13 (Ubuntu 12.04), Microsoft Office 2010, LibreOffice 3

It is common to typeset scientific documents in  \(\LaTeX\). However, few people may like to still read and edit the document in word processors like Microsoft word (.doc or .docx)or LibreOffice (.odt). Here are quick (& dirty) steps to produce reasonably looking "office" documents from .tex files. The idea is to exploit HTML output as intermediate format which is readable by word processors. This ideas is shown below and has been explored and reported widely.
.tex.html.docx
  1. Convert \(\LaTeX\) to .html: There are various ways to achieve this, but htlatex from TeX4ht worked best for me. First install TeX4ht and then then run following on the \(\LaTeX\) document. Note that htlatex runs latex three times before calling TeX4ht programs and it would write out all the outputs in the same directory as the .tex file (see below for handling PDF images). The generated files would include one .html file (paper.html for command shown below). $ sudo apt-get install tex4ht $ htlatex paper.tex
  2. PDF images: If the .tex file uses PDF files as images, then htlatex (or latex) may not be able to go along with correct conversion. Some discussions on Stack Exchange were very help for this issue and provided the solution. First create a configuration file, say myxhtml.cfg, with following content: \Preamble{xhtml} \Configure{graphics*} {pdf} {\Needs{"convert \csname Gin@base\endcsname.pdf \csname Gin@base\endcsname.png"}% \Picture[pict]{\csname Gin@base\endcsname.png}% \special{t4ht+@File: \csname Gin@base\endcsname.png} } \begin{document} \EndPreamble Then run htlatex as shown below. Note that the .tex file should use correct extension for every included image (or else use \DeclareGraphicsExtensions{.pdf}). $ htlatex paper.tex myxhtml
  3. Fix HTML: Sometimes TeX4ht will not write out clean html files i.e. the html tags may not be aligned properly. This may prevent html to import into word processors. Online editors like Fix My Html and HTML Tidy Online did the trick for me. Use the .html file generated by htlatex as input to these online editors and save the fixed html file for next step.
  4. Import HTML in word processor: Usually most word processors would support importing HTML files. If that does not work (like in my case), you can just open the HTML file in a browser then copy-paste the whole page into the word processor (check if your word processor also supports Paste Special for formatted text. It everything works out then you should be able to just save the pasted document in .doc, .docx or .odt format. 
The above set of steps produced good looking single column document for me with correct bibiliography references. The math equations are embedded as images in the documents, which may not be optimal but the process works for reviewing and editing the text by someone who prefers word processors.
Read more ...

Parent directories in tar archives

Jan 3, 2014
Tested on: Linux Mint 13 Maya (based on Ubuntu 12.04 LTS)

It is common to see full directory tree or . (dot) in tar archives. Sometimes, it may be unnecessary hassle to remove all parent directories after extracting or to look for the extracted file which merged with other files in extracted directory. In some situations, it may be desirable to create a tar archive with top directory (with informative name). There has been many discussion about the same. Here is quick summary with an example for future reference.

Test setup

We will create a test directory with some files in it with following commands (outputs are also shown): $ mkdir -p /tmp/path/to/test/dir_archive $ touch /tmp/path/to/test/dir_archive/file{1..10} $ ls /tmp/path/to/test/dir_archive/ file1 file10 file2 file3 file4 file5 file6 file7 file8 file9 $ tar --version tar (GNU tar) 1.26 Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by John Gilmore and Jay Fenlason.

Full parent directory

Following command creates tar archive with full parent directory structure as shown by --list command. $ tar -caf /tmp/test.tar.gz /tmp/path/to/test/dir_archive $ tar --list -af /tmp/test.tar.gz tmp/path/to/test/dir_archive/ tmp/path/to/test/dir_archive/file3 tmp/path/to/test/dir_archive/file10 tmp/path/to/test/dir_archive/file1 tmp/path/to/test/dir_archive/file8 tmp/path/to/test/dir_archive/file4 tmp/path/to/test/dir_archive/file2 tmp/path/to/test/dir_archive/file7 tmp/path/to/test/dir_archive/file5 tmp/path/to/test/dir_archive/file6 tmp/path/to/test/dir_archive/file9

Dot (.) as parent directory

Following command creates tar archive with dot (.) as parent directory. Note that the tar command ends in a dot (.). $ tar --directory /tmp/path/to/test/dir_archive -caf /tmp/test.tar.gz . $ tar --list -af /tmp/test.tar.gz ./ ./file3 ./file10 ./file1 ./file8 ./file4 ./file2 ./file7 ./file5 ./file6 ./file9

Directory name as parent directory

The trick to get dir_archive as parent directory in tar archive is to use --directory to change directory to one level up as shown below. Note location of dir_archive in the command. $ tar --directory /tmp/path/to/test -caf /tmp/test.tar.gz dir_archive $ tar --list -af /tmp/test.tar.gz dir_archive/ dir_archive/file3 dir_archive/file10 dir_archive/file1 dir_archive/file8 dir_archive/file4 dir_archive/file2 dir_archive/file7 dir_archive/file5 dir_archive/file6 dir_archive/file9
Some more notes about tar command:
  • Above commands can be combined with used along with exclude directive to by using --exclude='dir_archive/dir_exclude' after the --directory option.
  • Do not mix absolute and relative path in tar command for pathname and exclude option. --directory is an exception and can be absolute path while others paths can be defined relative to it.
Read more ...

gs (GhostScript) cheat sheet

Aug 28, 2012
Cheat-sheet for versatile interpreter GhostScript. It can be used to tweak, convert, produce high quality Postscript and PDF files.

Convert postscript (ps) to pdf:

gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=fileout.pdf filein.ps

Merge ps and/or pdf:

gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=fileout.pdf filein1.ps filein2.pdf filein3.pdf

Extract page(s) from a ps or a pdf document:

gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dFirstPage=3 -dLastPage=3 -sOutputFile=fileout.pdf filein.ps

Embed fonts in a pdf:

gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=fileout.pdf -dPDFSETTINGS=/prepress -dEmbedAllFonts=true -dSubsetFonts=true -dCompatibilityLevel=1.6 filein.pdf

Convert images to pdf:

Check this post. Or else use ImageMagic's convert.

PDF optimization options

-dPDFSETTINGS=/screen (screen-view-only quality, 72 dpi images) -dPDFSETTINGS=/ebook (low quality, 150 dpi images) -dPDFSETTINGS=/printer (high quality, 300 dpi images) -dPDFSETTINGS=/prepress (high quality, color preserving, 300 dpi imgs) -dPDFSETTINGS=/default (almost identical to /screen)

Paper size options

-sPAPERSIZE=letter -sPAPERSIZE=a4 -dDEVICEWIDTHPOINTS=w -dDEVICEHEIGHTPOINTS=h (point=1/72 of an inch) -dFIXEDMEDIA (force paper size over the PostScript defined size) -gWIDTHxHEIGHT (page size in pixels)

Output devices:

-sDEVICE=pdfwrite -sDEVICE=ps2write -sDEVICE=png16m (24-bit RGB color) -sDEVICE=pnggray (grayscale) -sDEVICE=pngmono (black-and-white) -sDEVICE=pngalpha (32-bit RGBA color) -sDEVICE=jpeg (color JPEG) -sDEVICE=jpeggray (grayscale JPEG) -sDEVICE=epswrite (encapsulated postscript) -sDEVICE=txtwrite (text output, UTF-8) Check -sOutputFile below, for separate images for each page of a multi-page document. Tiff, PNM and many more formats are supported. Check details in Ghostscript output devices.

Help & list of available devices:

gs -h

Other options

-dNOPAUSE (no pause after page) -dBATCH (exit after last file) -sOutputFile=ABC-%03d.pgm (produces 'ABC-001.pgm'..'ABC-010.pgm'..) -dEmbedAllFonts=true -dSubsetFonts=true (Embeds only the characters used in document) -dCompatibilityLevel=1.4 (Adobe's PDF specifications, >=1.4 for font embedding, =1.6 for OpenType font embedding) -dCompressPages=true (compress page content) -dFirstPage=pagenumber -dLastPage=pagenumber -dAutoRotatePages=/PageByPage (or /All or /None) -rXRESxYRES (XRES & YRES in pixels/inch) -rRES (same XRES & YRES, affects images and fonts converted to bitmaps) -sPDFPassword=password More details & defaults on ps2pdf documentation.
Adobe® PDF Creation Settings - Used by GhostScript.
GhostScript Documentation.

Read more ...

Wireless power management in Ubuntu

Feb 15, 2012
Tested on: Ubuntu 11.04 (natty)

I have been experiencing extremely slow network connection whenever my laptop has been on battery. Speedtest results showed a 50 fold speed reduction when my laptop was on battery. I speculated that lower speed has to do with power-management, which reduces network speed in order to save battery. Ubuntu, like other operating systems, also has power management options installed by default. There is a frontend/GUI for Power Management preferences. But I could not find any thing related to wireless or Wi-Fi in the GUI. Looking around on internet, I found many pages. Here is a log of the things I found.
  • Confirming the behaviour: In order to make sure that power-management is the culprit of the slow network access run following command both when on power and when on battery.iwconfig The output should look like following: wlan0 IEEE 802.11bgn ESSID:"USC Wireless" Mode:Managed Frequency:2.462 GHz Access Point: 00:00:00:00:00:00 Bit Rate=65 Mb/s Tx-Power=15 dBm Retry long limit:7 RTS thr:off Fragment thr:off Power Management:on Link Quality=68/70 Signal level=-42 dBm Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 Tx excessive retries:27329 Invalid misc:204 Missed beacon:0 Notice line five of the output. If it says anything other than Power Management:off while on battery, then it could be power management which is slowing down then network. Check power argument in iwconfig man page for other possible options.

  • Temporarily disable the power-management: While on battery, run following command (replace wlan0 with your Ethernet name) sudo iwconfig wlan0 power off This will only affect the wireless settings of power management. and should change the output of previous command to Power Management:off and most-likely revert the network speed to usual speed. However, on restarting the system the power management will be enabled.

  • Permanently disable power-management for wireless: If you do not want to keep running the above command each time you restart you laptop, create a file /etc/pm/power.d/wireless with following content: #!/bin/sh /sbin/iwconfig wlan0 power off Make the file executable by running following command:sudo chmod +x /etc/pm/power.d/wireless This new file will override the default wireless script run by power management and will also make sure that wireless power management is turned off. The above trick is taken from Ubuntu Documentation (Check few lines before the example). It says:

    When you run pm-powersave it combines the scripts in these two directories and executes them in sorted order. If both directories contain a script with the same name, the one in /etc/pm/power.d/ has a higher precedence and only this one will be executed. Therefore to disable a script from /usr/lib/pm-utils/power.d/ simply create an empty file in /etc/pm/power.d/ with the same name and without the execute bit set.


Read more ...

vsftpd behind router/firewall

Jan 28, 2012
Tested on: Ubuntu 11.04 (natty)

This is how I got vsftpd server work behind a router. If you are getting errors like "Server sent passive reply with unroutable address. Using server address instead." or "500 illegal port command" on list (ls) command, this post might help. Setting passive mode configuration correctly is the trick.

Please note that this may not be the perfect solution or even worse - not very secure. Read vsftpd.conf manual before applying any changes.

Make sure port 20, 21 and few more ports, for example 4242-4252, are being forwarded to the server. We will need these extra ports for passive mode - set pasv_min_port and pasv_max_port accordingly in the configuration file. Add following to /etc/vsftpd.conf . connect_from_port_20=YES pasv_enable=YES pasv_addr_resolve=YES pasv_address=myaddress.dyndns.com pasv_min_port=4242 pasv_max_port=4252 Set pasv_address to your domain name. You can use dyndns for dynamic ip-address. vsftpd will convert your domain name to ip address when vsftpd server starts. Note that if your ip address changes after vsftpd has started it will not update the ip-address. There has been some attempt to the solve it.
Here are some more configurations with comments: # Only allow FTP access to users listed in file /etc/vsftpd.userlist # Other users will not have ftp access userlist_enable=YES userlist_deny=NO userlist_file=/etc/vsftpd.userlist # Disable delete commands cmds_denied=DELE,RMD # Verbose logging log_ftp_protocol=YES # You may restrict local users to their home directories. See FAQ for # the possible risks in this before using chroot_local_user chroot_local_user=YES
For more security, you can also modify the login-shell of a dummy ftp user to something like /bin/false - which does not exist. Use following command sudo usermod -s /bin/false <username> In order to make this work you have to add /bin/false to the file /etc/shells. Or else vsftpd will generate login error when the user logs in using ftp.
Read more ...

xpdf & X resource

Aug 7, 2011
Tested on: Ubuntu 11.04

xpdf man page is not very detailed in terms of possible values for X resource file. Following are the places where xpdf settings can be specified:
  • Ubuntu X resource file: ~/.Xresources The exact files being read can be found by looking into /etc/gdm/Xsession. My settings in ~/.Xresources # xpdf settings xpdf.geometry: 1280x1024 xpdf.initialZoom: width Run following for immediate effect: xrdb -nocpp -merge ~/.Xresources
  • xpdfrc can be found at ~/.xpdfrc and at /etc/xpdf/xpdfrc. My ~/.xpdfrc file: include /etc/xpdf/xpdfrc initialZoom width
Read more ...

TeamViewer: Unattended auto-start in Ubuntu

Aug 4, 2011
Tested on: Ubuntu 11.04 (Natty Narwhal)

This is log of the steps to setup TeamViewer on Ubuntu on my laptop, so that I can access my laptop from any other computer, without any user interaction on my laptop's end. More importantly, TeamViewer should be started on each reboot automatically & should not interfere with user normal task(s).

Precisely its an effort to mimic TeamViewer on windows, where it can be used to remotely access the computer even before login to windows (Though this workaround is cheating as we use auto-login feature of Ubuntu. Read step 3 for details). Following are the main steps:
  1. Install & setup TeamViewer for auto-start - Detailed steps are here.
    • Download & install appropriate .deb file.
    • Add a new application in Menu -> System -> Preferences -> Startup Applications.
  2. (Optional) Some configuration to make sure that TeamViewer does not pop-up on user logins.
  3. Configure Ubuntu to automatically login & then lock the screen
Details of last two steps are given below.
Step 2:
This is optional step. Its safe to skip this step. If TeamViewer is added to auto-start on each login, the user gets the TeamViewer window on each login. This might be annoying after some time. So, the idea here is to use another application, devilspie, to hide TeamViewer window: put the TeamViewer window on another workspace and/or minimize it. Here is a very good devilspie tutorial.
  • Install devilspie (& maybe gDevilspie, a nice front-end)
  • Create devilspie directory mkdir ~/.devilspie
  • Create a file with name 'teamviwer.ds' & put following in it. ; generated_rule teamviewer ( if ( begin ( is ( application_name ) "TeamViewer" ) ( is ( window_name ) "TeamViewer" ) ) ( begin ( set_workspace 2 ) ( minimize ) ( println "match" ) ) ) It will put the windows with name "TeamViewer" on workspace 2 & minimize it. Make sure devilspie demon is running. Check gDevilspie GUI.

This is not a very elegant solution. There were some minor issues with the rendering of the TeamViewer window (Though it works without any flaw). There can be some other ways to put it in system tray using some application like alltray. But this workaround is good enough for me.

Step 3: Configure Ubuntu to automatically login & then lock the screen
TeamViewer will auto-start only when user is logged in. So in order to make sure that TeamViewer is started even in case of remote reboot, auto-login has to be enabled. But this is also a security/privacy threat. One of the easiest way to maintain security is to somehow lock the screen immediately after login in. We can create a custom xsession for the same. See note 2 below, if you are using some secured wireless network on Ubuntu.

Create a file /usr/share/xsessions/autolock.desktop with following content. Change username to the correct user name. [Desktop Entry] Name=Auto Lock Gnome Comment=Custom ~/.xsession script Exec=/home/<username>/.xsession X-Ubuntu-Gettext-Domain=gdm
Create another file ~/.xsession with following content: #! /bin/bash gnome-screensaver gnome-screensaver-command --lock gnome-session --session=2d-gnome Note the last line. I am loading the Ubuntu (Wihout any effects). You may want to change it to appropriate session. Check other .desktop files in /usr/share/xsessions/ for the correct command.

Now enable auto-login. Menu-> System -> Administration -> Login Screen. Select "Auto Lock Gnome" in the default session. Reboot & you should see the change. Check note 1 & 3 as well.

Notes:
  1. You may opt to allow only selected computers to connect to the TeamViewer for better security. See 10.2 "Security Category" in TeamViewer manual
  2. If auto-login is enabled, Gnome-Keyring kicks in each time after auto-login & usually affects all application related to saved passwords including network-manager. This is especially important if you are using a secured network, like WEP etc, as the internet connection won't be active till user enters the password in Gnome-Keyring manually. Here is a very easy work-around to get internet connection without Keyring kicking in. You should apply this changes for only the trusted network(s).
  3. Please note that enabling Auto-login & configuring it to connect to wireless network automatically is a potential security threat. Try it at your own risk.
Read more ...

CVS cheatsheet

Jul 15, 2011
Tested on: CentOS release 5.6 (Final)

There are many other CVS cheatsheets & books on the web. This is my version, which is intended to grow with time but will be less verbose (might not be good for beginners).
  • Update current working directory with prune & build directories cvs update -P -d
  • Difference between current version & latest repository version: cvs diff -cw <fileName>
  • Rename a file: mv <OldFileName> <NewFileName> cvs remove <OldFileName> cvs add <NewFileName> cvs commit -m "Renamed <OldFileName> to <NewFileName>" <OldFileName> <NewFileName>
Read more ...

Infrequent Linux commands

Jul 15, 2011
Tested with mainly Ubuntu-based distributions. List of Linux commands which are useful but not frequently used. See online or local man pages for details.

System Information

uname -a # Details of kernel, processor, machine, OS cat /proc/version # Detailed kernel version. More details about /proc. cat /etc/*-release # See details of distribution lsb_release -a # See details of distribution service --status-all # status of init services; [+] Running, [-] Not running, [?] Unknown sudo initctl list # List & status of upstart jobs. More at UbuntuBootupHowto.

Hardware Information

cat /proc/cpuinfo # Shows CPU details free -mt # Shows details of memory usage sudo dmidecode -t memory # Shows details of RAM slots df -hT # Report disk type, space usage, mount points sudo fdisk -l # Lists partition table of all disks blkid # Lists UUID and type of all disks ls -l /dev/disk/by-uuid # Lists drives by UUID

Users and Groups

groups <username> # Lists group memberships of the user id -u <username> # Prints user-id of user id -g <username> # Prints group-id of user id <username> # Print user and group information of user sudo passwd <username> # Change user password sudo usermod -d /new/home/dir <username> # Change user home directory
  • Disk usage (size) of directories: du -ach du -sch du -ch /home/user
  • List USB Devices lsusb -t
  • apt installed packages:less /var/log/apt/history.log zless /var/log/apt/history.log.1.gz dpkg --get-selections | sed -n 's/\t\+install$//p' Automatically installed packages </var/lib/apt/extended_states awk -v RS= '/\nAuto-Installed: *1/{print$2}'
  • Image to pdf:convert *.png out.pdf convert -compress jpeg *.png out.pdf

Last edited: June 11, 2014

Read more ...

Configuration Files

Sep 13, 2010
Updated weekly irrespective of the date of this blog post.

Ubuntu


Windows

Read more ...

Monday as first day of week - Ubuntu

Sep 13, 2010
Tested on: Ubuntu 10.04 (Lucid Lynx)

The calendar, which pops on mouse click over clock in Gnome panel, generally has Sunday as first day of week. This may not be a desired behavior if you use this calendar to manage all your appointments etc. Following are the steps to make Monday or any other day as first day of week.

The calendar and time etc are associated with the local settings. Use following command to know current locale-specific information.
locale In my case it produces the following output: LANG=en_US.utf8 LC_CTYPE="en_US.utf8" LC_NUMERIC="en_US.utf8" LC_TIME="en_US.utf8" LC_COLLATE="en_US.utf8" LC_MONETARY="en_US.utf8" LC_MESSAGES="en_US.utf8" LC_PAPER="en_US.utf8" LC_NAME="en_US.utf8" LC_ADDRESS="en_US.utf8" LC_TELEPHONE="en_US.utf8" LC_MEASUREMENT="en_US.utf8" LC_IDENTIFICATION="en_US.utf8" LC_ALL= Locale in my case is en_US. Then the specific locale file have to edited for the required change. Use following command (replace en_US by your locale):
sudo nano /usr/share/i18n/locales/en_US Search for "first_weekday" & "first_workday" and set both of them to 2 or any other value depending on your choice of first day of week. Sunday is represented by number 1.
first_weekday    2 first_workday    2 Then run following to compile the changes to locale definition files.
sudo locale-gen Logout and login. Or you can also run the following to avoid logout: killall gnome-panel It should do the trick.


Read more ...

apt-get behind proxy server

Apr 6, 2010
Tested on: Ubuntu 9.10 (Karmic Koala)
  • Using Synaptic
    Navigate to Settings->Preference->Network in Synaptic package manager. Enter your proxy server details like: username:password@proxyserver, and put the proxy server port

  • Using Command Line
    Add following lines to the end of ~/.bashrc http_proxy=http://username:password@proxyserver:port/ ftp_proxy=http://username:password@proxyserver:port/ https_proxy=http://username:password@proxyserver:port/ HTTP_PROXY=http://username:password@proxyserver:port/ FTP_PROXY=http://username:password@proxyserver:port/ HTTPS_PROXY=http://username:password@proxyserver:port/ no_proxy=server1,server2 NO_PROXY=server1,server2 Replace username, password, proxyserver and port by relevant value. You can omit username:password if your proxy server do not require any authentication. All the names, like http_proxy, are obvious and self-explanatory. no_proxy can take any number of servers separated by comma. Then type following command in shell sudo visudo It will open up a text editor in shell. Add the following line at the end of the file Defaults env_keep += "ftp_proxy http_proxy https_proxy HTTP_PROXY HTTPS_PROXY FTP_PROXY NO_PROXY no_proxy" It instructs to keep the variables from user environment to the sudo environment.
Read more ...

LXDE

Mar 8, 2010
Tested on: Ubuntu 9.10 (Karmic Koala) I found about LXDE few days back and found it to be suitable for my need of fast and configurable desktop environment. Most of the gnome applications (except automatic wallpaper changers like wallpaper-tray) also work without any flaw.

Note: I did not install lubuntu-desktop package. I just installed lxde & dependent packages.

Here are few configuration changes I made:
  • Changed default browser to firefox: sudo ln -sf /usr/bin/firefox /etc/alternatives/x-www-browser as /etc/bin/x-www-browser is symbolic link to /etc/alternatives/x-www-browser
  • Changed clock format to %a, %d %b, %I:%M %p in "Digital Clock" Settings. It displays in this format: Tue, 09 Mar, 10:22 AM
  • Added global keyboard hotkeys/shortcuts for Rhythmbox & Volume control by editing ~/.config/openbox/lxde-rc.xml and adding following to <keyboard> section <!-- Keybindings for audio volume --> <keybind key="W-Down"> <action name="Execute"> <execute>amixer -q set PCM 2- unmute</execute> </action> </keybind> <keybind key="W-Up"> <action name="Execute"> <execute>amixer -q set PCM 2+ unmute</execute> </action> </keybind> <keybind key="W-m"> <action name="Execute"> <execute>amixer -q set Master toggle</execute> </action> </keybind> <!-- Rhythmbox Shortcuts --> <keybind key="W-z"> <action name="Execute"> <command>rhythmbox-client --previous</command> </action> </keybind> <keybind key="W-x"> <action name="Execute"> <command>rhythmbox-client --play-pause</command> </action> </keybind> <keybind key="W-c"> <action name="Execute"> <command>rhythmbox-client --pause</command> </action> </keybind> <keybind key="W-v"> <action name="Execute"> <command>rhythmbox-client --next&nbsp;</command> </action> </keybind> More about key-bindings can be found on openbox binding help page.
  • Edited .desktop files in /home/chitresh/.local/share/applications using commands like lxshortcut -i firefox.desktop
Most of the answers to frequently asked questions can be found here.
Read more ...

cron scripts being executed at wrong time

Feb 4, 2010
Checked on: Ubuntu Karmic Koala 9.10

Few days back I was shocked to see that one of my cron scripts was being executed at 3:24PM, which was actually scheduled to be executed at 4AM. Probing with the system logs further revealed that none of the cron scripts were following the specified schedule. After googling a little bit I found that it is a common problem and has been discussed in many forums. Here is a synopsis of the all the discussions.

Cron is a utility, which is supposed to automatically execute specific commands periodically (daily, monthly etc). The preferences of the schedule for root is stored in /etc/crontab file and can be edited directly to make changes. Check this link to understand structure of crontab. Non-root users can also have their own cron schedule but their crontab file are located at different location. So, non-root users are suggested to use following command for editing their crontab. crontab -e Default entry of /etc/crontab is given below: # /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do. SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user    command 17 *    * * *    root    cd / && run-parts --report /etc/cron.hourly 25 4    * * *    root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6    * * 7    root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6    1 * *    root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) # Let us examine following line from crontab. 25 4    * * *    root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) It means that cron will execute following command daily at 04:25 AM as root. test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) The problem lies in first part of the command i.e. test -x /usr/sbin/anacron. The test command checks that whether the file /usr/sbin/anacron exists (& is executable), and if it exists then do not execute the next part (where actually scripts are being called). So, crontab is actually instructing to skip the execution of scripts at the scheduled time, if anacron is installed !! Sounds funny :) Clearly, this anacron is the culprit of all the chaos in schedule.

Anacron performs periodic command scheduling but without assuming that the system is running continuously. Cron schedules are not executed if the system is not running at the scheduled time. Anacron makes sure that these commands are run at the specified intervals as closely as machine uptime permits. Anacron reads a configuration file (/etc/anacrontab) that specifies the jobs Anacron controls, and their periods in days. If a job wasn't executed in the last n days, where n is the period of that job, Anacron executes it. Anacron then records the date in a special timestamp file that it keeps for each job, so it can know when to run it again. So, when a schedule is missed, the job is execute after next boot and a timestamp (depending on period of the job) is fixed for next run. This process may ultimately lead to timestamps which are too much out of the cron schedule. And this creates all the chaos.

Anacron is cron-complement (it requires cron) for laptop and home PC which are not running 24x7. So, Ubuntu Desktop edition have anacron installed by default and the crontab is configured so that cron is over ridden by anacron, if installed. The test commands can be removed from crontab as given below, if this default behavior is not required.

Note:
1. There are some known issues with hardware-clock time, when timezone is different. Check last few sections of this page.
2. fcron is intended to provide better features for periodic command scheduling.
Read more ...

Setting up VNC for GDM Login

Nov 12, 2009
Tested on: Ubuntu 9.10 (Karmic Koala)

Ubuntu has a Remote Desktop server (Vino), which can be easily configured. But personally I found it to be too slow (even on 100Mbps connection) and there is no option to get it up & running before actual GDM login. One of the faster alternatives is x11vnc. It allows one to view remotely and interact with real X displays with any VNC viewer. Following are the steps to enable x11vnc immediately after GDM (or XDM, KDM etc) loads. We will be effectively using XDMCP over VNC.
  1. Enable XDMCP
    • Older Ubuntu version: System->Administration->Login Screen Setup-> Tab XDMCP->Enable XDMCP. You can disable "Honor Indirect Requests".
    • Karmic Koala: There is no XDMCP Tab in settings. So add "Enable=true" in [xdmcp] section of /etc/gdm/custom.conf (or gdm.conf for older version of GDM). Check here for detailed instructions.
    • For others, just look through the settings and find XDMCP, make sure it's enabled.
  2. Disable Desktop Sharing with Vino under System -> Preferences -> Remote Desktop. Install x11vnc from repository.
  3. Create password for VNCsudo x11vnc -storepasswd yourpasswordhere /etc/x11vnc.pass
  4. Configure GDM to run x11vnc when it loads:sudo nano /etc/gdm/Init/Default & add this line to the file just before exit 0:/usr/bin/x11vnc -nap -bg -many -repeat -clear_keys -rfbauth /etc/x11vnc.pass -rfbport 5900
  5. Edit gdm configuration to make sure that x11vnc is not killed after being started.sudo nano /etc/gdm/custom.conf Add / edit KillInitClients option in the [daemon] section to:KillInitClients=false Also check this FAQ for recent changes and other workarounds in x11vnc regarding KillInitClients.
  6. Restart gdm (you can just reboot), and you are good to go.
Few things to be noted:
  1. x11vnc does NOT have any options for locking the server machine's display on connection with client. If this is an important security issue then other vnc servers like vino, tightvnc etc should be used. Refer comments for more details.
  2. You may experience endless key repetition / key pressing when logged from a client. Use "-repeat" options with x11vnc to check this behavior. Check this discussion for other alternatives.
  3. I experience initial delay (about 6-7 secs) in response from x11vnc whenever I try to make a new connection. Though, it responds nicely after initial glitch.
Edits:
17 Jan, 2010: [debug] changed to [daemon], as it makes more sense according to GDM manuals.
18 Jan, 2010: Added FAQ link in step 5.


Read more ...

Useful applications in Ubuntu

Sep 16, 2009

Read more ...

Change default Home, Desktop and documents path in Ubuntu

Sep 11, 2009
  • Edit ~/.config/user-dirs.dirs and set your desired path.
[ Reference(s): Ubuntuforums ]
 
Read more ...

ProFTPD Virtual User Setup with AuthUserFile

Sep 10, 2009
  1. Edit or add following to proftpd.conf
    AuthOrder mod_auth_file.c
    AuthUserFile /etc/proftpd/ftpd.passwd
    AuthGroupFile /etc/proftpd/ftpd.group
    RequireValidShell off
  2. Get uid and gid
    cat /etc/passwd | grep <username>
    cat /etc/group | grep <groupname>
  3. Add users to ftpd.passwd
    ftpasswd --uid <uid> --gid <gid> --gecos "Full Name" --name <username> --shell /bin/false --home <path> --passwd
  4. Add Groups to ftpd.group
    ftpasswd --gid <gid> --name <groupname> --group
  5. Add members to a group
    ftpasswd --gid <gid> --name <groupname> --member <membername> --group
  6. Set permissions on the ftpd.passwd and ftpd.group files
    chmod 400 /etc/proftpd/ftpd.passwd /etc/proftpd/ftpd.group
    chown proftpd.nogroup /etc/proftpd/ftpd.passwd /etc/proftpd/ftpd.group
  7. Restart ProFTPD
    /etc/init.d/proftpd restart
[ Reference(s): Link1, Link2 ]

Read more ...

Disable ipv6 in Ubuntu

Sep 10, 2009
  1. sudo gedit /etc/modprobe.d/aliases
  2. Find the line: alias net-pf-10 ipv6
  3. Edit this to: alias net-pf-10 off
  4. Save the file and reboot
  5. Check ipv6. There should not be any output to any of the following commands.
    ip a | grep inet6
    lsmod | grep v6
  6. change network.dns.disableIPv6 to true in about:config of Firefox.
[ Reference(s): Ubuntuforums ]
 
Read more ...