  Happyrat Google Is Your Best Friend Premium join:2002-07-01 Disneyland
| Re: Little Known Tips and Tricks... Why is this thread no longer sticky? Most of the info presented in this thread is timeless... --
Satan Loves You... »fuzzyrat.com | |
|
 |   alien9999999 Your Head Looks Nice Premium join:2002-05-21 B-3000 | Re: Little Known Tips and Tricks... hmm, strange... it should be sticky...
you better sitemark it, just in case -- Alien is my name and headbiting is my game. | |
|
 |  |  |
  armitage
join:2004-01-04 philippines
·mydestiny cable
| I dont recall where or when I found this, but just in case that you cat a binary file while in a terminal (before starting X), hit -
ctrl-v ESC-C
and that'll reset your terminal to normal...
haven't seen this work in FreeBSD though (but I can cat a bin file and still have a normal term in BSD though). -- Windows? It's a pack of instant noodles. Convenient, but not very healthy. Linux? Well, linux is the kitchen. | |
|
  a398274
@cox.net | Hate when your cursor disappears?
tried a reset? clear?
invisible cursor no more!
| |
|
  alien9999999 Your Head Looks Nice Premium join:2002-05-21 B-3000 | i don't want to sound arrogant, but i feel this might be usefull: »Installing IPv6 Server -- Alien is my name and headbiting is my game. | |
|
 ghost16825 Use security metrics Premium join:2003-08-26
3 edits | Gentoo installer/user tip:
This is more or less a RTFM tip rather than anything really brilliant. (Yes, I admit it - I occasionally do read the manual)
What should really be more prominent in the Official Gentoo docs is the elog system - logs info, warning messages etc when emerging.
#In your /etc/make.conf
#The default save directory for these logs is /var/log/portage/elog/ PORTAGE_ELOG_CLASSES="info warn error log qa" PORTAGE_ELOG_SYSTEM="save" #or save_summary for all the critical information in one file rather than separately. | |
|
 |  dom6791
join:2001-11-23 Bronx, NY 1 edit | Re: Little Known Tips and Tricks... In the event someone ever wanted to list only directories:
for i in * ; do if [ -d $i ]; then echo $i ; fi ; done
hohumdedumdum, True!  | |
|
 |  |   hohumdedumdum
@anduin.org
| Re: Little Known Tips and Tricks... No offense dom6791 , but that's just crazy. There's no need to do that.
ls -d */
That's it.
Also, your for loop will only work so long as the directory names have no spaces in them. | |
|
  weeksben1 Premium join:2004-02-26 Clarkston, MI | Just want to say thanks for the tips and tricks. Its great for showing us *nix rookies, some new (at least to us) stuff. -- Ben WeeksNetwork AdminNovell CNA NW3.2/4.x/5.xNetwork + Certified | |
|
 dom6791
join:2001-11-23 Bronx, NY
| Didnt see this one in the list
If you have many files in a directory that you want to execute consecutively, but dont want the hassle of manually running one at a time:
find /tmp/syncfiles -name 'sync*' -exec sh {} \;
This will find all files that begin with 'sync' in the /tmp/syncfiles directory and execute one at a time. This saved me lots of time since it takes 7 hours sometimes. Now I can just start it and walk away.  | |
|
 |
  timcuth Braves Fan Premium join:2000-09-18 Pelham, AL clubs:
·AT&T Southeast
1 edit | I don't know whether this already has been posted. I really think this thread should be edited into the ATU FAQ, as it is getting to be next to impossible to find anything specific in such a long thread.
Anyway, this week at work I was required to initiate a batch script upon reception of an FTP'ed file, rather than scheduling the job at a regular time. I did a Google search and then added my own twists, coming up with a very nice solution.
Since the batch script runs for about 10 minutes, I decided to check for the incoming file every 15 minutes during the range of times when the file might arrive (3 AM - 9 AM, Tue - Sat):
00,15,30,45 3-9 * * 2-6 /path/check_for_file.sh
check_for_file.sh runs the UNIX find command to look for the incoming file with a timestamp newer than the output file that is created by the batch script. When the newer input file is found, the find command starts the batch script:
find /expimp/blah -name input_file.txt -newer /path/output_file.txt -exec /path/batch_script.sh \;
Works like a charm!
Tim
-- The shortest sentence is, "I am". The longest is, "I do". ~ Project Hope ~ | |
|
 |   yock TFTC Premium join:2000-11-21 Fairfield, OH
