apt-get failed to fetch repository error solved.

For time immortal I have been searching to solve the error when I do apt-get update.

W: Failed to fetch http://archive.canonical.com/dists/rosa/partner/binary-i386/Packages 404 Not Found [IP: 2001:67c:1360:8c01::1b 80]

I searched the web for solutions, and I deleted this line and that line, but nothing happened. Until today, when I found the way out [link: https://forums.linuxmint.com/viewtopic.php?t=214358].

First I used the following command:

> inxi -r

Active apt sources in file: /etc/apt/sources.list.d/additional-repositories.list
 deb http://archive.canonical.com/ rosa partner 
 Active apt sources in file: /etc/apt/sources.list.d/google-chrome.list 
 deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main 
 Active apt sources in file: /etc/apt/sources.list.d/kubuntu-ppa-backports-trusty.list 
 deb http://ppa.launchpad.net/kubuntu-ppa/backports/ubuntu trusty main 
 deb-src http://ppa.launchpad.net/kubuntu-ppa/backports/ubuntu trusty main 
 Active apt sources in file: /etc/apt/sources.list.d/official-package-repositories.list 
 deb http://packages.linuxmint.com rosa main upstream import 
 deb http://extra.linuxmint.com rosa main 
 deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse 
 deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse 
 deb http://security.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse 
 deb http://archive.canonical.com/ubuntu/ trusty partner 
 Active apt sources in file: /etc/apt/sources.list.d/vikoadi-ppa-trusty.list 
 deb http://ppa.launchpad.net/vikoadi/ppa/ubuntu trusty main 
 deb-src http://ppa.launchpad.net/vikoadi/ppa/ubuntu trusty main

We can see the apt-get error occurred when fetching the archive.cannonical.com rosa partner repositories.

W: Failed to fetch http://archive.canonical.com/dists/rosa/partner/binary-i386/Packages 404 Not Found [IP: 2001:67c:1360:8c01::1b 80]

This repository is in the  /etc/apt/sources.list.d/additional-repositories.list file as we can see from the output of the inxi command.

We just delete this file or the specific line in the file and then if we do apt-get update. No errors!

 

 

#apt-get, #linux

Permission bits of directories

What does folder permission bits – rwx, mean?

x – search for files in a directory.

You can cd, but you cannot ls, however if you know the name of a file, you can access its metadata and its contents; if the permissions on the file allows. You can even write to existing files (if write permission bit is set for the file) within the directory, even when the directory itself does not have write permission.
Take the following example, I have a folder named foobar and in this there is a file named, newfile also note that Coder and Arjob are names of two user accounts that I use in this post.

arjob > chmod 771 foobar
Coder > ll foobar
ls: cannot open directory .: Permission denied
Coder > ll newfile
-rw-rw-r-- 1 arjob arjob 19 Jan 29 13:30 newfile

r – read folder for files and folders.

With read permission alone you can only view the files and sub-folders names inside the folder, but neither can you cd into file directory or can you read the contents of the files inside the directories.

arjob > chmod 774 foobar
Coder > cd foobar
bash: cd: foobar: Permission denied
Coder > ll foobar
ls: cannot access foobar/file: Permission denied
ls: cannot access foobar/newdir: Permission denied
ls: cannot access foobar/newfile: Permission denied
total 0
-????????? ? ? ? ? ? file
d????????? ? ? ? ? ? newdir/
-????????? ? ? ? ? ? newfile

with rx permission, we can cd into and access file metadata and its contents.

arjob > chmod 775 foobar
Coder > ll foobar
total 12
-rw-rw-rw- 1 arjob arjob 13 Jan 29 13:31 file
drwxrwxr-x 2 arjob arjob 4096 Jan 29 13:05 newdir/
-rw-rw-r-- 1 arjob arjob 19 Jan 29 13:30 newfile

this listing cannot be done with execute permission alone.

w – write to directory

What you cannot do with rx permission is to add new files, rename or delete files in the directory. These are permitted/denied using the write permission bit.

arjob > chmod 775 foobar
Coder > touch foobar/foofile
touch: cannot touch ‘foofile’: Permission denied

mv or rm will fail the same way.

arjob > chmod 777 foobar
Coder > touch foobar/foofile
Coder > ll foobar
total 12
-rw-rw-rw- 1 arjob arjob 14 Jan 29 13:59 file
-rw-rw-r-- 1 Coder Coder 0 Jan 29 14:10 foofile
drwxrwxr-x 2 arjob arjob 4096 Jan 29 13:05 newdir/
-rw-rw-r-- 1 arjob arjob 19 Jan 29 13:30 newfile

The bits it seams, work on the entity themselves. For folders, the bits does not trickle into the files, bit rather work on the Folder inode data.

  • execute(x) permission, grants us permission to search for files in the folder inode database.
  • read(r) permission, grants us permission to read the folder inode database. That’s is why we can ls, and read the filenames because they are all in the folder inode database. Where does file metadata resides, because I cannot read them with just the read permission??
  • write(w) permission, grants us permission to write into the folder inode database. Thus we can create new files, move and remove them, even if I do not have write permission on the files, themselves.
arjob > chmod 777 foobar
Coder > ll foobar
total 12
-rw-rw-rw- 1 arjob arjob 14 Jan 29 13:59 file
drwxrwxr-x 2 arjob arjob 4096 Jan 29 13:05 newdir/
-rw-rw---- 1 arjob arjob 19 Jan 29 13:30 newfile

Now, even though, Coder does not have any file permission he can still delete the file, because Coder has write permission on the folder.

Coder > rm newfile
rm: remove write-protected regular file ‘newfile’? y

Folder permissions are very important, cannot believe I didn’t knew what they meant until now.

#computer-science, #linux, #unix

How to group and its usefulness

I am in-fact talking about groups in Linux Operating System; just thought the title may be misleading to some.

I write this post to share a thing I learnt, from having to do something, as simple as, allowing another user, have read-write access to my files.  This is one of those things, that you will remember for rest of your life, but all you have to do, is to do it once..

I have two users in my computer, one named say User_A and another User_B. Now User_A owns a bunch of ‘Project’ Files that I would love to have access from User_B. User_A may give everyone a rw permission, but that would like firing a cannon to kill a bee. So what is the way.

I plan to take advantage of Groups. Every user in Linux can be part of multiple groups, so here’s what I planted to do:

  1. Create a new group named project_access. This group will have ownership of all the project files and folders that I want to share.
  2. I will assign the project_access group to those users, who I want to have access to the Project files.
  3. And give appropriate permission to the Project files and folders that will make the owner and thoes in the group to have rw, and everyone else, readonly access.

Now as the Project files are owned by User_a, all the following operations are done loged in as that user.

1. Create a new group:

We user the command groupadd.

> groupadd project_access

We can verify if indeed a group was created by viewing the /etc/group file, and searching for the group.

> cat /etc/group|grep project_access
project_access:x:1002:

This indicates that the group was created with an ID of 1002.

2. Add my existing users to the group:

The command in this case is usermod

> usermod -aG project_access user_a
> usermod -aG project_access user_b

The -aG means simply ‘Append Group’

Then I had to restart the computer. I checked if the commands worked by looking at the /etc/group file once again,

> cat /etc/group|grep project_access
project_access:x:1002:user_a,user_b

This shows that, now we have two users assigned to the group project_access.

3. Gave permissions to the Project files and folders:

> chmod 664 demo.py
> ll demo.py
-rw-rw-r-- 1 user_a user_a 24 Jan 28 21:07 demo.py

The 664 meanes that the owner, and users, in the same group as the file, will have rw access and everyone else has only reading permission.

I am showing this for one of the files in the project, so that the text remains clean on this blog.

All that is left to do now, is to change the group owner for the file. This is done using the command chgrp

> chgrp project_access ./demo.py
> ll demo.py
-rw-rw-r-- 1 user_a project_access 24 Jan 28 21:07 demo.py

And that is all done. My Project files are shared among the group.

However, there is a restriction, no one except the owner of file or folder can chmod on it. This is obvious, you do not want anyone in the group to chmod & make a file or folder private.


If you want to know more about the commands follow the links.


Side information:

  • How to change ‘mode bits’ of files recursively?
    chmod 664 `find /home/user_a/Projects -type f`
  • How to change ‘mode bits’ of directories recursively?
    chmod 754 `find /home/user_a/Projects -type d`

    664 permission will not work for directories, becasue dirctories need x permission which files dont. Thats the reason I had to do chmod for files and direcories separately. Why this is the case is because the permission bits has different meaning for directories

  • How to change owner group recursively?
    chgrp project_access `find /home/user_a/Projects`

    This command is same for files and directories, thats why we are specifing type as we did in case of chmod.

#computer-science, #linux, #unix

What does the hold off control in an oscilloscope do?

In order to play with the hold off feature, I have a micro-controller output following pulses.

It is a repeating pattern of 5 pulses and an idle period; you, of course can create whatever pattern you want, for your demonstration.

Example digital signal

The problem with this kind of sequence is that, the oscilloscope would not know which pulse to trigger on. In my case I have my ‘scope set to trigger on rising edges, but which one, there are 5! The oscilloscope may trigger on any of the 5 rising edges; and so it does. The oscilloscope is not be able to lock on to the signal and produces a runny display on the screen.

Solution on a DSO, may be is to do just a Single capture, but there is another way – HOLD-OFF.

If we can tell the oscilloscope to just delay the next capture, after the first, we could be able to have a stable display. Let’s see how.

Let us say we tell the oscilloscope to delay the second capture by 10 μs. So after the first trigger, at point, it would wait for 10 μs and trigger only after point . It would trigger again at the next rising edge, which is at point . As and are same points in the sequence, the process continues and we get a stable, locked display on the screen.

This 10 μs is the hold-off duration.

The hold-off time for this signal can be anywhere from points to , or from 7 to 15.8 μs – The last rising edge occurs at and the first of the next sequence occurs at .

Now, hold-off is not only applies to digital signals, it also comes very handy in analog signals as well, for example AM or other complex signals.

This is a rather short entry, but please point out the mistkaes and have fun learning.

#electronics, #oscilloscope

Curve tracer and component tester

Here is my implementation of a simple component tester, called the octopus.

I came to know about this from one of w2aews’ video in YouTube (https://www.youtube.com/watch?v=Gwo3pEH7hUE). I highly recommend his channel, wonderful stuff there.

You just connect channel 1 of the scope to the X terminal and channel 2 to the Y terminal of the circuit. Now set the scope to display in XY mode, and that’s it. You can now connect whatever device, a diode, capacitor, resistor, or even an IC to the Device under Test (DUT) terminal and you will see the voltage vs current characteristic curve on the scope. Here are some of my experiments.


Short circuit


When DUT terminal is open.


1N414 diode characteristics


BE junction of BC547 transistor. Notice the BE junction breakdown at about -11v.


Normal output pin of a 74LS14 IC


A damaged output pin in the same 74LS14


1K Resistor

To get the corresponding current for some voltage, you just measure the voltage on Y axis and divide it by the current sensing, R3 resistor value.

Workings

The R2 is a 10k potentiometer for current limiting. The R3 is current sensing resistor and the R1 is there to limit the current even when R2 is set to a low value.

The sine wave from the transformer is used to do a voltage sweep on the DUT, and you use the scope to see the response.
The probe at X measures the voltage across DUT, and the one at Y measures the voltage across the current sensing resistor R3.

Note: Because of the structure of this circuit, the current measured will be of opposite polarity as you would expect. So you need to invert the polarity of the channel 2 (Y) in the scope, or leave it as is and deal with it in your head.

I have used a fixed output transformer but a variable output one would be better.

When the DUT terminal is open, there is no current in the circuit and so Channel 2 (Y) will read 0 volts across R3, Channel 1 (X) however, will see the open circuit voltage across the DUT terminal. Therefore, you see only a horizontal line on the display.

Similarly, you will see a vertical line on the scope, when the DUT terminal is shorted.


My Implementation

My circuit

With max current of 57mA (R.M.S), the R1 resistor has to be 1W, instead I used 5, 1/2 W resistors in parallel, because I didn’t had any 1W 200\Omega resistors lying around, though if I had done my math correctly at the time I was soldering, I would have used 5, 1/4W 1k\Omega resistors for the task.

Please let me know your comments and question and have fun building it.

Basics: Capacitor charging

We are going to see what happens when we charge a capacitor and why it blocks DC.
I am not going to go into all the theory behind capacitor, but lets dig in to the experiment setup.

cap circuit

our circuit for this experiment.

In the beginning, when the switch S1 is open, lets assume the capacitor is discharged. (i.e. the plates of the capacitor have zero potential across them.)

We are probing the setup at
1. the input of the capacitor C1 and (channel 2)
2. across the resistor R1. (channel 1)
3. We are going to subtract the channel 1 from channel 2 to get the voltage across the capacitor in our Math channel of the scope.

cap_charging

So we know what our setup is. Lets wait no longer and press the switch, S1.
A surge of current equal to about V1/R1 starts to flow and we get v1 (here which is 5v) across the resistor R1; as if the capacitor is a short circuit! At this very point we can see in the Math channel that the voltage across the capacitor is indeed zero. (a signature of a short circuit.)

This current that is now flowing will decrease gradually as the capacitor gets charged, (i.e. the between the the two plates becomes equal to the source voltage (here that is 5v).

Now as the current decreases, charging the capacitor more and more, we see a the voltage across the resistor decrease at the same rate. The current this time becomes,

i(t) = {{(V1 - V_c(t))} \over{R1}}

Soon the capacitor will be fully charged, with the left plate at around 5v (we see it to be around 4.8v) and the right plate at zero, at this point very little current flows and therefore we get very little voltage across the resistor.

To find the time for this to happen, we use the capacitor charging equation.

V_c(t) = V_s(1-e^{-t/RC})

t = -ln((1 - {V_c(t) \over V_s})) \cdot RC

t = -ln((1 - {4.8 \over 5})) \cdot 1k \Omega \cdot 1 \mu F = 3.9{\mu}s.

Our experimental data checks out with our math. No further current will flow, until the capacitor gets discharged.

Hope you like this little, ‘back to the basics’ post. I am waiting to hear back from you.

#back-to-basics, #capacitor, #charging, #electronics

Complex number in A/C circuit analysis

I am going to do a series of posts and try explaining what impedance is and how to analyse a passive Low and High Pass filters. But for that we need to know what a complex number is and how to handle it. A complex number is in the format of A + Bj, where B is an imaginary number and A was real. That was the entire story I knew. Until recently, I didn’t know why it is necessary or what it represented. I will be going to great depth on this subject and begin with the absolute basics.

Graphical representation of a Complex Number

Let’s say we have a graph as shown in figure 1. 

We have three points, A = (0, 15), B = (10, 0) and another point Z. We defined Z as the sum of A and B. So what is the value of Z.? What point does it represent? That is simple:

Z = A + B = (0 + 10, 15 + 0) = (10, 15) .We just add the X values and Y values together and that’s the answer.

A complex number can also be thought of just a point in a graph. The Y axis is represents the imaginary numbers and X real.

For example the graph in figure 1, the point A is represents the imaginary part and point B the real part of a complex number. Therefore, that complex number must be B + Aj, or, 10 + 15j. And this complex number is what Z represents.

Another way of thinking is that all points in a graph represent some complex number. A point that lies on the Y axis is purely imaginary, and, that which lies on the X axis is purely real.

Thus A is a complex number, with no real part and B with no imaginary part. To find A + B we simply do a complex number addition.

Z = B + A = ( 10 + 0j ) + ( 0 + 15j ) = 10 + 15j.

Polar and Cartesian form of a complex number

We can represent a point on a graph either in polar or Cartesian (or rectangular) format. And because a complex number is thought as nothing more than just a point on a graph, we can represent a complex number in either of these forms.

In Cartesian format, we represent a complex number by the point on the graph it represents. For example in the figure 1, the point Z represents the point (10, 15). So its Cartesian form is Z = 10 + 15j.

In the polar format, we represent a complex by its distance from the centre and an angle. The distance from the origin, is, the magnitude of the complex number. The complex number can also be thought as a vector; with a magnitude and a direction.

The magnitude r = \sqrt[2]{{y^2} + {x^2}}

And the angle \phi = tan^{-1} (\frac{y}{x})

In the polar format we can demote Z with its magnitude and it’s angle, so Z = \sqrt[2]{{y^2} + {x^2}} \angle tan^{-1} (\frac{y}{x})

  1. Say we want to represent Z = 10 + 15j in polar format. This is in Cartesian format, so we know, that it denotes a point of (10,15) on the graph.

Z = \sqrt[2]{{15^2} + {10^2}} \angle tan^{-1} (\frac{15}{10})

\Rightarrow Z = 18 \angle 56.3^{ \circ}

  1. Take another example. Convert P = 15.5 – 10.5j in polar format.

    Again, we know that this complex number denotes the point (15.5 , 10.5) in a graph. So

    Z = \sqrt[2]{{15.5^2} + {10.5^2}} \angle tan^{-1} (\frac{-10.5}{15.5})

    \Rightarrow Z = 18.72 \angle -34.1^{ \circ}

We can convert a complex number in polar format to Cartesian format in the following way.

We know that the Cartesian format of a complex number is in the form

Z = x + yj.

From the basic trigonometry, cos \phi = \frac{x}{r} and sin \phi = \frac{y}{r}

\Rightarrow x=r.cos\phi and y = r.sin\phi

thus the Cartesian form of the complex number is

Z = r.cos\phi + r.sin\phi j

For example: A the Cartesian form of the complex number

Z=5.385 \angle68.2^{\circ} is Z = 5.385 * cos(68.2) + 5.385 * sin(68.2)j = 2 + 5j.

Multiplication, Division and Reciprocal of a complex number

Multiplication and division is easier when the complex number is represented in the polar format. For example:

Multiplication

We just multiply the scalar and add up the angles.

For example:

1. (18\angle90^{ \circ})(10\angle-45^{ \circ}) = 180\angle45^{ \circ}

2. (176\angle-320^{ \circ})(5\angle-10^{ \circ}) = 880\angle-330^{ \circ} or 880\angle30^{\circ}

Division

We divide the magnitude as usual, then to find the angle, we subtract the denominator from the numerator.

For example:

1. \frac{18\angle90^\circ}{10\angle-45^\circ} =1.8\angle45^\circ

Reciplocal

Reciprocal of a complex number is also easy to do, when the complex number is in the polar format. Just follow the division procedure, except the angle in numerator is zero.

1. \frac{1}{23\angle45^\circ}=\frac{1\angle0^\circ}{23\angle45^\circ}=0.043\angle-45^\circ

2. \frac{1}{15\angle-19^\circ}=\frac{1\angle0^\circ}{15\angle-19^\circ}=0.0667\angle19^\circ

That’s that.

In the next post, I will design a passive high pass and a low pass filter, and then you will see how important complex numbers are. It makes our lives a lot easier.

PS: I am not an expert in this, so please inform me, if I have done anything wrong, or something that you didn’t understand.


#back-to-basics, #electronics, #mathematics