Quick performance tip for Ubuntu Edgy and Feisty users

Quick performance tip for Ubuntu Edgy and Feisty users:

Edit your “/etc/hosts” file

sudo gedit /etc/hosts

You should see something like this

127.0.0.1 localhost

127.0.1.1 onlyubuntu

(and if your in Feisty, some lines about IPV6 also)

Now, add the following lines

127.0.0.1 localhost onlyubuntu

127.0.1.1 onlyubuntu

(Replace “onlyubuntu” with your hostname)

Save and exit the file.

Now your applications launch should improve.

Currently There are two bugs filed against this you can check

https://bugs.launchpad.net/ubuntu/+source/gnome-desktop/+bug/94048
https://bugs.launchpad.net/ubuntu/+source/gnome-session/+bug/26419

Setup PPTP on Ubuntu

Here is a quick howto on installing and setting up PPTP on Ubuntu.
Specifically I’ll be attempting to configure this machine to use the Israeli ISP 012 over a cable modem. 012 provides some sort of installation package for Linux but it doesn’t support Ubuntu.

Anyway- here are my steps:
xhost +
sudo su-
export DISPLAY=’:0′
echo ‘deb http://quozl.netrek.org/pptp/pptpconfig ./’ >> /etc/apt/sources.list
apt-get update
apt-get install pptp-linux
apt-get install pptpconfig
pptpconfig&
Use the server cablepns.012.net.il and the user/password provided by the ISP

Set the Cable connection to by your default route (All to Tunnel)

Select ‘usepeerdns’ enabled (Automatic)

Set the tunnel to reconnect if disconnected.
Use the following pppd options:

noipdefault noauth default-asyncmap noipx defaultroute hide-password nodetach maxfail 1 lcp-max-configure 6 linkname cable ipparam cable-pptp userpeerdns persist mtu 1460 mru 1460 noproxyarp noaccomp nobsdcomp nodeflate nopcomp user cable lcp-echo-interval 20 lcp-echo-failure 3

Click Add and Start
——————————————————–
Now if you don’t have a network connection which is very likely you will need your ubuntu cd and these files from the apt source we added:
http://quozl.us.netrek.org/pptp/pptpconfig/php-gtk-pcntl_1.0.0-2_i386.deb
http://quozl.us.netrek.org/pptp/pptpconfig/php-pcntl_4.3.8-2_i386.deb
http://quozl.us.netrek.org/pptp/pptpconfig/pptpconfig_20060821-0_all.deb

Instead of the ‘apt-get install pptpconfig’ step above do:
dpkg -i php-gtk-pcntl_1.0.0-2_i386.deb
dpkg -i php-pcntl_4.3.8-2_i386.deb
dpkg -i pptpconfig_20060821-0_all.deb

How to add Universe and Multiverse repository

By default, Ubuntu does not enable the Universe and Multiverse repositories. But they include some important programs and codecs, so it is highly recommended to activate them. There may also be non-Ubuntu sources that you might wish to add to your Ubuntu machine.

The repositories (of apt) are stored in a file called /etc/apt/sources.list

First you should create a backup of your existing sources.list file:
sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup

Next you edit the sources.list file with an editor like GEdit.
sudo gedit /etc/apt/sources.list

There is an incode documentation. Uncomment everything you need, especially the universe and multiverse repositories.

Save the file and run

#sudo apt-get update

Mount your widows Partitions and make it read/writable in ubuntu

Mount your widows Partitions and make it read/writable in ubuntu

Some of ubuntu users are running their ubuntu machine as dual boot with windows and if you want to access your windows partition data using this guide in a simple manner.

This tutorial will show you how to mount NTFS and FAT partitions in ubuntu

For mounting TFS we are going to use one small tool called NTFS-3G this is very powerfull and simple tool.

The NTFS-3G driver is an open source, freely available NTFS driver for Linux with read and write support. It provides safe and fast handling of the Windows XP, Windows Server 2003 and Windows 2000 file systems. Most POSIX file system operations are supported, with the notable exception of file ownership and access right changes.

You need to edit the sources.list file using the following command

sudo gedit /etc/apt/sources.list

and add the following repositories which is suitable for you