| Re: Start a script based on reception of a file said by timcuth :I really think this thread should be edited into the ATU FAQ, as it is getting to be next to impossible to find anything specific in such a long thread. That's a great idea. If users feel so inclined, they can submit their FAQ suggestions to this page and the system will IM the FAQ editors that there are new suggestions for the FAQ. In fact, Maxo sent us one just today.
No_Strings and I are slowly making our way through the FAQ in a massive cleanup effort, so anything you guys can add would be welcome. -- Wiki Wiki Laughter is the closest distance between two people. --Victor Borge | |
|
  deblin Dark Side of the Moon Premium,MVM join:2001-09-01 El Dorado Hills, CA
| Quick and easy way to check for a valid date with "cal", which is pretty ubiquitous.
is_valid=0 cal $mon $year | grep -qw $day && is_valid=1 if [ $is_valid == 1 ]; then echo "do stuff here if it's a valid date" else echo "invalid date entered" fi -- "Talk is cheap because the supply is greater than the demand" - Shelby Friedman | |
|
 |   Steve Consultant join:2001-03-10 Yorba Linda, CA
| Re: Little Known Tips and Tricks...Why not:
if cal $mon $year | grep -qw $day then echo "do stuff here if it's a valid date" else echo "invalid date entered" fi No need for the variable set when you can check for the result directly in the "if"
Steve — who nevertheless would have not thought to do it this clever way
-- Stephen J. Friedl Unix Wizard Microsoft Security MVP Tustin, California USA my web site | |
|
 |  |   yock TFTC Premium join:2000-11-21 Fairfield, OH
| Re: Little Known Tips and Tricks...said by Steve :Why not: if cal $mon $year | grep -qw $day then echo "do stuff here if it's a valid date" else echo "invalid date entered" fi No need for the variable set when you can check for the result directly in the "if" Steve — who nevertheless would have not thought to do it this clever way I think a *LOT* of people forget about return codes when shell scripting...myself included. This script is a perfect example of why they're so damned useful.
-- Wiki Wiki The more secretive a government is, the more skeptical we need to be. --Shepard Smith | |
|
 |  |   Mordy Comfortably Numb Premium,MVM,ExMod 2004-07 join:2001-12-02 Denver, CO 1 edit | (topic move) Little Known Tips and Tricks...
Moderator Action The post that was here (and all 6 followups to it), has been removed. | |
|
 |
  Steve Consultant join:2001-03-10 Yorba Linda, CA
| Wow, just tripped across something in Linux by accident: the x option to the ps command. Running ps -afx, it shows all processes with their parent/child relationship - very handy.
# ps afx PID TTY STAT TIME COMMAND 1 ? S 0:45 init [3] 2 ? SW 0:00 [kflushd] 3 ? SW 0:06 [kupdate] 4 ? SW 0:00 [kpiod] 5 ? SW 0:01 [kswapd] 6 ? SW< 0:00 [mdrecoveryd] 274 ? S 267:19 named -t /chroot/named -u named -c /etc/named.conf 327 ? S 140:15 syslogd -m 0 338 ? S 0:00 klogd 354 ? S 0:00 /usr/sbin/atd 370 ? S 0:00 crond 447 ? S 0:56 /usr/libexec/postfix/master 454 ? S 0:17 \_ qmgr -l -t fifo -u 9737 ? S 0:00 \_ pickup -l -t fifo -u 456 ? S 8:00 /usr/local/sbin/sshd 9754 ? S 0:00 \_ sshd: root@pts/0 9756 pts/0 S 0:00 \_ -bash 9770 pts/0 R 0:00 \_ ps afx 491 tty1 S 0:00 /sbin/mingetty tty1 492 tty2 S 0:00 /sbin/mingetty tty2 Looking back in older versions, it's obviously been around a long time, but today was the first I'd ever seen it.
Nice!
-- Stephen J. Friedl Unix Wizard Microsoft Security MVP Tustin, California USA my web site | |
|
 |
  toadlife Premium join:2004-05-03 Lemoore, CA
