Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Longinus00
Dec 29, 2005
Ur-Quan

T.K. posted:

So does the old advice about not using backticks and cat if you need to loop through a file still apply?

I.e. use

while read f; do stuff with $f; done < infile.txt

instead of

for f in `cat infile.txt`; do stuff with $f; done

I find myself doing it the second way because that's how I learned it. Can it really break something in the real world?


Won't the 2nd example load the whole file into memory at once instead of stepping through it line by line (of course it still processes it by delimiters)? I'm not sure how 'read' is actually handled behind the scenes.

Adbot
ADBOT LOVES YOU

rugbert
Mar 26, 2003
yea, fuck you
So my laptop has started overheating a LOT and Im not sure why. Ive been using ubuntu on it for years and I feel like it didnt start overheating really until I upgraded to 11.04.

and even when I installed 10.10 from scratch it still overheats. At first I thought it was just when I had my second monitor plugged in (and then when I was playing flash videos which is what usually shutdown my laptop) but no, it just turned off on me and Im not using it. I used to be able to run TONS of stuff (virtual box, chrome and firefox (with multiple tabs), rails server, gedit, and pandora) but now it seems to overheat ALL THE TIME. Im wondering now if it could be a hardware issue tho.

I mean, look art my syslogs
code:
ov  1 11:25:14 samsung kernel: [55350.875494] intel ips 0000:00:1f.6: MCP limit exceeded: Avg temp 9125, limit 9000
Nov  1 11:25:19 samsung kernel: [55355.867188] intel ips 0000:00:1f.6: MCP limit exceeded: Avg temp 9760, limit 9000
Nov  1 11:25:24 samsung kernel: [55360.858860] intel ips 0000:00:1f.6: MCP limit exceeded: Avg temp 10035, limit 9000
Nov  1 11:25:29 samsung kernel: [55365.850539] intel ips 0000:00:1f.6: MCP limit exceeded: Avg temp 9940, limit 9000
Nov  1 11:25:34 samsung kernel: [55370.842230] intel ips 0000:00:1f.6: MCP limit exceeded: Avg temp 10080, limit 9000
Nov  1 11:28:59 samsung kernel: [55575.501270] intel ips 0000:00:1f.6: MCP limit exceeded: Avg temp 9246, limit 9000
Nov  1 11:29:04 samsung kernel: [55580.492928] intel ips 0000:00:1f.6: MCP limit exceeded: Avg temp 9331, limit 9000
Nov  1 11:29:09 samsung kernel: [55585.484628] intel ips 0000:00:1f.6: MCP limit exceeded: Avg temp 9396, limit 9000
Nov  1 11:29:34 samsung kernel: [55610.443024] intel ips 0000:00:1f.6: MCP limit exceeded: Avg temp 9996, limit 9000
Nov  1 11:29:39 samsung kernel: [55615.434705] intel ips 0000:00:1f.6: MCP limit exceeded: Avg temp 9962, limit 9000
Nov  1 11:29:44 samsung kernel: [55620.426388] intel ips 0000:00:1f.6: MCP limit exceeded: Avg temp 10088, limit 9000
Nov  1 11:29:49 samsung kernel: [55625.418077] intel ips 0000:00:1f.6: MCP limit exceeded: Avg temp 10140, limit 9000
Nov  1 11:29:50 samsung kernel: [55626.671789] Critical temperature reached (103 C), shutting down.
Anyone have any advice?

spankmeister
Jun 15, 2008






Open 'er up and see if there is any dust clogging the fans.

Ninja Rope
Oct 22, 2005

Wee.

Longinus00 posted:

Won't the 2nd example load the whole file into memory at once instead of stepping through it line by line (of course it still processes it by delimiters)? I'm not sure how 'read' is actually handled behind the scenes.

I think the `cat` method will fail on a large file for this reason.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Is there a way to disable NetworkManager (Debian) for just one interface?

I want to share an internet connection but I don't want to manually configure it every time I join the network (using 2 wifi cards)

edit: I think I answered my own question, remove 'auto wlan1' from /etc/network/interfaces

Bob Morales fucked around with this message at 00:05 on Nov 2, 2011

covener
Jan 10, 2004

You know, for kids!

Ninja Rope posted:

I think the `cat` method will fail on a large file for this reason.

This should not be a practical concern, cat has no reason to buffer significant amount of the contents on the heap and a sniff test shows different catsusing 4k buffer, 32k buffer, and mmap.

