SaltyCrane Blog — Notes on JavaScript and web development

Ubuntu notes

Boot process

  • What are the stages of the boot process?
    1. BIOS
    2. Master Boot Record
    3. Bootloader (LILO, GRUB)
    4. Kernel
    5. init
    6. Run Levels

  • Where is the GRUB menu list?
    /boot/grub/menu.lst

  • How do I get rid of Ubuntu splash screen / progress bar and show scrolling text?
    Remove quiet and splash from "kernel" line in /boot/grub/menu.lst

See also:
http://en.wikipedia.org/wiki/Linux_startup_process
http://www.debianhelp.co.uk/boot.htm

Run levels

  • What are the run levels for Ubuntu?
    1: single user
    2: default
    3-5: same as 2
    6: reboot

  • Where can I find the default startup programs for run level 2?
    /etc/rc2.d

  • How do I update the symbolic links in /etc/rc?.d?
    Use update-rc.d. For help, man update-rc.d.

  • Where is the default run level set in Ubuntu?
    /etc/event.d/rc-default

Xsessions

  • Where is another location for startup programs?
    /etc/X11/Xsession.d

Restarting

  • What are some alternatives to rebooting?
    1. Restart the display manager, gdm
      sudo /etc/init.d/gdm restart or CTRL+ALT+BACKSPACE
    2. Switch to runlevel 1 then back to runlevel 2
      sudo telinit 1 then telinit 2 (this didn't work for me; I wasn't able to get to runlevel 1.)
    3. This article has a lot of good tips including Alt+SysReq+"Raising Skinny Elephants Is Utterly Boring" - http://www.linuxclues.com/articles/09.htm

  • How can I reboot?
    reboot or CTRL+ALT+DEL

Keeping Ubuntu time up to date

I would think Ubuntu would install something to keep the system clock from drifting, but it seems they haven't. There are at least 2 options: ntpdate and ntpd. Ntpdate is used from a cron script to sync the time once a day. Ntpd runs as a daemon and ajusts the time continually but it costs resources. On my machine, using ps -e -O rss | grep ntpd, I got 1.3 MB of memory use. Here is how to install ntpd:

sudo apt-get install ntp

The ntp config file is located at: /etc/ntp.conf

Reference: https://help.ubuntu.com/9.04/serverguide/C/NTP.html

My /etc/apt/sources.list

This sources.list includes security, updates, and proposed (but not backports) and source for the main, restricted, universe, and multiverse repositories.

deb http://archive.ubuntu.com/ubuntu/ jaunty main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ jaunty main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ jaunty-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ jaunty-security main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ jaunty-updates restricted main universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ jaunty-updates restricted main universe multiverse

deb http://archive.ubuntu.com/ubuntu/ jaunty-proposed restricted main multiverse universe
deb-src http://archive.ubuntu.com/ubuntu/ jaunty-proposed restricted main multiverse universe

My filesystem changes

  • For wmii:
    sudo ln -s /usr/include/freetype2/freetype /usr/include/freetype

System config file changes:

These changes apply to Ubuntu Karmic

  • Disable xsplash before session load: Comment out the following from /etc/gdm/PreSession/Default:
    if [ -x '/usr/bin/xsplash' ];
    then
            /usr/bin/xsplash --daemon
    fi
  • To run ~/.xsession from gdm: Create a '.desktop' file in '/usr/share/xsessions' [owned by root:root with permissions 644] whose 'Exec' entry is '/etc/X11/Xsession'.

How to show what you've installed with apt-get

Haven't found a way that I'm happy with yet. Here are some options:

  • sudo apt-get install apt-show-versions
    apt-show-versions
  • dpkg --get-selections
  • dpkg -l 
  • cat /var/log/dpkg.log | grep installed 