| If you run FreeBSD as your desktop, and you frequently run portupgrade or portmanager to update your ports, you may have started an update of your ports and gone to bed while it compiles only to find in the morning that it stopped somewhere in the middle of compiling to ask you a configuration question about one of the programs.
To keep make from asking you any questions, put the following line in /etc/make.conf
With batch mode enabled, make will use the default options when compiling ports.
If you don't want batch mode to be turned on by default, you can pass the option to portupgrade when you run it.
With portupgrade, the option... ...will cause portupgrade to pass the batch=yes to the make command each time it compiles.
With portmanager, you cannot (AFAIK) pass arguments to make, so you would have to have the argument in make.conf
To pass the batch argument when compiling a single port (useful with huge meta-ports like kde), you can pass the batch argument like so...
make BATCH=yes install clean | |
|
  wizard_ct Gentoo Mage
join:2002-06-27 Santa Clara, CA clubs:
| Building on the split tip earlier, I'm sure the benefits of tarring to small chunks is obvious - burning to dvds, copying to a FAT partition (2gb limit) - what have you. Here's how to do it:
tar -cvf - /home/dirToBackup | split -b 1000m - backup-09-06-2005
Allows you to tar a directory to chunks in place, without needing to create the massive one first. This saves a ton of space.
Of course customize tar params and and split size to taste.
Use cat to recover on the other end.
cat backup-09-06-2005a? > backup.tar
You could easily do this in place as well if you needed. | |
|
 |   ironwalker World Renowned Premium,MVM join:2001-08-31 Keansburg, NJ clubs:
·Optimum Online
1 edit | Re: Little Known Tips and Tricks... said by wizard_ct :Building on the split tip earlier, I'm sure the benefits of tarring to small chunks is obvious - burning to dvds, copying to a FAT partition (2gb limit) - what have you. Here's how to do it: tar -cvf - /home/dirToBackup | split -b 1000m - backup-09-06-2005 Allows you to tar a directory to chunks in place, without needing to create the massive one first. This saves a ton of space. Of course customize tar params and and split size to taste. Use cat to recover on the other end. cat backup-09-06-2005a? > backup.tar You could easily do this in place as well if you needed. Can I do it the same for Zip.I need to send a 48mb zip file to a windows user.I need them to be able to click first zip and open....if possible. I will read man zip too.
Thanks for the tip though:)
Nevermind,I found it. the tar command above made one 46mb archive for me and I had to use the split command seperately.
thanx again -- "LIVE FREE OR DIE" ... »www.rif.org/ ... Fiber Optics is the future of high-speed internet access. Stop by the BBR Fiber Optic | |
|
 |
 |  canadiancree Crusin in the boonies
join:2004-02-10 Charlottetown, PE
| Re: Little Known Tips and Tricks... a good idea. one question though, wouldnt it be a bit taxing to resolve the DNS names everytime? What about adding a routine to have it look up a table or something to see if that IP range is already resolved, and if not, to then seek it out?
Unless you already have that, my perl is rustier than a '72 Vega | |
|
 |  |   steve1515 Premium join:2000-08-07 Peabody, MA 1 edit | Re: Little Known Tips and Tricks... Ya, it only resolves each found IP once since each key in the hash is unique.
I'm also thinking that there is a simpler way than using dig...Maybe some built in perl resolving function, but I don't know what it is. | |
|
 |  |  |  tld