If you are running Ubuntu Dapper enter the following lines save and exit the file

deb http://givre.cabspace.com/ubuntu/ dapper main main-all
deb http://ntfs-3g.sitesweetsite.info/ubuntu/ dapper main main-all
deb http://flomertens.keo.in/ubuntu/ dapper main main-all

If you are running Ubuntu Edgy enter the following lines save and exit the file

deb http://givre.cabspace.com/ubuntu/ edgy main
deb http://ntfs-3g.sitesweetsite.info/ubuntu/ edgy main
deb http://flomertens.keo.in/ubuntu/ edgy main

Now you need to import th GPG key for these repositories using the any one of the following command

wget http://flomertens.keo.in/ubuntu/givre_key.asc -O- | sudo apt-key add –

wget http://givre.cabspace.com/ubuntu/givre_key.asc -O- | sudo apt-key add –

Now you need to update the source list using the following command

sudo apt-get update

Install ntfs-3g in Ubuntu

If you want to install ntfs-3g run the following command from your terminal

sudo apt-get install ntfs-3g

Configuring ntfs-3g

Now you need to use the following command to determine all the available partitions

sudo fdisk -l

Now you need to configure your NTFS partitions in /etc/fstab file before doing any changes in /etc/fstab file we will take a backup of this file using the following command (Highly Recommended)

sudo cp /etc/fstab /etc/fstab.bak

Now you need to create a directory where do you mount your windows partitions in this example i ma creating windows directory

sudo mkdir /media/windows

If you want to mount /dev/hda1 is your windows partition you need to enter the following line in /etc/fstab file

/dev/ /media/ ntfs-3g defaults,locale=en_US.utf8 0 0

You need to replace your partition and mount point with your details

Example

/dev/hda3 /media/windows ntfs-3g defaults,locale=en_US.utf8 0 0

save and exit the file

If you want to mount as read only you need to enter the following line in /etc/fstabfile

/dev/hda3 /media/windows ntfs-3g ro,locale=en_US.utf8,uid=1000 0 0

If You want to change your locale option you need to run the following command in a terminal to know which one is supported by your system.

locale -a

Now if you want these new chnages to take effect there are two options one is you can simply reboot your machine and the second one is without rebooting you need to run the following commands

To unmount

sudo umount -a

To Mount

sudo mount -a

If you want to know more available options for ntfs-3g check man page

If you want to mount and unmount Windows partitions (FAT) manually, and allow all users to read and write

Follow the same procedure to get the list of your windows partitions,create a directory where do you want to mount and you do the following command from your teminal replace /dev/hda3,/media/windows/ to your environment

sudo mount /dev/hda3 /media/windows/ -t vfat -o iocharset=utf8,umask=000

If you want to mount FAT partitions on boot-up to allow users to read and write use the following command in your /etc/fstab file you can see the above procedure how to take backup of fstab file before you do any changes

/dev/hda3 /media/windows vfat iocharset=utf8,umask=000 0 0

Enable WPA Wireless access point in Ubuntu Linux

Enable WPA Wireless access point in Ubuntu Linux

Procedure to enable WPA Wireless in Ubuntu

To update the source list run the following command

sudo apt-get

sudo apt-get install wpasupplicant

sudo apt-get install network-manager-gnome network-manager

sudo gedit /etc/network/interfaces

Comment out everything other than “lo” entries in that file and save the file

Create a file called /etc/default/wpasupplicant, add entry ENABLED=0 and save the file

sudo touch /etc/default/wpasupplicant

Reboot your system or use the following command

sudo /etc/init.d/dbus restart

Once you login back in to your machine you need to left-click the network manager icon in Gnome and select your wireless network It should prompts for password, type, etc and It will ask you to choose a password for your new “keyring”.

Creating a LAMP server with Ubuntu

Creating a LAMP server with Ubuntu

First off, I hate using the sudo command, so let’s become root

#sudo passwd root
enter your passwd
enter root passwd
enter root passwd

#su – root

Edit the apt-get resources file and remove the comments from
deb http://us.archive.ubuntu.com/ubuntu breezy main restricted
deb-src http://us.archive.ubuntu.com/ubuntu breezy main restricted
deb http://us.archive.ubuntu.com/ubuntu breezy universe
deb-src http://us.archive.ubuntu.com/ubuntu breezy universe