Sound troubleshooting

  • Make sure speakers are plugged in / power strip on. (For some reason, the power to my speakers keeps going out.
  • Run gnome-volume-control. Make sure volume is up and not muted. (For some reason on Karmic this resets to mute on restart.)

Skype microphone troubleshooting

Running Skype 2.1.0.47-1 on Ubuntu Karmic

  • Run gnome-volume-control. Select Microphone 1. Raise the volume up to almost Max.
  • (Testing can be done with gnome-sound-recorder.)

Flash

Emacs keybindings

Copy /usr/share/themes/Emacs/gtk-2.0-key/gtkrc to ~/.gtkrc-2.0. Edit as necessary.

(Hardware) System Information

sudo apt-get install sysinfo

custom xsession

Edit /usr/share/xsessions/user.desktop

[Desktop Entry]
Name=~/.xsession
Comment=User's .xsession
Exec=/etc/X11/Xsession
TryExec=/etc/X11/Xsession
Icon=
Type=Application

Can't create test file error

Trying to move datadir from /var/lib/mysql to /mnt/mysql-data on EC2

http://ubuntuforums.org/showthread.php?t=782224

Had to edit /etc/apparmor.d/usr.sbin.mysqld

Troubleshooting X freezes

Thinkpad W510 suspend

http://math.umons.ac.be/an/W510/#ACPI
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/522998
For Ubuntu 10.10:
/etc/pm/config.d/unload_modules
SUSPEND_MODULES="xhci_hcd"

Note: in 10.04, I had "xhci" instead of "xhci_hcd"

Cisco VPN

$ sudo apt-get install network-manager-vpnc 
  • Click on network manager icon in gnome-panel
  • VPN Connections -> Cofigure VPN...
  • Import
  • Select file from my company
  • Set user name
  • Apply
  • Close
  • Restart newtork-manager
    $ sudo /etc/init.d/network-manager restart 
    
  • Click on network manager icon in gnome-panel
  • VPN Connections -> My Company
  • Enter password
  • Done

VPN change to gain access to important stuff on our network

 - click network icon
 - "VPN Connections" > "Configure VPN..."
 - highlight "My Company VPN"
 - "Edit"
 - "IPv4 Settings" tab
 - "Routes..."
 - uncheck "Use this connection only for resources on its network"
 - "OK"
 - "Apply"
 - "Close"

When the above vpn setup didn't work with my Verizon mifi

...using vpnc from the command line worked: http://www.debuntu.org/how-to-connect-to-a-cisco-vpn-using-vpnc See also: http://www.chicagotech.net/routingissuesonvpn.htm.

/etc/vpnc/mycompany.conf:

IPSec gateway vpn.abc.mycompany.com
IPSec ID MyCompanyVPN
IPSec secret mygrouppassword
#IKE Authmode hybrid
Xauth username myusername

To use it, I run:

$ sudo vpnc mycompany 

To disconnect

$ sudo vpnc-disconnect 

vpnc: no response from target error

vpnc: no response from target

I added the following line to /etc/vpnc/mycompany.conf:

NAT Traversal Mode cisco-udp

Connection really slow and nothing happens: disabled encryption.

Debugging:

$ sudo vpnc --debug 2 --no-detach  mycompany 

Help:

$ man vpnc 

Prevent vpnc from periodically disconnecting due to timeout

See http://superuser.com/questions/309723/vpnc-it-keeps-disconnecting-after-24-minutes

Start vpnc with the --dpd-idle 0 option. e.g.:

$ sudo vpnc --debug 2 --dpd-idle 0 mycompany 

Set the timezone on a server

run as root

# dpkg-reconfigure tzdata 

Set the hostname on a server

run as root

# echo "plato" > /etc/hostname 
# hostname -F /etc/hostname 

Edit /etc/hosts:

127.0.0.1        localhost.localdomain    localhost
12.34.56.78      plato.example.com        plato

HTML messages in Claws Mail

  • Install extra plugins
    $ sudo apt-get install claws-mail-extra-plugins 
    
  • Load the Fancy HTML plugin
    Configuration -> Plugins.. -> Load... -> fancy.so
  • Configure preferences
    Configuration -> Preferences... -> Message View/Text Options, under "HTML messages", uncheck the first box and check the second and third boxes.
    Configuration -> Preferences... -> Plugins/Fance, check "Auto-Load images" and uncheck "Block external content"

How to set the folders for Sent, Drafts, and Trash

Ensure that all folders (e.g. "Sent Items", "Deleted Items") are available:

  • Configuration -> Preferences for current account... -> Receive
  • Uncheck "Show subscribed folders only"

Set the folders:

  • Configuration -> Preferences for current account... -> Advanced
  • Select the appropriate folders
  • OK

Set custom keyboard shortcuts for Claws Mail

You can also modify each menu shortcut by pressing any key(s) when focusing the mouse pointer on the item.

Change the location of the popup notification

http://askubuntu.com/questions/130124/how-can-i-make-notifications-appear-on-a-specific-monitor
$ sudo apt-get install dconf-tools 
$ dconf-editor & 

apps -> notify-osd. Change multihead-mode to "focus-follow"

How to suspend from the command line

http://manpages.ubuntu.com/manpages/precise/man8/pm-action.8.html
$ sudo pm-suspend 

Switching TTYs

The default TTY on Ubuntu is TTY7

How to determine which TTY you're currently on:

$ sudo fgconsole
7

How to switch to TTY1 from the command line

$ sudo chvt 1 

How to switch to TTY1 by pressing a key combo:

CTRL + LEFT ALT + F1

How to switch to TTY7 by pressing a key combo:

CTRL + LEFT ALT + F7

Install Claws Mail on Ubuntu 12.04

The claws-mail package included in Ubuntu 12.04 has a bug that doesn't allow you to click any buttons in one of the Filtering dialogs. See http://www.thewildbeast.co.uk/claws-mail/bugzilla/show_bug.cgi?id=2624. To fix, install the PPA from the Claws Mail team: https://launchpad.net/~claws-mail/+archive/ppa

$ sudo add-apt-repository ppa:claws-mail/ppa 
$ sudo apt-get update 
$ sudo apt-get install claws-mail 

That did not work. So install from source:

1. sudo apt-get build-dep claws-mail
2. download claws mail source
3. untar
4. ./configure --prefix=/home/saltycrane/lib/claws-mail-3.8.1
5. make
6. make install

That didn't work either.

To get filtering working, I copied the filtering rules file: ~/.claws-mail/matcherrc. Here is an example file:

[#imap/[email protected]@owa013.msoutlookonline.net/BP]
enabled rulename "Mark as read" all mark_as_read

[#imap/[email protected]@owa013.msoutlookonline.net/INBOX]
enabled rulename "Archive" age_greater 90 move "#imap/[email protected]@owa013.msoutlookonline.net/Archive/Inbox"

[#imap/[email protected]@owa013.msoutlookonline.net/Serverconfig]
enabled rulename "Archive" age_greater 90 move "#imap/[email protected]@owa013.msoutlookonline.net/Archive/Serverconfig"

[preglobal]

[postglobal]

[filtering]
disabled rulename "Test (copy to)" all copy "#imap/[email protected]@owa013.msoutlookonline.net/BP" set_tag "inbox"
enabled rulename "Serverconfig (copy to)" from matchcase "[email protected]" copy "#imap/[email protected]@owa013.msoutlookonline.net/Serverconfig"
enabled rulename "Jira (copy to)" from matchcase "[email protected]" copy "#imap/[email protected]@owa013.msoutlookonline.net/Jira"
enabled rulename "Confluence (copy to)" from matchcase "[email protected]" copy "#imap/[email protected]@owa013.msoutlookonline.net/Confluence"
enabled rulename "Jenkins (move to)" from matchcase "[email protected]" move "#imap/[email protected]@owa013.msoutlookonline.net/Jenkins"
disabled rulename "Mark non-inbox messages as read" ~tag matchcase "inbox" mark_as_read
enabled rulename "Build Announce" from matchcase "Build Annouce " move "#imap/[email protected]@owa013.msoutlookonline.net/Build Announce"
enabled rulename "Database builder" from matchcase "\"[email protected]\" " copy "#imap/[email protected]@owa013.msoutlookonline.net/Database builder"
enabled rulename "Daily News (copy to)" from matchcase "[email protected]" copy "#imap/[email protected]@owa013.msoutlookonline.net/Daily News"

Printer Settings from the command line Ubuntu 12.04

$ system-config-printer & 

Ref: http://askubuntu.com/questions/147019/how-can-i-learn-the-command-which-will-start-an-application-in-unitys-system-s

Settings from the command line Ubuntu 12.04

$ gnome-control-center & 

How to resize an image from the command line

Install imagemagick

$ sudo apt-get install imagemagick 

Resize an image

$ convert 2012-10-31_14-49-38_807.jpg -resize 50% 2012-10-31_14-49-38_807-halfsize.jpg 

How to determine what type of (wireless) network adapter (card) you have

Reference: http://ubuntuforums.org/showthread.php?t=1734728

$ sudo lshw -c network 

Network Tools

mtr - mtr combines the functionality of the traceroute and ping programs in a single network diagnostic tool.
ntop web based tool - ntop is the best tool to see network usage in a way similar to what top command does for processes i.e. it is network traffic monitoring software. You can see network status, protocol wise distribution of traffic for UDP, TCP, DNS, HTTP and other protocols.
nmap - scan your server for open ports.
iptraf
netstat
ss
traceroute

nvidia-settings 'BadValue (integer parameter out of range for operation)'

I got the following error when trying to use nvidia-settings after an apt-get dist-upgrade:

The program 'nvidia-settings' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadValue (integer parameter out of range for operation)'.
  (Details: serial 739 error_code 2 request_code 139 minor_code 25)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)

Googling told me that the new version of nvidia-settings was broken. dpkg told me that I had version 331 installed:

$ dpkg -l | grep nvidia 
ii  nvidia-304                             304.116-0ubuntu0.0.1                                NVIDIA binary Xorg driver, kernel module and VDPAU library
ii  nvidia-settings                        331.20-0ubuntu0.0.1                                 Tool for configuring the NVIDIA graphics driver

apt-cache told me there were 3 versions available:

$ apt-cache showpkg nvidia-settings | tail -5 
Provides: 
331.20-0ubuntu0.0.1 - 
304.88-0ubuntu0.0.2 - 
295.33-0ubuntu1 - 
Reverse Provides: 

I installed the 304 version and it worked:

$ sudo apt-get install nvidia-settings=304.88-0ubuntu0.0.2 

How to install a specific version of a package with apt-get and prevent it from being upgraded with apt-get update


Install specific version:

$ sudo apt-get install nvidia-settings=304.88-0ubuntu0.0.2 

Prevent it from being upgraded:

$ sudo apt-mark hold nvidia-settings 

Install emacs 24 on Ubuntu 12.04

http://askubuntu.com/questions/297170/how-to-install-emacs-24-3-on-ubuntu
$ sudo add-apt-repository ppa:cassou/emacs 
$ sudo apt-get update 
$ sudo apt-get install emacs24 

Control-Space doesn't work in Emacs in Ubuntu 14.04

http://askubuntu.com/questions/243639/ctrlspace-has-been-bound-to-invoke-some-input-method-and-does-not-work-in-ema
  • $ unity-control-center 
  • Go to Keyboard -> Shortcuts -> Typing
  • Remove Control+Space keybinding

List commands using ports

$ lsof -i :5001
COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
python  11851 eliot    3u  IPv4 845825      0t0  TCP *:5001 (LISTEN)

Cisco AnyConnect VPN

Install Openconnect:

$ sudo apt-get install openconnect 

Connect:

$ sudo openconnect vpn.mycompany.com 

How to disable the ALT and SUPER keys in Unity 15.04

$ sudo apt-get install compizconfig-settings-manager 
1. Desktop
2. Ubuntu Unity Plugin
3. General
4. Key to show the menu bar while pressed. <- Disable it.
5. Launcher
6. Key to show the Dash, Launcher and Help Overlay. <- Disable it.

Install Flash

http://askubuntu.com/questions/531672/how-to-install-flash-payer-in-ubuntu-14-04-lts

Comments