join:2002-12-19
·Optimum Online
| Re: Little Known Tips and Tricks...said by steve1515 :Ya, it only resolves each found IP once since each key in the hash is unique. I'm also thinking that there is a simpler way than using dig...Maybe some built in perl resolving function, but I don't know what it is. I've always used this:
sub iptoname { my ($ip) = @_; my (@list, $packed, @info, $hostname); @list = split(/\./,$ip); $packad = pack("C4",@list); if (@info = gethostbyaddr($packad,2)) { $hostname = $info[0]; } else { $hostname = ""; } $hostname; } I'm not sure I'd call it 'simpler' :D but it's probably a pretty efficient way of doing it.
Tom | |
|
 |  |  |  |   ireallyneedtoregiste
@rr.com
| Re: Little Known Tips and Tricks... Multitasking on the command line is something I actually didn't know about until recently. I admit I felt stupid for not learning how to do this earlier, but I don't recall any intros to the command line that went over this.
If you are logged into the command line and don't have vt's enabled or don't want to switch vt's for whatever reason, you can still run a command and then run another while the previous job is running.
Let's say I bunzip2 LDPHowtos.tar.bz2 That will take a while, and I want to read Slashdot, so I hit Ctrl-Z to pause the unzip and send me back to the shell. Now I can type bg to resume the unzip in the background, and use elinks to check the news.
If you know the command you're about to run will take a while, then a better way to do that is to put a "&" at the end of the command. That will background the job and put you back at the shell also.
Let's say I want to run multiple commands at the same time in one line. I can do that by putting a "&" at the end of each separate job. Like this: bzip2 foo & bzip2 bar & bunzip2 wtf.bz2 then I do the Ctrl-Z and bg bit to put it in the background. Or I could have just put another "&" at the end of the whole thing to background it.
Hope this helps someone new to the command line. I wish I knew this earlier. Would have saved me from having to wait for apps to finish whatever they were doing before I could check /. | |
|
 |
 ghost16825 Use security metrics Premium join:2003-08-26
| This probably not original, but at the moment I quite like this neat one liner:
(Useful when you don't care about the subject title and just want to send it off)
cat message.txt | mail emailaddress@domain.com or if you want a subject
cat message.txt | mail -s Subject address@domain.com Of course this requires your message to be in message.txt. I'm sure someone can find a method without having to invoke cat at all.
-- Admin of the Kerio 2x-like open source project: http://sourceforge.net/projects/kerio/ http://kerio.sourceforge.net/
| |
|
 |  See 6 replies to this post |
|
 |
 |   JohnInSJ Premium join:2003-09-22 San Jose, CA
·Comcast
| Re: Little Known Tips and Tricks...said by jdong :oh, so slocate is sgid/suid? $ ls -ld `which slocate` -rwxr-sr-x 1 root slocate 26388 Apr 16 2004 /usr/bin/slocate Looks like it [FC2] | |
|
 |  |   yock TFTC Premium join:2000-11-21 Fairfield, OH | Re: Little Known Tips and Tricks... Assuming you add your user to the slocate group. Without being a member of that group it should follow file permissions. -- This signiture pisses you off. | |
|
 |   BeesTea Network Janitor Premium,VIP join:2003-03-08 00000 | Generally
$ ls -l `which slocate` -rwx--s--x 1 root slocate 32468 Nov 12 2004 /usr/bin/slocate -- $ /bin/whoami nobody | |
|
 |
 |   BeesTea Network Janitor Premium,VIP join:2003-03-08 00000
| Re: Little Known Tips and Tricks... said by jdong :slocate started doing that, but nothing stops an experienced user from directly parsing the locate database, Well, except for file permissions that is.
$ ls -ld /var/lib/slocate/ drwxr-x--- 2 root slocate 104 May 23 03:22 /var/lib/slocate/ -- $ /bin/whoami nobody | |
|
dom6791
join:2001-11-23 Bronx, NY | Little Known Tips and Tricks... I was just wondering if some of you more knowledgeable *nix users would share some of your lesser known tips and tricks with Linux? Not including the information listed in this forums FAQs. | |
|
 |
|
 |