Thursday, 1 September 2016

Dealing with permissions in the fat 32 sd card in linux system

FAT filesystems really don't have permissions.

The way that linux handles this is that when you mount a FAT drive, all
the files are given the _same_ file permissions at mount time.
Furthermore, once mounted, these permissions can't be modified.

The default permissions that mount will use for FAT partitions is
"rwxr-xr-x". To change this, you can add an option "umask=" in the fstab
file. For example, on my computer, I use:

/dev/hda1       /mnt/c          vfat    defaults,umask=0000 0 0

The argument to umask is and octal number. To understand what this number
means, you have to understand how file permissions actually work in unix.

The way file permissions are stored on the disk is as a 9-bit binary
number. The best way to show this is with examples. File permission are
commonly represented in three ways:

rwxr-xr-x  - human readable
111101101  - binary number
7  5  5    - 3 octal numbers

The last one is the most important. If you read the manpage for chmod, you
will notice that you can specify the desired permissions using and octal
number. Examples:

gsteele@atlas:~$ chmod 0755  foo
gsteele@atlas:~$ ls -l foo
-rwxr-xr-x    1 gsteele  gsteele   1123166 Mar 27 11:42 foo*
gsteele@atlas:~$ chmod 0766  foo
gsteele@atlas:~$ ls -l foo
-rwxrw-rw-    1 gsteele  gsteele   1123166 Mar 27 11:42 foo*
gsteele@atlas:~$ chmod 0777  foo
gsteele@atlas:~$ ls -l foo
-rwxrwxrwx    1 gsteele  gsteele   1123166 Mar 27 11:42 foo*

(Note: the first number is related to "special file permissions". You
should always leave this number as 0. You can read about these here:

Now, umask is like the binary NOT of the file permissions you want. For

rwxr-xr-x  - desired file permissions
111101101  - binary file permissions
000010010  - umask
0  2  2    - octal umask

So, for example, in my fstab file, I use umask=0000, so that the
permissions on my dos drive are rwxrwxrwx. If you wanted the permissions
on the dos drive to be rwxrwxr-x, you would set umask=0002.

Extracted from

Wednesday, 31 August 2016

Process running in background

Keeping a process running after ending ssh session could be very useful.

The best way is often the simplest.
nohup long-running-command &
It was made specifically for this, it even logs stdout to nohup.log
man nohup
If you want to "background" some already running tasks, then your best bet is to ctrl+z then run
bg (this will background your most recent suspended task, allowing it to continue running)
then a quick disown should keep the process running after you log out.
screen and others can do it, but that's not what they're for. I recommend nohup for tasks you know your going to leave behind and bg for tasks your already running and don't want to re-start.
Keep in mind, both are bash specific. If you're not using bash, then the commands could be different.
Extracted from

Friday, 26 August 2016

Tip - place for scripts

* A place for putting common scripts (with execution permission) that must be available for all the system is

It can be called in any location.   

* Also,when trying to run commands or scripts on startup you can put the required command to run inside the file
~/.bashrc for a local command
/etc/bash.bashrc for a global command (for example a command that requires sudo). 

Both of the above commands will ask for the sudo passwork. If you do not put sudo, the script will not run if it requires administrative priviledges

You can also put a command that requires sudo inside your local .bashrc but you will be asked to put the sudo password everytime your start a command line or the .bashrc is processed (for example when running source ~/.bashrc)

* Also, to run an administrative command without having to put the admin password and that you want to be executed at the end of each multiuser runlevel, put your command in the file

Also, take into account that you do not need to put sudo, the execution of this file has already administrative priviledges .
Do not forget to finish the command by providing an exit value. 0 means sucess and any other value means error.
exit 0 
* For other related information, visit:

Friday, 19 August 2016

Setting static ip for your network card
 Edit the file /etc/network/interfaces and add this:

auto wlan0
iface wlan0 inet static

wpa-ssid 'mynetwork'
wpa-psk '12345'

In order for this to take effect the networking service must be restarted
$ sudo /etc/init.d/networking restart

For more info, look here->

Thursday, 18 August 2016

Computers in a network

Arp-scan can scan the computers in a network
* Using Wi-Fi:
sudo arp-scan -l --interface=wlan0
* Using ethernet:
sudo arp-scan -l --interface=eth0 
* Connection by usb 
sudo arp-scan -l --interface=usb0
Answer from system:
Interface: usb0, datalink type: EN10MB (Ethernet)
Starting arp-scan 1.8.1 with 256 hosts ( 02:00:86:9b:2a:ad (Unknown)

1 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.8.1: 256 hosts scanned in 1.289 seconds (198.60 hosts/sec). 1 responded

Thursday, 5 May 2016

Python Function Arguments

In contrast to many languages, python has several types of parameters to be sent to a function:
  • Required arguments
  • Keyword arguments
  • Default arguments
  • Variable-length arguments
A tutorial about that is here:

Tutorial to work with Python and Opencv

Complete tutorial.