rugbert
Mar 26, 2003
yea, fuck you

spankmeister posted:

Open 'er up and see if there is any dust clogging the fans.

I cracked it open and air dusted the hell out of the fan but it didnt look like there was much in there. My temperatures SEEM to have gone down tho, however they still seem to spike up a lot.

Ninja Rope
Oct 22, 2005

Wee.

covener posted:

This should not be a practical concern, cat has no reason to buffer significant amount of the contents on the heap and a sniff test shows different catsusing 4k buffer, 32k buffer, and mmap.

I swear I've broken it reading large files but I don't remember the details of how. Ever since then I've used the read method (or used Perl) instead.

ToxicFrog
Apr 26, 2008


Ninja Rope posted:

I swear I've broken it reading large files but I don't remember the details of how. Ever since then I've used the read method (or used Perl) instead.

You can very easily get a "command line size limit exceeded" error by doing something like 'foo $(cat a_large_file)'. I don't know if for is subject to the same limits, though; since the whole thing is a shell construct, it might optimize $() internally by turning it into a pipe, rather than expanding the whole thing before starting the loop.

covener
Jan 10, 2004

You know, for kids!

Ninja Rope posted:

I swear I've broken it reading large files but I don't remember the details of how. Ever since then I've used the read method (or used Perl) instead.

Could be the scenario described by ToxicFrog's, which makes sense. But Longinus00's "read it into memory" aspect is probably off the mark.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

ToxicFrog posted:

You can very easily get a "command line size limit exceeded" error by doing something like 'foo $(cat a_large_file)'. I don't know if for is subject to the same limits, though; since the whole thing is a shell construct, it might optimize $() internally by turning it into a pipe, rather than expanding the whole thing before starting the loop.

You usually end up having to use 'find' or 'xargs'

http://en.kioskea.net/faq/1086-unable-to-delete-file-argument-list-too-long

ls *.toto | xargs rm
find . -type f -name *.toto | xargs rm

or

find . -name "*.toto" -exec rm {} ;


IGNORE THIS AND READ THE NEXT POST

Bob Morales fucked around with this message at 16:29 on Nov 2, 2011

ExcessBLarg!
Sep 1, 2001

Bob Morales posted:

You usually end up having to use 'find' or 'xargs'
Bah that link is incredibly wrong!

1. 'rm *.toto' and 'ls *.toto | xargs rm' have the same wildcard expansion, the latter is just needlessly convolved.

2. 'find . -type f -name *.toto | xargs rm' needs to properly escape the wildcard, otherwise it won't work right if there's any "*.todo" in the current directory.

3. 'find . -name "*.toto" -exec rm {} ;' works fine, but spawns a separate "rm" process to delete every file, which is a bit suboptimal.

The two best solutions which aren't mentioned are:

1. 'find . -name "*.todo" -exec rm {} +' which works like xargs and spawns as few "rm" processes as possible. The "{} +" may be a non-standard extension in GNU find, I'm not sure, but it does work in BusyBox which is about the only other case I care about these days.

2. 'find . -name "*.todo" -print0 | xargs -0 rm' uses nulls as delimeters, so properly handles the utterly-perverse case of file names with newlines (as does the above solution).

Edit edit: Better accuracy, more content.

ExcessBLarg! fucked around with this message at 16:28 on Nov 2, 2011

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

ExcessBLarg! posted:

Bah that link is incredibly wrong!

