What Have You Done with Linux Lately?

Man of Honour
Soldato
Joined
2 Aug 2005
Posts
8,721
Location
Cleveland, Ohio, USA
I thought it might be fun to have a thread where we can discuss the little things that we use Linux to do that might otherwise be impracticable or otherwise needlessly difficult.

I'll go first.

This morning I was given a bunch of data on three dozen DVDs. He wanted me to copy all of the .zip files within a very deep system of subdirectories, found amid other types of files, then combine them into one large archive. He said it would probably take me several hours to track 'em all down. Little did he know! ;)

I needed just a few short commands to do the job and somebody who, unlike me, actually knows what they're doing could probably do it even easier.
essentially I ran:
Code:
find /cdrom/* | grep ".zip" > ~/Desktop/zipfiles.txt
Which, for those unfamiliar with such things is going to list all files in /cdrom, then search those results for .zip. It's going to then write the locations of those files to a text file on my desktop.

I popped open the file to see that it had indeed found a bunch of archives.
It then occurred to me that I could turn this into a little script. I went back to the command line and used sed:
Code:
sed 's/\/cdrom/mv\ \/cdrom/g' zipfiles.txt > mvscript.sh
This line uses sed, the Stream EDitor to search for /cdrom, the beginning of every path in the file, and replace it with mv /cdrom. All the of the backslashes are there to tell it to ignore the slashes and spaces which would confuse things. this is called escaping characters. I'll do the same sort of substitution for the end:
Code:
sed 's/.zip/.zip\ ~\/Desktop\/zipfiles/g' zipfiles.txt > mvscript2.sh
This replaces .zip with .zip ~/Desktop/zipfiles thus completing the move command. Now I just chmod +x mvscript2.sh and execute it and let the computer worry about navigating the nasty directories.

Since I had a lot of DVDs to go through I plopped all the commands I used into a single script which I ran after each disk automounted. In it I also ha Easy as pie and it let me get back to what's really important, playing networked dopewars. :D

I'm sure that if I had to do all this on Windows it would have taken hours.

So how about it, lads? Have you done anything cool with Linux lately to save you time, effort, or make you feel like some sort of demi-god, capable of solving all the world's problems with only a few keystrokes?
 
Soldato
Joined
18 Oct 2002
Posts
8,123
Location
The Land of Roundabouts
I made a Udev rule that would detect and dial a Three hsdpa usb modem then overwrite the Resolv file to get around there dodgy DNS servers when it was plugged in.
Not as clever as your little script mind :)
Thats the great thing about Linux, there are so many small yet extremely powerfull tools that are only limited by your imagination and creativity.
 
Soldato
Joined
15 Aug 2006
Posts
3,422
Location
127.0.0.1
nice work billy, really showing off the power of the shell.

only script i've written recently is to grab and monitor the temps from my quad through lmsensor and if they go over 70c it calls shutdown with immediate effect as most likely my pump has failed - the script is called through the cron daemon every minute of the day and will log details if it calls shutdown. i could incorporate it through conky and have it check with more frequency but my radiator doesn't heat up quick enough for it to be a problem.

nothing special but needed as there's no programs like speedfan or similar under linux that i know of but it does the job just as well and probably more reliable tbh.
 
Man of Honour
Soldato
OP
Joined
2 Aug 2005
Posts
8,721
Location
Cleveland, Ohio, USA
That's cool, marscay. How does it work? I haven't used lmsensor but I assume it prints the results of the sensors to standard I/O which you can then point to a file or grep or similar. How does your script manipulate this gleaned data? Share the goodness, it might give some of us some good ideas. :D
 
Associate
Joined
17 Dec 2005
Posts
1,218
Nice scripts, seem useful as well for a change. :p I will be watching this thread, as I'm no script master myself. I can't seem to find any use for a script atm either. Any ideas? :D

To reply to your topic, I've been getting an arch linux x64 file server up and going with samba today. :) Makes me wonder why I've stored all my files locally for so long...
 
Associate
Joined
28 Feb 2008
Posts
185
My one is not really all that impressive, but I'm fairly new to Linux really (only about 6 months or so) and I don't know that much programming/terminal stuff, so I'm fairly happy through WINE I got iTunes to work nearly seamlessly, though it can't seem to see any of my external drives and crashes when I tell it to play Videos. I've been using Ubuntu these last few months and it really is brilliant, about to see how well the Linux version (the Transgaming/Cegeda wrapper) of Eve Online works!
 
Man of Honour
Soldato
OP
Joined
2 Aug 2005
Posts
8,721
Location
Cleveland, Ohio, USA
Nice scripts, seem useful as well for a change. :p I will be watching this thread, as I'm no script master myself. I can't seem to find any use for a script atm either. Any ideas? :D
Download Firefox over and over again for the next 15 or so hours. ;)

copy the following:
#!/bin/bash
while true ; do wget http: //MIRROR[/url] OF YOUR CHOICE/mozilla.org/firefox/releases/3.0/linux-i686/en-GB/firefox-3.0.tar.bz2; done

Go to Mozilla's site and find the address of a mirror that seems fast enough for you.
Open up nano or the text editor of your choice, paste it in with the relevant mirror address in place. Save it (ctrl o in nano). Exit and go back to the prompt (ctrl x in nano). run

chmod +x nameofscript

execute it with ./nameofscript

For extra fanciness you can run it with nohup and return control of your shell like so:
nohup ./nameofscript &&

P.S. Don't actually do this. It won't cont and puts unnecessary strain on their servers.
 
Last edited:
Associate
Joined
16 Sep 2007
Posts
353
Location
Stoke-on-trent
I've setup a webserver with php and mysql. setup torrentflux,mail-server,irc-server stream video from my server to xbox 1 and a few other really boring things. simple to everyone else but when you do it yourself you feel like some sort of linux demi-god :p
 
Soldato
Joined
7 Apr 2004
Posts
4,212
Recently set up LUKS encryption on my root partition :p and tbh its more hassel than its worth, and doesnt work 100% correctly on Arch sadly.

Also code a lot, i really like the code::blocks C++ IDE :)
 
Soldato
Joined
15 Aug 2006
Posts
3,422
Location
127.0.0.1
That's cool, marscay. How does it work? I haven't used lmsensor but I assume it prints the results of the sensors to standard I/O which you can then point to a file or grep or similar. How does your script manipulate this gleaned data? Share the goodness, it might give some of us some good ideas. :D

#!/bin/sh
PATH=/bin:/usr/bin:/usr/local/bin:/usr/sbin
export PATH
temp=`sensors | grep ^"Core 0" | cut -c15-16`
if [ $temp -gt 70 ] ; then
echo "CPU reached $temp degrees and system was shutdown at `date`" > /home/marscay/temp.shutdown
/sbin/shutdown -P now
fi

pretty simple but it works nicely, as i said earlier it gets called every minute through the cron daemon and the best part is it's all working away silently in the background.

these kind of apps are one area in which linux is lacking but a little improv and it's sorted. :p
 

Una

Una

Associate
Joined
26 Nov 2004
Posts
2,471
Location
Reading / Lake District
Built gcc ARM cross compiler (on my x86 linux box) for iphone native development and configured my toolchain correctly. Been busy working on iphone kernel development so not had much time to write linux stuff recently.
 
Man of Honour
Soldato
OP
Joined
2 Aug 2005
Posts
8,721
Location
Cleveland, Ohio, USA
Built gcc ARM cross compiler (on my x86 linux box) for iphone native development and configured my toolchain correctly. Been busy working on iphone kernel development so not had much time to write linux stuff recently.
[accent=exaggerated Victorian , à la Futurama's Hedonismbot]Lah dee dah, I'm just too busy doing piddly ARM kernel development to toil with yon mere mortals. Lah de dah...[/accent]

:D

sablabra I've picked up what I know by finding some task to do then researching how it might be done. Basic shell scripting is essentially just a list of commands that you'd type at the command prompt. It executes one line then when that's done it executes the next. This is the stage I'm at. More advanced scripting uses variables and loops and conditional statements that, while not too difficult to understand when it's being explained, are a bit esoteric when starting with no programming experience.

I had to take a half semester course in C wherein the only thing I learned was that I didn't want to do programming again. As fate would have it I had another half semester course in Matlab that I was able to slog though by miming examples, not really understanding what I was doing.

There are plenty of shell scripting tutorials on the web. If anybody has read any and can recommend one for absolute beginners I'd love to know about it.
 
Soldato
Joined
27 Aug 2004
Posts
2,955
Location
Singapore ExPat
Don't mean to be a party pooper and what you did was a good way to learn but you could have just done this:

find /cdrom/ -name "*.zip" -exec cp {} /your/location

The find manpage should explain it all.
 
Man of Honour
Soldato
OP
Joined
2 Aug 2005
Posts
8,721
Location
Cleveland, Ohio, USA
Don't mean to be a party pooper and what you did was a good way to learn but you could have just done this:

find /cdrom/ -name "*.zip" -exec cp {} /your/location

The find manpage should explain it all.
BillytheImpaler said:
...and somebody who, unlike me, actually knows what they're doing could probably do it even easier.
See! :D
 
Soldato
Joined
13 Nov 2002
Posts
3,589
I'm sure that if I had to do all this on Windows it would have taken hours.

On Windows, you could do:

Start-->Search-->*.zip--->Select All--->7zip, Add to archive.

Don't know how quick it would be, though. :p


I wanted to see if I could set up an ultra low power computer. So I set up Linux on an Linksys NSLU2 and added an 8GB Corsair flashdrive. I use it to download Firefox 3 and Linux distros when main PCs are off. Silent and only draws a few milliamps. :D
 
Last edited:
Associate
Joined
2 Dec 2003
Posts
357
1. Used curlftpfs + rarfs + mediatomb to mount an ftp, then the contents of rar files on that ftp, then mediatomb to stream it to my PS3 XMB to watch it on the TV.

2. Managed to get Gentoo compiling on PS3. (didn't really take much, just never got round to it). Got spu-libmedia and a modified version of mplayer working to do a little (tho not enough to have 720p mkvs) playing under linux. Only 1 spu was being used, and 1 core of the ppu.

Almost made me cry with how cool it all was.
 
Man of Honour
Soldato
OP
Joined
2 Aug 2005
Posts
8,721
Location
Cleveland, Ohio, USA
How long did it take to compile the kernel? How much customization did you do to it, or did you just run with the base options as many do?

I assume that the hypervisor-crippled Cell still supports 64-bit operation. Is that what you're running? Does the proc and kernel support Altivec? If so it should have the guts to play most "scene" H.264 .mkv files.
 
Associate
Joined
21 May 2007
Posts
1,464
Oh, I feel rather dull.

My recent Linux use........

Browsed web
Read mail
Watched Le Mans 24hrs live (well 20 hours of it) while listening to Radio Le Mans via the net during the ads.
Watched some documentaries
Listened to some tunes.
Ripped a music DVD (using mencoder)
Copied some data dvd's using cat /dev/sr0>image.iso and then burning with k3b, was amusing too, as after catting the iso, 3+ GB of it were still in RAM, and k3b read them from there, it quite surprised me since the stuff in ram had been left over from stuff that was on it's way to the ISO file, rather than a cache of data read from it.
Wrote some UDEV rules (with bro's help) so that each of my external drives, when attached, will appear as a meaningful /dev name (freecom1 freecom2 etc).
Set all my HD's to 5 min spindown timeout, with them spinning the machine idles at 100W-ish, and although I've not measured yet, I'd assume that turning 4 10-15W HD's off will make a big reduction in power, as well as taking it one step closer to silence.


What did I do in windows in the same time frame?
Fixed windows-only issues and played games.
 
Back
Top Bottom