Archive for the ‘ubuntu’ Category

FOSSwire has a great reference sheet for Ubuntu.

Original article.

Updated for 8.04


sudo command – run command as root
sudo su – open a root shell
sudo su user – open a shell as user
sudo -k – forget sudo passwords
gksudo command – visual sudo dialog (GNOME)
kdesudo command – visual sudo dialog (KDE)
sudo visudo – edit /etc/sudoers
gksudo nautilus – root file manager (GNOME)
kdesudo konqueror – root file manager (KDE)
passwd – change your password


sudo /etc/init.d/gdm restart – restart X (GNOME)
sudo /etc/init.d/kdm restart – restart X (KDE)
(file) /etc/X11/xorg.conf – display configuration
sudo dpkg-reconfigure -phigh xserver-xorg – reset X configuration
Ctrl+Alt+Bksp – restart X display if frozen
Ctrl+Alt+FN – switch to tty N
Ctrl+Alt+F7 – switch back to X display

System Services¹

start service – start job service (Upstart)
stop service – stop job service (Upstart)
status service – check if service is running (Upstart)
/etc/init.d/service start – start service (SysV)
/etc/init.d/service stop – stop service (SysV)
/etc/init.d/service status – check service (SysV)
/etc/init.d/service restart – restart service (SysV)
runlevel – get current runlevel
Package Management¹
apt-get update – refresh available updates
apt-get upgrade – upgrade all packages
apt-get dist-upgrade – upgrade Ubuntu version
apt-get install pkg – install pkg
apt-get remove pkg – uninstall pkg
apt-get autoremove – remove obsolete packages
apt-get -f install – try to fix broken packages
dpkg –configure -a – try to fix broken packages
dpkg -i pkg.deb – install file pkg.deb
(file) /etc/apt/sources.list – APT repository list
ifconfig – show network information
iwconfig – show wireless information
sudo iwlist scan – scan for wireless networks
sudo /etc/init.d/networking restart – reset network
(file) /etc/network/interfaces – manual configuration
ifup interface – bring interface online
ifdown interface – disable interface
Special Packages
ubuntu-desktop – standard Ubuntu environment
kubuntu-desktop – KDE desktop
xubuntu-desktop – XFCE desktop
ubuntu-minimal – core Ubuntu utilities
ubuntu-standard – standard Ubuntu utilities
ubuntu-restricted-extras – non-free, but useful
kubuntu-restricted-extras – KDE of the above
xubuntu-restricted-extras – XFCE of the above
build-essential – packages used to compile programs
linux-image-generic – latest generic kernel image
linux-headers-generic – latest build headers
ufw enable – turn on the firewall
ufw disable – turn off the firewall
ufw default allow – allow all connections by default
ufw default deny – drop all connections by default
ufw status – current status and rules
ufw allow port – allow traffic on port
ufw deny port – block port
ufw deny from ip – block ip adress
Application Names
nautilus – file manager (GNOME)
dolphin – file manager (KDE)
konqueror – web browser/filemanager (KDE)
kate – text editor (KDE)
gedit – text editor (GNOME)


Recovery – Type the phrase “REISUB” while
holding down Alt and SysRq (PrintScrn) with
about 1 second between each letter. Your system
will reboot.

lsb_release -a – get Ubuntu version
uname -r – get kernel version
uname -a – get all kernel information



Copy your eth0 config file located at /etc/sysconfig/network-scripts/
(you need to be root to do most of these commands)

cd /etc/sysconfig/network-scripts/
cp eth0 eth0:1

Now we need to edit this new file. You will need to …escape.. the colon. Neither eth0 or eth0:1 can be set by DHCP, you must setup a static address. The “HWADDR=” needs to be deleted from eth0:1 since it is the same physical device as eth0.

vi eth0\:1

Now you should be able to issue the ifup <device> command to bring up the virtual device and confirm with an ifconfig.

ifup eth0:1




This was copied from the Johnny Chadda blog.