Sorry, I've seen that problem a hundred times on the web and similar solutions posted, I just didn't check the first link I found. Partly because I don't have a directory with half a million files in it...

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Maybe with some edits and additions (screenshots, BSD's?) this could go in the OP (or at least in the next Linux thread)


Ubuntu



Currently what most people think of when you say "Linux", for better or for worse. Estimated at 20 million users, Ubuntu offers easy installation, great hardware support, and the latest in user interfaces. Many users aren't happy about the new interface, however. Alternatives exist if Unity isn't your thing: Kubuntu if you like KDE, Xubuntu for XFCE, and starring LXDE - Lubuntu. Although most popular on the desktop, Ubuntu offers solid server and LTS releases.

Website: http://www.ubuntu.com/
Forums: http://ubuntuforums.org/index.php
Package Manager: APT

Mint



Mint is a Ubuntu-based desktop distribution where MP3 codecs, Flash player, and other additions are installed and working out-of-box. They have recently added a Debian-based version. Mint claims to be the second most popular Linux distribution, behind Ubuntu.

Website: http://www.linuxmint.com/
Forums: http://forums.linuxmint.com/
Package Manager: APT

Fedora



Fedora is a Red Hat sponsored community project, as they no longer offer a free version of Red Hat Linux. A new version is released every 6 months, and versions are abandoned every 13 months. In order to use non-free software with Fedora (such as MP3 codecs or Adobe Flash), users must add 3rd party repositories such as RPM Fusion. Fedora is the third-most popular Linux distribution

Website: http://fedoraproject.org/
Forums: http://forums.fedoraforum.org/
Package Manager: RPM

Debian



Debian is one of the oldest Linux distributions. Focused on security and stability, Debian offers three releases: stable, unstable, and testing. Often criticized for using old or even obsolete packages in the stable release, the unstable and testing releases are often found in eveyrday use. Debian boasts over 30,000 software packages and the entire distribution spans over 30 CD-ROMs (or a handful of DVDs), although you only need the first one to install a usable system.

A true 'free' OS, you won't find built-in support for things like playing DVDs, MP3 or Flash support. You also won't find firmware for hardware like certain wireless cards, but those are easily downloadable from Debian's non-free repositories. Applications such as Firefox are even re-branded as 'Iceweasel', because of copyright and trademark issues.

Website: http://www.debian.org/
Forums: http://forums.debian.net/
Package Manager: APT

OpenSUSE



OpenSUSE started in Germany and is still mainly developed in Europe. They were acquired by Novell but released back to the community. It contains a unique administration tool named 'YaST'.

Website: http://www.opensuse.org/
Forums: http://forums.opensuse.org/
Package Manager: RPM

Arch



Currently developing a large and dedicated following, Arch Linux defines itself as a 'simple, lightweight distribution'. Arch gets back to the core of Linux and prides itself in high-quality documentation. Arch uses the 'Pacman' package management system and a rolling-release system.

Website: http://www.archlinux.org/
Forums: https://bbs.archlinux.org/
Package Manager: Pacman

CentOS



CentOS is a free re-packaging of Red Hat Enterprise Linux. Very popular in production use with servers on the Internet.

Website: http://www.centos.org/
Forums: http://www.centos.org/modules/newbb/
Package Manager: RPM

Slackware



Another of the 'classic' Linux distributions, Slackware is a simpler distribution that sticks to the basics of UNIX. It has fallen behind newer distributions over the past ten years.

Website: http://www.slackware.org/
Forums: http://www.linuxquestions.org/questions/forumdisplay.php?forumid=14
Package Manager: PKG

Gentoo



Gentoo was made by a bunch of crazy bastards who though compiling your entire sytem (takes 2 days if you want KDE and OpenOffice) when you install. I'm not sure who uses it anymore but if you want to play around with it, go right ahead. It can be an educational experience. It's also a rolling-release system.

Website: http://www..gentoo.org/
Forums: http://forums.gentoo.org/
Package Manager: Portage


FreeBSD



The most popular of the BSD's, you can find FreeBSD at hosting providers (originally running sites such as Hotmail and Yahoo!) as well as the desktop. It forms the basis of projects such as m0n0wall, pfSense, and FreeNAS.

Website: http://www.freebsd.org/
Forums: http://forums.freebsd.org/
Package Manager: ports/PKG

OpenBSD



OpenBSD's main goals are security, adhering to the BSD license, and documentation. The project is lead by the controversial Theo de Raadt. The website once bragged about having "only one remote exploit in nearly 6 years!" OpenBSD is found as the base of many networking systems such as firwealls, routers, and VPN systems.

Website: http://www.openbsd.org/
Forums: http://openbsd.org/mail.html
Package Manager: ports

NetBSD



The least popular of the big-three BSD's, NetBSD is focused on portability. "Of course it runs NetBSD" is the project's motto. Nearly 60 hardware platforms are supported. is Theo de Raadt left NetBSD in 1994 to start OpenBSD.

Website: http://www.netbsd.org/
Forums: http://www.netbsd.org/community/
Package Manager: pkgsrc

Bob Morales fucked around with this message at 18:47 on Nov 2, 2011

spankmeister
Jun 15, 2008






Might be worth mentioning Debian is the upstream provider of Ubuntu, (and mint for that matter)

edit: derp

spankmeister fucked around with this message at 16:49 on Nov 2, 2011

dont skimp on the shrimp
Apr 23, 2008

:coffee:
Not a bad idea Bob Morales, though I think screenshots might be overkill. I think there's also a separate thread for BSD-discussion somewhere in the forums already, and I don't think it'd be a good idea to have that under the same thread anyhow.

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

ExcessBLarg! posted:

Bah that link is incredibly wrong!

1. 'rm *.toto' and 'ls *.toto | xargs rm' have the same wildcard expansion, the latter is just needlessly convolved.
Note that wildcard expansion isn't the whole behavior, though. The xargs example will likely try to delete all files with names that match those inside any directory named *.toto, which is probably really far away from the right behavior.

ExcessBLarg! posted:

2. 'find . -name "*.todo" -print0 | xargs -0 rm' uses nulls as delimeters, so properly handles the utterly-perverse case of file names with newlines (as does the above solution).
I think you read the same bad information on Wikipedia that I just did -- you don't just have to worry about newlines, because xargs will break arguments on any whitespace by default. If you don't null-separate, you hit the much more common case where at best it utterly fails to remove files that contain any spaces in the filename at all, and at worst removes several files it's not supposed to.

quote:

This manual page documents the GNU version of xargs. xargs reads items
from the standard input, delimited by blanks (which can be protected
with double or single quotes or a backslash) or newlines
, and executes
the command (default is /bin/echo) one or more times with any initial-
arguments followed by items read from standard input. Blank lines on
the standard input are ignored.

find ... -exec ... + is definitely the cleanest solution, but it's worth noting that xargs also has a -P option for parallelizing that might significantly speed up what you're trying to do (obviously rm is a terrible example).

Vulture Culture fucked around with this message at 16:48 on Nov 2, 2011

text editor
Jan 8, 2007

Zom Aur posted:

Not a bad idea Bob Morales, though I think screenshots might be overkill. I think there's also a separate thread for BSD-discussion somewhere in the forums already, and I don't think it'd be a good idea to have that under the same thread anyhow.

I don't see why we don't combine them, most of the questions are about cross-platform packages or shell coding.


I'll make some effortposts later tonight in here too, then we can decide what should go in the next megathread and ask for mod approval.

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

Might want to mention Funtoo Linux in the gentoo blurb, it is a fork by Daniel Robbins, the guy who started gentoo. P.S. it doesn't take days to compile kde etc if you run the compile in tmpfs (ramdisk)

taqueso fucked around with this message at 18:00 on Nov 2, 2011

ExcessBLarg!
Sep 1, 2001

Misogynist posted:

The xargs example will likely try to delete all files with names that match those inside any directory named *.toto, which is probably really far away from the right behavior.
Ah, yes. I retract my retract, that link is incredibly wrong.

Misogynist posted:

I think you read the same bad information on Wikipedia that I just did -- you don't just have to worry about newlines, because xargs will break arguments on any whitespace by default.
drat, you're right!

I had been assuming the behavior of xargs was to split on newlines for years. I use it rather sparingly but, sigh.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
So installing ubuntu server on that computer worked great. I'm surprised it went so smoothly. Anyways I just wanted to update you guys with a picture of how the screen looks.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

MEAT TREAT posted:

So installing ubuntu server on that computer worked great. I'm surprised it went so smoothly. Anyways I just wanted to update you guys with a picture of how the screen looks.



Remove the NVIDIA (nouveau) drivers, why would you install them on a server anyway?

If they automatically installed, try removing or upgrading them. You may be able to pass some sort of command-line option at boot to use VESA graphics and have it work normal but you won't get fancy graphics.

Longinus00
Dec 29, 2005
Ur-Quan

MEAT TREAT posted:

So installing ubuntu server on that computer worked great. I'm surprised it went so smoothly. Anyways I just wanted to update you guys with a picture of how the screen looks.



Didn't you say the screen was messed up in windows? It's probably a hardware fault and I recommend closing the lid and never opening it up again.

spankmeister
Jun 15, 2008






start it up with nomodeset kernel option, then it will run in ye olde vga.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Longinus00 posted:

Didn't you say the screen was messed up in windows? It's probably a hardware fault and I recommend closing the lid and never opening it up again.

No, read my post again. The screen looks like that as soon as it POSTS. It is a hardware fault, I burned out the video card playing WoW back when I was still in uni.

I've had it sitting in my closet for almost 2 and a half years. When my wife saw last week she said I could either fix it or throw it out. It's just that it's completely unusable in Windows, so I figured I could make it into a headless Linux server. At least in Linux I can sorta make out the words in the console, despite the terrible color.

But all of that doesn't matter since I just SSH into it from my PC. I won't be using it as a laptop anymore, it's just going to sit under my router for now. I'll try the kernel VESA options and see if it helps, but I doubt it will since it's like that even in the BIOS.

Janitor Prime fucked around with this message at 22:57 on Nov 2, 2011

spankmeister
Jun 15, 2008






MEAT TREAT posted:

I'll try the kernel VESA options and see if it helps, but I doubt it will since it's like that even in the BIOS.

The old vga=xxx modes are deprecated. Your best use is nomodeset, which runs it in pure text mode. But yeah if even your bios is hosed then there is not really anything you can do. (badram patch for vga? :v: )

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

I thought this a photoshops. Haynes, the people who make chintzy automotive repair manuals, wrote a Linux book.

http://www.amazon.com/exec/obidos/ASIN/1844259706/distrowatch-20

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Bob Morales posted:

I thought this a photoshops. Haynes, the people who make chintzy automotive repair manuals, wrote a Linux book.

http://www.amazon.com/exec/obidos/ASIN/1844259706/distrowatch-20



Hah! I got a good laugh out of that.

Grabulon
Jul 25, 2003

I have a large file (an XML document) and I want to remove a multiline string that is somewhere near the end of the file. How can I do this using sed that is faster than what I'm currently using:

code:
sed -e '/<tag>/,/<\/tag>/d'

spankmeister
Jun 15, 2008






I just typed crontab -r instead of -e :gonk:

Hope there wasn't anything important in there. :v:

Ninja Rope
Oct 22, 2005

Wee.

spankmeister posted:

I just typed crontab -r instead of -e :gonk:

Hope there wasn't anything important in there. :v:

I did that once on a server that generated reports and emailed them from cron. Why are those two keys next to each other? :(

Longinus00
Dec 29, 2005
Ur-Quan
Just put a backup script in your crontab! (or have it be a symlink to a vcs version)

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug
Please let me know if there's a good reason not to have /etc backed by a Git repository, because I do it everywhere.

I keep meaning to try out etckeeper, which does the same thing in the same way but also hooks into apt/yum/whatever. Plan Git hasn't been a problem for me; I occasionally have commits like "this is apparently what the package manager changed".

dont skimp on the shrimp
Apr 23, 2008

:coffee:

Lysidas posted:

Please let me know if there's a good reason not to have /etc backed by a Git repository, because I do it everywhere.

I keep meaning to try out etckeeper, which does the same thing in the same way but also hooks into apt/yum/whatever. Plan Git hasn't been a problem for me; I occasionally have commits like "this is apparently what the package manager changed".
poo poo you haven't modified yourself usually just get overwritten by new config files on a package update. If you then restore to an old, obsolete config, then poo poo might not work as expected.

That doesn't mean you don't need to backup, but you might want to keep it in mind when restoring stuff.

pseudorandom name
May 6, 2007

git doesn't store permissions, which is problematic for things like /etc/shadow. etckeeper does, though.

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

pseudorandom name posted:

git doesn't store permissions, which is problematic for things like /etc/shadow. etckeeper does, though.
etckeeper is just a shim around metastore, which is the piece that does all the actual lifting. There are some annoying caveats.

spankmeister
Jun 15, 2008






My crusty old UNIX-admin colleague uses RCS for that purpose, but git is fine too.

pseudorandom name
May 6, 2007

Misogynist posted:

etckeeper is just a shim around metastore, which is the piece that does all the actual lifting. There are some annoying caveats.

It actually doesn't anymore.

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

pseudorandom name posted:

It actually doesn't anymore.
That's reassuring, I stopped using etckeeper on account of metastore.

Adbot
ADBOT LOVES YOU

hackedaccount
Sep 28, 2009

Lysidas posted:

Please let me know if there's a good reason not to have /etc backed by a Git repository, because I do it everywhere.

If you don't mind, why are you doing this? Quick and dirty backup solution for nodes that hold no data?

I'm used to good old daily full/incremental via backup software so I'm curious what you're up to here.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply