Ubuntu : Useful Commands

1. Set commands at terminal startup on ubuntu

export PATH=$PATH:/home/me/play

to your ~/.bashrc.

restart terminal (ctrl+alt+T)

2. Installing Wine 1.6 on Ubuntu 12.04 LTS

0. sudo apt-get build-dep wine
1. Download wine_1.6.tar.bz2
2. tar jxvf wine_1.6.tar.bz2
3. cd wine_1.6/tools/
4. ./wineinstall
5. type 'yes' for sudo root permission
To run .exe files -
$wine <file-name>.exe

3. Creating startup USB from Ubuntu

usb-creator-gtk -i ubuntu-12.10-desktop-i386.iso

4. Brightness problem in Ubuntu 12.04 64-bit

xrandr --output LVDS1 --brightness 0.5

5. Determine destination location of apt-get install <package>
You can run the command dpkg -L package to list all the files in the package. For example dpkg -L ubuntu-minimal will only list a couple of small files related to packaging, as it is only an empty meta-package that depends on other packages.

dpkg -L tomcat7

is probably what you want.

6. set what application to use to open a file based upon it’s extension on Ubuntu.

You can use mimeopen to set what application to use to open a file based upon it’s extension.

Run mimeopen followed by the file extension you want to change. For example, if I wanted to open .py (python) files in Geany instead of Gedit I would run:

mimeopen .py

Which returns (on my system, this will depend slightly based on what software you have installed on your computer):

Please choose a default application for files of type text/x-python

1) Geany (geany)
2) notepad (wine-extension-txt)
3) gedit (gedit)
4) LibreOffice 4.0 Writer (libreoffice4.0-writer)
5) Other...

use application #

Inputting 1 and pressing Enter will open a blank .py file in Geany and set all further .py files to open in that editor.

If I put in 5 and press Enter I get the prompt:

use command:

In which case I can use a program’s command to open whatever file type I am currently changing.

So I could have done:

mimeopen .py

Used 5 and put geany as the command to get the same result:

You might notice that if you run mimeopen .py again it will open a new .py file in Geany (or whatever app you chose) instead of asking you what application to use. In that case you need to use the -a handle, like this:

mimeopen -a .py

7. How to check if open ports for remote system(ubuntu)

[user@lappie ~]$ nmap host

Starting Nmap 5.21 ( <a href="http://nmap.org">http://nmap.org</a> ) at 2010-10-07 11:25 CEST
Nmap scan report for host (ip.adr.tld)
Host is up (0.0052s latency).
rDNS record for ip.adr.tld : host.domain.tld
Not shown: 995 closed ports
22/tcp open ssh
80/tcp open http
111/tcp open rpcbind
3000/tcp open ppp
5666/tcp open nrpe

Nmap done: 1 IP address (1 host up) scanned in 0.18 seconds

8. Installing flareget on Ubuntu with firefox integration

1. Download flareget from

2. untar and dpkg -i flarget _1.5-12_i386.deb
3. Install flashgot plugin from addon section of firefox
4. add flareget as the default download manager (if not already selected)

9. How to create and extract zip, tar, tar.gz and tar.bz2 files in Linux

To compress a directory with zip do the following:

# zip -r archive_name.zip directory_to_compress

Here’s how you extract a zip archive:

# unzip archive_name.zip


tar -cvf archive_name.tar directory_to_compress

And to extract the archive:

# tar -xvf archive_name.tar.gz
# tar -xvf archive_name.tar -C /tmp/extract_here/


To compress a directory use the following syntax:

# tar -zcvf archive_name.tar.gz directory_to_compress

To decompress an archive use the following syntax:

# tar -zxvf archive_name.tar.gz
# tar -zxvf archive_name.tar.gz -C /tmp/extract_here/


Here’s how you compress a directory using tar.bz2:

# tar -jcvf archive_name.tar.bz2 directory_to_compress

To extract the files to a different directory use:

# tar -jxvf archive_name.tar.bz2 -C /tmp/extract_here/

10. Resume a large scp transfer

If you need to resume an scp transfer, try with rsync:

rsync --partial --progress --rsh=ssh user@host:remote_file local_file

11. copy directory tree:

mkdir -p /copy/this/directory/tree

12. change ownership of subdirectories and files:

chown -hR username directory/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s