When you are out traveling or just at work, the need sometimes arises when you have to access your computer at home. This article will show you how to access your computer in a simple and secure way. The article is focused on Ubuntu, but can just as well be used with the remote desktop features of Windows XP.

We first of all want to create a secure channel between your current computer and your machine at home, and what better tool for the job than OpenSSH. In Ubuntu, you may install the SSH server by installing the packet called “openssh-server” like so:

sudo apt-get install openssh-server

This will enable remote connections into your computer on port 22, which is the standard SSH port. If your computer sits behind a router, you must forward the port to the computer from the router.

The next step is to enable the remote desktop facilities of the Gnome desktop in Ubuntu, by opening the “System” menu, “Preferences” and then selecting “Remote desktop”. You will be presented with a dialog like the following:

The options are self-explanatory, and since you will be connecting to it when you yourself are not around, be sure to untick “Ask you for confirmation”. This will start the VNC server at port 5900, which you should not expose to the internet. Instead, here is where SSH comes into play.

The primary purpose of SSH is to allow secure text-based remote management capabilities to servers. It can however tunnel arbitrary traffic over it too, and VNC traffic is of course not an exception. The endpoint should be to be able to connect to port 5900 which runs the VNC server, so we need to tell SSH to create a tunnel from the current computer to the home computer and then on to the VNC server. Let’s select port 50000 for the start of the tunnel, but it can be any free port between 1024 and 65535. If you are fortunate enough to be running Linux on your work computer, connect to your home computer using the following command:

ssh -l username -L 50000:localhost:5900 your.home.pc

Let’s take a minute to analyze this command. You issue the ssh command, and -l lets you specify which user-name to connect as. -L is the magic part where we specify endpoints of our SSH tunnel. The tunnel starts at port 50000 of the local computer, then travels to the SSH server on the other side. It then looks at the endpoint which is localhost port 5900, which happens to be the VNC server! The last part is to specify a host-name or IP-address to your home computer. It can of course also be done in Windows using the popular PuTTY terminal:



On the first screenshot we specify which host to connect to, and the tunnel is set using the tunnel settings. The screenshots should be self-explanatory. Just don’t forget to click the add button to actually enable the tunnel.

After logging into the server either using a Linux or Windows machine, the time has come to actually try this out by connecting a VNC client to the server. Ubuntu users have a VNC client installed under “Applications” – “Internet” – “Terminal Server Client”, and Window users may for example download UltraVNC viewer. If you don’t want to install anything, choose the “Ultr@VNC Standalone Viewer” package, which only contains a zipped viewer.

To connect, we only need to specify the start of the SSH tunnel and it should take the data to its destination automatically.


Connect to localhost port 50000 like we specified for the start of the tunnel earlier. Notice the extra colon – we need to write this way since we are not connecting to a particular display. Remember to set the quick options in UltraVNC to “MEDIUM” if you have slow connection to make the interface relatively snappy and useful.

Click connect, and if everything works you should be prompted for the password you specified when configuring the VNC server earlier.

The SSH tunnel can of course also be used to secure Windows Remote Desktop access. It uses port 3389 by default and you might not have an SSH server running on a Windows client, but perhaps you have another Linux machine on your network? In that case, you can connect to the Linux server using SSH and set the endpoint of the tunnel to your Windows client. The following is an example in the Linux SSH notation:

ssh -l username -L 50000: my.home.linux.server.pc

It works just like before, but instead of just looping the connection to localhost, it will forward the connection to port 5900 on your network, and if that happens to be your Windows client you should be able to connect.

Most howto’s and screencasts about Ruby on Rails deployment using Capistrano are a little confusing now that 2.0 has come out.

Build a Full Rails Server on Ubuntu

To run the old version

cap _1.4.1_ <command>

More to come on this….

A video I found to help set up Samba.

This is partially reprinted from the Ubuntu community documentaion

Format the Partition via Command Line

To format the disk as ext3 filesystem (best for use under Ubuntu):

sudo mke2fs -j /dev/hdd1

Substitute “/dev/hdd1” with your own drive’s path.


Modify reserved space (optional)

