Wikipedia:Reference desk/Archives/Computing/2012 May 17

= May 17 =

Linux chown mistake
There was an error in a  bash script I wrote that accidentally  'd to the base of the filesystem (/) and changed the ownership of all the files at / as well as all files in each of the directories at / (but no deeper) to my user account. To correct this, I immediately re- ed all those files to root:root. I then went to the /home directory and corrected the obvious mis-match in ownership there, but I'm concerned that overwriting the ownership of all files /*/* to root may create some problems.... How much damage have I done? Are there certain files at the base of the filesystem and one level deeper that shouldn't be owned by root (other than obviously the directories inside the home file)? Is there a tool to verify correct ownership of system files? Thank you for any help or suggestions. I'm running Ubuntu 12.04.--el Aprel (facta-facienda) 00:32, 17 May 2012 (UTC)


 * As to how much damage: a bit. Most, but not all, stuff in the system directories is owned by root, but some is owned by special users for specific daemons. But worse, you've destroyed group-id info, which is more widely used to allow such semi-privileged processes access to sensitive stuff.  I wrote a little script to scan a healthy 12.04 install and count the number of unique user and group ids in different system directories:

/usr 204690 items, 3 uids, 17 gids /etc 3190 items, 1 uids, 9 gids /bin 155 items, 1 uids, 1 gids /sbin 182 items, 1 uids, 2 gids /opt 13102 items, 2 uids, 2 gids /lib 9750 items, 1 uids, 1 gids /boot 224 items, 1 uids, 1 gids /sys 21491 items, 2 uids, 2 gids /var 11475 items, 13 uids, 20 gids


 * For example, in my /usr there are filesystem objects with the follow groups: root utempter mail utmp messagebus games libuuid dip staff lpadmin tty daemon wireshark shadow ssh mlocate crontab


 * As to the fix: RPM based systems have an option to get the package manger to restore the ownership and permission info on installed files, but I don't know of an option for APT based systems like Ubuntu to do so. This question has someone writing much of that functionality (by interrogating dpkg to get the list of installed packages and the perms of each file therein, and then setting it) - but even that isn't complete, as packages have pre- and post-install hooks, which can quite reasonably set permissions. -- Finlay McWalterჷTalk 09:43, 17 May 2012 (UTC)


 * Thank you, Finlay, for the explanation. I'm not that attached to my system, so I don't really mind reinstalling (after backing up /etc and /home, of course), but before I do, since you already have the script, would you mind checking the different uids and gids of only files at /* and /*/* ? My reckless bashing only made it one level deep, so for example my /usr dir got chown'd as well as every file and directory inside /usr, but files inside directories in /usr, say /usr/bin/something, were untouched.--el Aprel (facta-facienda) 18:21, 17 May 2012 (UTC)
 * Reinstalling is really overkill for this. I've posted my non-root, non-/home ownerships on your talk page. --Sean 21:00, 17 May 2012 (UTC)
 * Ah, thank you, Sean. This was a very helpful list. I have used it to restore the correct ownerships. I'd also like to point out (should anyone with a similar problem come across this thread) that ing files also unsets the setuid bit. Below are the files with the setuid bit set on a Debian installation on my other box. Can anyone confirm that these are the only files one level deep (/*/*) with +s perms in Ubuntu?   immediately came to my mind, but it's an extra level deep in my Ubuntu installation at /usr/bin/sudo, so its setuid permission wasn't touched by my erroneous script.

/bin -rwsr-xr-x 1 root root 68316 Jan 25  2011 mount -rwsr-xr-x 1 root root 31360 Oct 14  2010 ping -rwsr-xr-x 1 root root 35252 Oct 14  2010 ping6 -rwsr-xr-x 1 root root 29152 Feb 15  2011 su -rwsr-xr-x 1 root root  47304 Jan 25  2011 umount /sbin -rwsr-xr-x 1 root root   80600 Dec 30 13:03 mount.nfs /usr drwxrwsr-x 10 root     staff         4096 Jan 31 20:00 local /var drwxrwsr-x 2 root staff 4096 Jan 22 16:05 local drwxrwsr-x 2 root mail  4096 Apr  8 13:47 mail
 * Also, I noticed that in Debian, the group of /usr/local is staff, but it wasn't on Sean's list of non-root:root files for Ubuntu. Is that correct?--el Aprel (facta-facienda) 02:01, 18 May 2012 (UTC)
 * Correct about /usr/local. I ran 'sudo find / -maxdepth 2 -perm /7000 -ls' and got this:


 * --80.112.182.190 (talk) 13:05, 18 May 2012 (UTC)


 * Thanks, 80.112! I have now restored those other perms on my files. Thanks again everyone for your help.--el Aprel (facta-facienda) 02:43, 20 May 2012 (UTC)

password
were do i find out what my password is to connect to amazon.com on my kindle. i had one years ago and it will not let me connect — Preceding unsigned comment added by 139.55.249.179 (talk) 00:55, 17 May 2012 (UTC)


 * You may need to get Kindle Support to reset it for you. -- Finlay McWalterჷTalk 10:13, 17 May 2012 (UTC)


 * You can also log into amazon with that username/password to see if it's actually correct. RMoD (talk) 23:06, 23 May 2012 (UTC)

555 astable circuit has slightly longer first 'on'. Why?
I made this circuit: and as you can see in the video (if it works), the first 'on' of the LED is longer than the rest. This always happens. Why? Peter Michner (talk) 01:30, 17 May 2012 (UTC)
 * Could it be because TRIG trips at 1/3 Vcc, not 0v, but the 1st interval starts at 0v? Vespine (talk) 04:06, 17 May 2012 (UTC)
 * And just for some shameless self promotion, when someone mentions LED, I can't help but show off a LED project I built a couple of years ago. Vespine (talk) 04:15, 17 May 2012 (UTC)
 * I had seen the hack-a-day pages and the videos, but didn't expect to find the man behind the cube at wikipedia reference desk! :-) Nice one, I've been looking at lots of projects since I got an arduino chip. Ssscienccce (talk) 19:46, 17 May 2012 (UTC)
 * Regarding the circuit: first "on" would last about 57% longer than the others since first time charging from 0 to 2/3; after that from 1/3 to 2/3. (e-0.4=0.67; e-1.1=0.33; 0.4/(1.1-0.4)=0.57)
 * You could invert the signal, lighting the led during output low, (put led between out and +V instead of out and 0V), so that all the ON times are the same (and the first OFF period isn't noticed since the led is OFF before as well.) Ssscienccce (talk) 19:46, 17 May 2012 (UTC)

server side scripting in perl/python
i know how to embed php code in html but how to do that for perl/python?
 * Do you mean how to imbed perl into python, or imbed perl and python into HTML? If it's the latter, I don't believe there is any easy way, perl and python are High-level programming languages that need to be compiled before they can run. PHP on the other hand is a server side scripting language which was designed specifically to be embedded into HTML. Vespine (talk) 05:51, 17 May 2012 (UTC)
 * Thinking a little more about this. Perl and Python are actually Interpreted languages, so I wasn't correct saying they need to be compiled, they can be executed by an "interpreter" which is possible, but unlike a PHP interpreter, not very common on a web server. I found this for using a python interpreter on a web server, there's probably something similar for perl, but it doesn't look trivial, or at least not as trivial as PHP. Vespine (talk) 06:38, 17 May 2012 (UTC)


 * The pattern of embedding executable code in an HTML source isn't quite the same as it's done in PHP. Usually people use a framework like Django, Pylons, TurboGears, or Google App Engine. These include a template engine (like Jinja, Cheetah, or Mako) which allows some code to be embedded into the blocks of HTML you're processing.  But mostly you have separate python source files for code, separate from the "presentation" (the HTML). This all probably sounds like a lot of extra gubbins when all you want is a few lines of code in a little throwaway file, and indeed PHP gets you that without the other stuff.  But if you're talking about a non-trivial project having the HTML and code jammed together starts to be a liability, and it's common in PHP to separate it out (Mediawiki mostly does, for example).  If you're just interested in web development in Python, try Udacity's course on that, which is pretty straightforward (they use Google App Engine with Jinja).  For the technically minded, I think mod_python did support embedding python just like php, but mod_python is thoroughly deprecated, and I don't think its moral successor mod_wsgi does this. -- Finlay McWalterჷTalk 10:03, 17 May 2012 (UTC)


 * It can be done very easily, assuming your web server is set up to launch python. Here's an example (from Programming Python 4th edition by Mark Lutz):

and

The only tricky bit might be getting your web server configured. If you tell us which server you run, we may be able to help.- gadfium 22:26, 17 May 2012 (UTC)

Code help
What code should I give to a HTML page, when I want to: i)Go to the next line without spacing, as offered in ms-word. ii)Write something inside a orange colored, 100% width, box. I am new to HTML. Thanks, extra 999  ( talk ) 07:59, 17 May 2012 (UTC)
 * Another question, how it is done that some space is left from the left side where a colourful background is added, and then a vertical line separates the main content. extra 999  ( talk ) 08:05, 17 May 2012 (UTC)

Like this (this is full width of its container - on your site you need to make sure it's not contained by something else. To make a no-space newline, use the    tag Spacing like you're asking about is usually done with CSS padding and margins. -- Finlay McWalterჷTalk 10:08, 17 May 2012 (UTC)

And is it possible to convert this into proper html: font {font-family: Century Gothic, sans-serif; font-variant: small-caps; text-indent: 125px; font-size: 150%; text-weight: bold; } extra 999 ( talk ) 11:26, 17 May 2012 (UTC)


 * Just apply the style to a given tag, either using the html style directive (which gets very repetitive if you do it more than a little) or using a CSS stylesheet Either way it looks like this. -- Finlay McWalterჷTalk 11:34, 17 May 2012 (UTC)
 * By the way,  should be , in which case it would look like this. AndrewWTaylor (talk) 12:05, 17 May 2012 (UTC)

Thanks you all for my help. extra 999 ( talk ) 06:36, 18 May 2012 (UTC)

What is abbreviation MFi?
What do the letters in MFi stand for (in this context)? Made for iPad? Made for iDevices? Is there a reference that defines it?--Mortense (talk) 11:34, 17 May 2012 (UTC)


 * https://developer.apple.com/programs/mfi/ -- Finlay McWalterჷTalk 11:36, 17 May 2012 (UTC)


 * OK, let me try again. So what do the three letters stand for? I don't see it defined on that page. I am not looking for information about MFi, but for what the abbreviation stand for. What does "M" stand for? "Made"? What does "F" stand for? "for"? What does "i" stand for? "iDevices"? Where is this abbreviation defined? I am not looking for what MFi is, only the definition of the abbreviation itself. --Mortense (talk) 12:06, 17 May 2012 (UTC)


 * I'm not stupid. I understood your question fine. Your question is answered right there in the "MFi Logos" section, as best as it can be. -- Finlay McWalterჷTalk 12:53, 17 May 2012 (UTC)


 * Our MFI disambiguation page says:
 * "Made for iPhone/iPod/iPad, Apple's licensing and certification program for electronic accessories that connects with their portable devices"
 * but we don't have a page for it. It's quite possible that the abbreviation is not specifically defined by Apple, and you can substitute whichever iDevice you want.  Rojomoke (talk) 12:39, 17 May 2012 (UTC)
 * According to this site it stands for "Made for iPod/iPhone/iPad".--Fuhghettaboutit (talk) 12:43, 17 May 2012 (UTC)

Is there any way to open up multiple wikilinks in one click?
In finder I can highlight twenty documents and click to open them all in one click. An equivalent facility for wikilinks would be quite a boon for say opening up fifteen double redirects from the what links here redirect list after a page move.--Fuhghettaboutit (talk) 11:51, 17 May 2012 (UTC)


 * There's a Firefox extension called MultiLinks (instructions) which lets you drag-select an area of the browser screen, and will then open each link it finds in that area in a new tab. It works quite nicely. -- Finlay McWalterჷTalk 13:13, 17 May 2012 (UTC)
 * Finlay, that's absolutely great! Works like a charm and will save me hours. Thank you.--Fuhghettaboutit (talk) 02:18, 18 May 2012 (UTC)

Connecting to wireless network
i have an existing wireless network with one computer on it/ I am trying to connect another computer via a Netgear adaptor. Ive tried all the usual things a number of times but i cant get the new computer to connect to the internet. I can get it to connect ot the router but no further. Any ideas on what i could be doing wrong?--92.28.76.69 (talk) 16:01, 17 May 2012 (UTC)


 * Some routers have a "MAC filter" (or the like) in their wireless config screens. This prevents devices with unknown MAC addresses from connecting. So if that's turned on, you can figure out your MAC and add it to the "white list" in that screen. Depending on your operating system, look at the output of ipconfig or ifconfig to find out your MAC. -- Finlay McWalterჷTalk 16:14, 17 May 2012 (UTC)
 * No the router is not filtering any addresses. Any other ideas?--92.28.76.69 (talk) 16:39, 17 May 2012 (UTC)


 * Perhaps your problem is a fixed (and wrong) DNS server. At the command line try entering ping 91.198.174.225 (which is a Wikipedia server). You should see a procession of times in milliseconds. If you see "no reply" or "timed out" or something, that suggests a routing problem. If the numeric ping succeeds but can't successfully ping en.wikipedia.org then your setting for the DNS server may be to blame. -- Finlay McWalterჷTalk 16:49, 17 May 2012 (UTC)

Terminal emulator on android phone
I installed [https://play.google.com/store/apps/details?id=jackpal.androidterm&feature=search_result#?t=W251bGwsMSwxLDEsImphY2twYWwuYW5kcm9pZHRlcm0iXQ.. this] terminal emulator on this Android phone. Basic commands like ls, cd and pwd work, but most commands trigger a "permission denied" message. Examples of commands that don't work: find, grep, which, vi. How do I obtain the required permissions to make the shell usable? --NorwegianBluetalk 19:43, 17 May 2012 (UTC)


 * The Android shell environment is pretty basic, with a few builtins and access to a few utilities on the system. Perhaps your your system doesn't have find, grep, or vi; they're not listed in the list of commands (I guess what's installed varies a bit by phone). For others you may need to su as root. -- Finlay McWalterჷTalk 21:34, 17 May 2012 (UTC)


 * Thanks for the link, which says that the "permission denied" message is misleading, and may also mean that the command is not understood. A basic command that's missing is cp (there's no "copy" either), and scp (which appeared on the list) gives the "permission denied" message. cat t.mp3 > u.mp3 worked, however. --NorwegianBluetalk 08:41, 18 May 2012 (UTC)


 * Android phones don't come with busybox, of which includes most of the standard console commands. Rooting your device will usually piggyback busybox on as well, which will let you use the terminal more efficiently. RMoD (talk) 23:09, 23 May 2012 (UTC)

Print Driver
Some years ago I had a Windows print preview utility with which one could select random thumbnail pages for printing (i.e. they didn't need to be consecutive) and ignore others. I thought it was called iPrint but a search on that term does not find it. Anyone recall it? Thanks. — Preceding unsigned comment added by Callerman (talk • contribs) 19:52, 17 May 2012 (UTC)

Like a batch file, but in linux
If I want the equivalent of a Windows batch file in linux, with a series of commands, and which requires admin privileges, how do I put it into a clickable file (without the admin password included, of course, it has to be asked at the moment of running the batch file). OsmanRF34 (talk) 23:09, 17 May 2012 (UTC)
 * Create your file of commands. The first lines should be


 * Alternatively, you could use kdesu or gksu if you use the KDE or GNOME environments.


 * The file of commands must be set to be executable, with 'chmod +x scriptname'.- gadfium 23:35, 17 May 2012 (UTC)
 * This won't work. Any commands that follow su in this script will run as the original unprivileged user, after the privileged shell that su starts is manually exited. You could put the rest of the commands in a second script and pass that to the subshell with the -c option to su, or you could put <tt>sudo</tt> in front of all of the privileged commands instead of using <tt>su</tt>. -- BenRG (talk) 00:51, 18 May 2012 (UTC)


 * Note that if you're running in an environment where other untrusted users have access to the computer, it's quite easy to create gaping security holes by doing things of that sort. Looie496 (talk) 23:41, 17 May 2012 (UTC)


 * By the way, the name for this is shell script.- gadfium 00:37, 18 May 2012 (UTC)
 * Have a look at the "advanced bash scripting guide" at "the linux documentation project". It's how I learn't bash. Heres the code for what you want to do.

Staticd (talk) 09:28, 20 May 2012 (UTC)