root@ubuntu:~# cd /etc/apt
root@ubuntu:/etc/apt# vi sources.list

Now update apt-get

root@ubuntu:/etc/apt# apt-get update

now let’s rock
root@ubuntu:/etc/apt# apt-get install apache2
root@ubuntu:/etc/apt# apt-get install php4
root@ubuntu:/etc/apt# apt-get install libapache2-mod-php4
root@ubuntu:/etc/apt# apt-get install mysql-server-4.1
root@ubuntu:/etc/apt# apt-get install php4-mysql
root@ubuntu:~# mysqladmin create
root@ubuntu:~# /etc/init.d/apache2 restart

—john

Install Adobe PDF Reader on Ubuntu

To install just Adobe Reader, open up a terminal window and type in the following command:

sudo apt-get install acroread

If you want to install Adobe Reader as well as the plug-in for Firefox, then use this line instead:

sudo apt-get install acroread mozilla-acroread acroread-plugins

If you are reading this in Firefox, you may want to restart Firefox for the plug-in to start working.

Add Open with gedit to the right click menu in Ubuntu

Add "Open with gedit" to the right click menu in Ubuntu

The file browser in Ubuntu provides the ability to run scripts on a selected file. These scripts can be used to do anything from opening a file to zipping or uploading, or anything that you can do from the command line.

To start off, we will need to open a terminal window and type in the following command, which will create a new script file in our nautilus scripts directory

gedit ~/.gnome2/nautilus-scripts/Open\ with\ gedit

