Easy file sharing with Python SimpleHTTPServer

An easy way to share files from your computer is to use Python SimpleHTTPServer. You don’t need to know Python programming to use the SimpleHTTPServer, the only requirement is to have Python installed on the machine where the files that needs to be shared are located.

Most Linux distributions are shipped with Python installed by default, but for Windows you might need to check how to use Python on Windows.

To start the SimpleHTTPServer “cd” into the directory which you want to be shared and run the command:

python -m SimpleHTTPServer 8000

You need to specify a port, usually 8000, like in the example should be just fine.
To access the shared files o to http://your_ip_address:8000.

Understanding file permissions and ownership on Linux

The files on a Linux system can have reading permissions, writing permissions, executing (running) permissions or no permissions for the user that owns that files, groups of users or the rest – users who does not own that files and they are not members of any group.

The usual file types are:

  • Directory – associated symbol d
  • Normal file – associated symbol (minus, dash)
  • Symbolic link (symlink) (like a shortcut on Windows) – associated symbol l

Permission types:

  • Reading – associated symbol r, or number 4
  • Writing – associated symbol w, or number 2
  • Executing (running) – associated symbol x, or number 1
  • No permission – associated symbol , or number 0

If a file has the reading permission you can open the file and read it, but you can not change the content. If a directory has the reading permission you can read the files in that directory, but you are not allowed to change their content.

If a file has the writing permission you can open the file for reading and for writing (you can change the file’s content and save it with the new content). You can not delete or rename a file unless the directory has the writing permission.

The execution permission allows the user to execute (run) the file (like a shell script).

User types:

  • User – the user name of the owner of the file or directory; if a user creates a file or directory it becomes the owner of that file of directory.
  • Group – a group of users (ftp, mysql), all group members have the same rights for the file or directory.
  • Other – all users that do not own the file or directory and they do not belong to any group that has right for the file or directory.

Setting permissions:

You can set the permissions using the chmod command. There two methods for changing file permissions:

  • Symbolic mode
  • Numeric mode

Symbolic mode

Setting the permissions is made using the associated symbols – rwx.

Actions are defined using mathematical symbols: the + (plus) symbol is used to add a permission, the – (minus) symbol is used to remove a permission, and the = (equal) symbol is used to remove the old permission and set a new one.

For the owners, associated symbols are u for user, g for group, o for others (the rest) and a for all.

To make a file executable type in a console:

chmod +x myfile

To remove the write permissions of the group:

chmod g-w myfile

Numeric mode

Instead of symbols, the associated number are used for setting permissions. The number for each owner will be the sum of the permissions for that owner.

To set the reading, writing and execution rights for the user you use the number 7 (4+2+1); to set the reading and writing rights for group will you use the number 6 (4+2); the reading permission for the rest (others) will be set using number 4.

The command for setting the permissions in numeric mode:

chmod 764 myfile

Here is the association between numbers and letters:

0  |  ---
1  |  --x
2  |  -w-
3  |  -wx
4  |  r--
5  |  r-x
6  |  rw-
7  |  rwx

Changing the owner:

It is done using the command chown.

To change the owner:

chown myusername myfile

To change the group and the owner:

chown mygroup:myowner myfile

To change only the group you use the command chgrp:

chgrp group myfile

Video tutorial

Check also a video tutorial about Unix File Permissions and Ownership (CHOWN, CHMOD, ETC) via Irongeek.com:

References:
TLDP.org
TUXfiles.org

Take screenshot from command line

Take a screenshot of your desktop using the SCROT utility.

Basic usage is to call the scrot command in a console, but this would take an instant screenshot of the desktop in the current directory. Thus it would be better used along with the “-d” (delay) option in order to have a time buffer to place the desired objects on the desktop.

Fix NetBeans big fonts on Ubuntu

There is a rather annoying issue related with NetBeans displaying large fonts on Ubuntu for menus and panels. There are some suggestions on Ubuntu forums related with java fonts settings, but there are a couple of better solutions which may improve the way NetBeans looks on Ubuntu when it comes to font size.

The default Netbeans look and feel on Ubuntu looks like this:

NetBeans default look and Feel on Ubuntu

The integration with the default theme is great, except for the large fonts.

Lower the application font

The first solution consist in lowering the font used for applications. By default Ubuntu is using for applications the Ubuntu font family with a size of 11. Go to the “Fonts” tab on “Appearance Preferences” window (right-click on Desktop, select “Change Desktop Background”) and set the “Application” font (highlighted in below image) to 10.

Appearance Preferences

The fonts should be better now in NetBeans, but the downside is that all your applications’ fonts will be smaller. If you can live with that, great! If not, here goes another solution.

Use the Nimbus look and feel

The second solution is using the java Nimbus look and feel. Nimbus may be best described as a skin for java applications, thus this tip applies not only to NetBeans, but to other java applications as well.

In order to specify the look and feel, edit the “netbeans.conf” file (usually the file is placed in “<netbeans_installation_directory>/etc/”), find the “netbeans_default_options” option and insert the following values right before the last quote:

 --laf Nimbus -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd

With the Nimbus skin, Netbeans should look likw this:

Nimbus look and feel tip thanks to Geertjan’s Blog