When formatting the drive, 5% of the drive’s total space is reserved for the super-user (Root) so that the operating system can still write to the disk even if it is full. However, for disks that only contain data, this is not necessary.

You can ajust the percentage of reserved space with the “tune2fs” command, like this:

sudo tune2fs -m 1 /dev/hdd1

This example reserves 1% of space – change this number if you wish.

Using this command does not change any existing data on the drive. You can use it on a drive which already contains data.


Mount the Drive

You can choose to have the drive mounted automatically each time you boot the computer, or manually only when you need to use it.

Automatic Mount at Boot

You’ll need to edit /etc/fstab:

gksudo gedit /etc/fstab

Add this line to the end:

/dev/hdd1 /media/mynewdrive ext3 defaults 0 2

The “2” at the end instructs your system to run a quick file system check on the hard drive at every boot. Changing it to “0” will skip this. Run ‘man fstab’ for more info here.
You can now run “sudo mount -a” (or reboot the computer) to have the changes take effect.

If you want to allow a normal user to create files on this drive, you can either give this user ownership of the top directory of the drive filesystem: (replace USERNAME with the username)

sudo chown -R USERNAME:USERNAME /media/mynewdrive

or in a more flexible way, practical if you have several users, allow for instance the users in the plugdev group (usually those who are meant to be able to mount removable disks, desktop users) to create files and sub-directories on the disk:

sudo chgrp plugdev /media/mynewdrive
sudo chmod g+w /media/mynewdrive
sudo chmod +t /media/mynewdrive

The last “chmod +t” adds the sticky bit, so that people can only delete their own files and sub-directories in a directory, even if they have write permissions to it (see man chmod).

Manually Mount

Alternatively, you may want to manually mount the drive every time you need it.

For manual mounting, use the following command:

sudo mount /dev/hdd1 /media/mynewdrive

When you are finished with the drive, you can unmount it using:

sudo umount /media/mynewdrive

Name-Based Virtual Hosts

With name-based virtual hosts, one instance of Apache hosts several domains. You do not need to set up multiple IPs for a machine. This is the easiest, preferred alternative. Reasons against the use of name-based virtual hosts are covered in the Apache documentation.

Configure it directly by way of the configuration file /etc/apache2/ sites-available/filename(by default we have default name file take this as reference and create new file). To activate name-based virtual hosts, specify a suitable directive. NameVirtualHost *. * is sufficient to prompt Apache to accept all incoming requests. Subsequently, configure the individual hosts:

ServerName http://www.example.com
DocumentRoot /home/www/htdocs/example.com
ServerAdmin webmaster@example.com
ErrorLog /var/log/apache2/www.example.com-error_log
CustomLog /var/log/apache2/www.example.com-access_log common

ServerName http://www.myothercompany.com
DocumentRoot /home/www/htdocs/myothercompany.com
ServerAdmin webmaster@myothercompany.com
ErrorLog /var/log/apache2/www.myothercompany.com-error_log
CustomLog /var/log/apache2/www.myothercompany.com-access_log common

A VirtualHost entry must also be configured for the domain originally hosted on the server (www.example.com). In this example, the original domain and one additional domain (www.myothercompany.com) are hosted on the same server.

Just as in NameVirtualHost, a * is used in the VirtualHost directives. Apache uses the host field in the HTTP header to connect the request to the virtual host. The request is forwarded to the virtual host whose ServerName matches the host name specified in this field.

For the directives ErrorLog and CustomLog, the log files do not need to contain the domain name. Here, use a name of your choice.

ServerAdmin designates the e-mail address of the responsible person that can be contacted if problems arise. In the event of errors, Apache gives this address in the error messages it sends to clients.


In Apache2 to configure virtual hosts there are two important files i.e

/etc/apache2/sites-available and /etc/apache2/sites-enabled/

We need to create symlink between these two folders for each virtual host or you can use a2ensite and a2dissite


This Will create the correct symlinks in sites-enabled to allow the site configured in sitefilename to be served


This Will remove the symlinks from sites-enabled so that the site configured in sitefilename will not be served