Paste in the following script, found on the G-Scripts site, which is a great resource for finding scripts. (http://g-scripts.sourceforge.net/)

#!/bin/bash
#
# Nautilus script -> open gedit
#
# Owner : Largey Patrick from Switzerland
# patrick.largey@nazeman.org
# www.nazeman.org
#
# Licence : GNU GPL
#
# Copyright (C) Nazeman
#
# Ver. 0.9-1 Date: 16.02.2002
# Add multiple file open in the same windows
#
# Ver: 0.9 Date: 27.10.2001
# Initial release
#
# Dependence : Nautilus (of course)
# Gnome-utils (gdialog)
#
filesall=”"
while [ $# -gt 0 ]
do
files=`echo “$1” | sed ’s/ /\?/g’`
filesall=”$files $filesall”
shift
done
gedit $filesall&

Save and close the gedit window, and then execute the following command to make the script executable:

chmod u+x ~/.gnome2/nautilus-scripts/Open\ with\ gedit

Note that tab completion really helps here =)

Now when you right click a file, you will see the gedit as an option

root sudo

In Linux (and Unix in general), there is a superuser named root. The Windows analog of root is Administrator.
The superuser can do anything and everything, and thus doing daily work as the superuser can be dangerous.
You could type a command incorrectly and crash the system.
Ideally, you run as a user that has only the privileges needed for the task at hand. In some cases,
this is necessarily root, but most of the time it is a regular user.

By default, the root account is locked in Ubuntu. This means you cannot login as root or use su.
Instead, the installer will setup sudo to allow the user that is created during install to run all administrative commands.

This means that in the terminal you can use sudo for commands that require root privileges.
All programs in the menu will use a graphical sudo to prompt for a password. When sudo asks for a password,
it needs YOUR USER Password; this means that a root password is not needed.
Notes

*

The password is stored by default for 15 minutes. After that time, you will need to enter your password again.
*

Your password will not be shown on the screen as you type it, not even as a row of stars (******). It is going in, however!
*

To run the graphical configuration utilities with sudo, simply launch the application via the menu.
*

To run a program using sudo that normally is run as the user, such as gedit, press Alt+F2 and enter gksudo gedit.
*

For users of Kubuntu, use kdesu in replacement for gksudo.
*

Ubuntu 5.10 (Breezy Badger) users, go to Applications –> System Tools –> Run as different user.
*

To use sudo on the command line, preface the command with sudo, as below:

Example #1

sudo chown bob:bob /home/bob/*

Example #2

sudo /etc/init.d/networking restart

*

NEVER use sudo to start graphical programs. You should always use gksudo or kdesu to run such programs,
otherwise new login attempts may fail. If this happens and at login an error message reports:
"Unable to read ICE authority file", log in using the failsafe terminal and execute the command below
substituting user for your username.

rm /home/user/.{ICE,X}authority

*

To start a root shell (i.e. a command window where you can run root commands) use:

sudo -i

*

To login as another user (on the command line, use something like gdmflexiserver for a graphical login)

sudo -i -u username

Allowing other users to run sudo

To add a new user to sudo, open the Users and Groups tool from System –> Administration menu.
Then click on the user and then on properties. Choose the User Privileges tab. In the tab, find
Executing system administration tasks and check that.

/!\ In the terminal this would be: sudo adduser $user admin, where you replace $user with the name of the user.
Benefits of using sudo

The benefits of leaving root disabled by default include the following:

*

The installer has to ask fewer questions
*

Users don’t have to remember an extra password, which they are likely to forget
*

It avoids the "I can do anything" interactive login by default -you will be prompted for a password before
major changes can happen, which should make you think about the consequences of what you are doing.
*

Sudo adds a log entry of the command(s) run (In /var/log/auth.log). If you mess up, you can always go back
and see what commands were run. It is also nice for auditing.
*

Every cracker trying to brute-force their way into your box will know it has an account named root and
will try that first. What they don’t know is what the usernames of your other users are.
*

Allows easy transfer for admin rights, in a short term or long term period, by adding and removing users from groups,
while not compromising the root account.
*

sudo can be setup with a much more fine-grained security policy

Downsides of using sudo

Although for desktops the benefits of using sudo are great, there are possible issues which need to be noted:

*

Redirecting the output of commands run with sudo can catch new users out. For instance consider
sudo ls > /root/somefile will not work since it is the shell that tries to write to that file.
You can use ls | sudo tee -a /root/somefile to append, or ls | sudo tee /root/somefile to overwrite contents.
You could also pass the whole command to a shell process run under sudo to have the file written to with
root permissions, such as sudo bash -c "ls > /root/somefile".
*

In a lot of office environments the ONLY local user on a system is root. All other users are imported
using NSS techniques such as nss-ldap. To setup a workstation, or fix it, in the case of a network
failure where nss-ldap is broken, root is required. This tends to leave the system unusable unless cracked.
An extra local user, or an enabled root password is needed here.

Misconceptions

*

Isn’t sudo less secure than su?
o

The basic security model is the same, and therefore these two systems share their primary weaknesses.
Any user who uses su or sudo must be considered to be a privileged user. If that user’s account is compromised
by an attacker, the attacker can also gain root privileges the next time the user does so. The user account
is the weak link in this chain, and so must be protected with the same care as root.

On a more esoteric level, sudo provides some features which encourage different work habits, which can positively
impact the security of the system. sudo is commonly used to execute only a single command, while su is generally
used to open a shell and execute multiple commands. The sudo approach reduces the likelihood of a root shell being
left open indefinitely, and encourages the user to minimize their use of root privileges.
*

I won’t be able to enter single-user mode!
o

The sulogin program in Ubuntu is patched to handle the default case of a locked root password.
*

I can get a root shell from the console without entering a password!
o

Console users have access to the boot loader, and can gain administrative privileges in various ways
during the boot process. For example, by specifying an alternate init(8) program. Linux systems are not typically
configured to be secure at the console, and additional steps (for example, setting a root password, a boot loader
password and a BIOS password) are necessary in order to make them so. Note that console users usually have physical
access to the machine and so can manipulate it in other ways as well.

Going back to a traditional root account

This is not recommended!

Consider using the below command instead:

sudo -i

That will open up a root console temporarily. Enabling the root account in Ubuntu is neither supported nor necessary.
Anything you need to do as administrator of an Ubuntu system can be done via sudo or gksudo.

Drag & Drop Sudo

This is a trick from the [WWW] forums.

Create a launcher with the following command:

gksudo "gnome-open %u"

When you drag and drop any file on this launcher (it’s useful to put it on the desktop or on a panel), it
will be opened as root with its own associated application. This is helpful especially when you’re editing
config files owned by root, since they will be opened as read only by default with gedit, etc.