Search:  

 
 
   All ForumsHot TopicsGallery






how-to block ads


 
Forums » Tech and Talk » OS and Software » All Things Unix » Little Known Tips and Tricks...
Search Topic:
Uniqs:
25476
Share Topic:
RSS topic:
toggle:
flat / full
normal / watch
Posting:
Post a:
Post a:
Gaim alternatives? »
« Need Light Network Enabled Distro..  
page: 1 · 2 · 3 ...9 · 10 · 11 · 12 · 13 · 14
AuthorAll Replies


BeesTea
Network Janitor
Premium,VIP
join:2003-03-08
00000
reply to jdong
Re: Little Known Tips and Tricks...

Generally

$ ls -l `which slocate`
-rwx--s--x 1 root slocate 32468 Nov 12 2004 /usr/bin/slocate
--
$ /bin/whoami
nobody


JohnInSJ
Premium
join:2003-09-22
San Jose, CA
·Comcast

reply to jdong
said by jdong See Profile:

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
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.

ghost16825
Use security metrics
Premium
join:2003-08-26

reply to dom6791
Quick mail sending

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/


jdong
Eat A Beaver, Save A Tree.
Premium
join:2002-07-09
Rochester, MI
clubs:

reply to dom6791
Re: Little Known Tips and Tricks...

dd if=/dev/urandom of=- bs=1M count=10| mail emailaddress@domain.com
e-mail 10MB of randomness? ;)

--
Official Ubuntu Linux Forum Super Moderator: try Ubuntu Linux


deblin
Dark Side of the Moon
Premium,MVM
join:2001-09-01
Middletown, DE

reply to ghost16825
Re: Quick mail sending

said by ghost16825 See Profile:

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.
mail -s subject emailaddress@domain.com < message.txt


--
$(perl -e 'print pack("H*","6d616e207065726c0a")')

ghost16825
Use security metrics
Premium
join:2003-08-26
How about:

(without file creation)

echo "message here enclosed in double quotes" | mail -s Subject address@domain.com


deblin
Dark Side of the Moon
Premium,MVM
join:2001-09-01
Middletown, DE

Yep, that works. But if your message is long or pre-composed, I'm sure you won't want to type it out again. But yes, that's perfect for a quick message.
--
$(perl -e 'print pack("H*","6d616e207065726c0a")')


BeesTea
Network Janitor
Premium,VIP
join:2003-03-08
00000

For a long one-shot message, you can use cat

$ cat - | mail -s Subject address@domain.com << EOF
> This is another way to send mail
>
> Even
> with
> returns!
>
>
> EOF
$

--
$ /bin/whoami
nobody


deblin
Dark Side of the Moon
Premium,MVM
join:2001-09-01
Middletown, DE

Yep, and just in case you actually need to type EOF in your message:

cat - | mail -s subj user@host.com
type
your stuff
here
with an
EOF if you want
^D

Where ^D is a ctrl-d. Ok, we're getting a bit carried away now :)

--
$(perl -e 'print pack("H*","6d616e207065726c0a")')


BeesTea
Network Janitor
Premium,VIP
join:2003-03-08
00000

said by deblin See Profile:

Ok, we're getting a bit carried away now

With the "Yep, one up"? I agree.
--
$ /bin/whoami
nobody


steve1515
Premium
join:2000-08-07
Peabody, MA
·Speakeasy

reply to dom6791
Re: Little Known Tips and Tricks...

Here's a perl script I wrote that looks at apache logs and prints out unique counts, IPs, and DNS names.

syntax colored perl code:
#!/usr/bin/perl -w

use strict;

my $log_file = '/var/log/apache/access_log';

my %IP_count; #*** Hash containing count of hits from each IP
my %IP_DNS; #*** Hash containing the reverse lookups of IPs
my @sorted_IPs; #*** List of IPs sorted by count

#*** Check if log file exists and then try to open it
-e $log_file or die "ERROR: File not found.\n";
open LOG, "< $log_file" or die "ERROR: Can't create file: $!";

#*** Go through log and put IPs and counts in the hash
while (<LOG>)
{
$IP_count{$&}++ if (/^\d+\.\d+\.\d+\.\d+/);
}

close LOG;

#*** Go through each IP found, resolve it, and store result in the hash
foreach my $IP (keys %IP_count)
{
chomp($IP_DNS{$IP} = `dig +short -x $IP`);
}

#*** Store list of sorted IPs by count
@sorted_IPs = sort {$IP_count{$a} <=> $IP_count{$b} or
$IP_DNS{$a} cmp $IP_DNS{$b} or
$a cmp $b} keys %IP_count;

#*** Print out counts, IP, and DNS names
foreach my $IP (@sorted_IPs)
{
print " $IP_count{$IP}\t$IP\t$IP_DNS{$IP}\n";
}

This is my first perl program, so if theres some crazy error please let me know. :)

canadiancree
Crusin in the boonies

join:2004-02-10
Charlottetown, PE

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
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

said by steve1515 See Profile:

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

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 /.


wizard_ct
Gentoo Mage

join:2002-06-27
Santa Clara, CA
clubs:

reply to dom6791
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
said by wizard_ct See Profile :

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


packetscan
Premium
join:2004-10-19
Bridgeport, CT
clubs:
·Optimum Online

reply to Steve
said by Steve See Profile :

said by somebody quoted by paul1238 See Profile:
Some no0bs don't understand the number system that is associated with files and directories.
Neither the n00bs nor anybody else should fool with the numbers: it's difficult and often dangerous. Much better is to use the symbolic permissions, which are much less subject to surprises.

Symbolic permissions with chmod are a list of "sets", each of which is

scope
operation
permissions

"scope" is one or more of:
    u = user (the owner of the file)•g = group•o = other•a = same as ugo


"operation" is one of
    + add the permissions to existing ones•- subtract the permissions to existing ones•= set the permissions absolutely


"permissions" is one or more or
    r read permissions•w write permissions•x execute permissions
(yes, there are other permissions, such as sticky bit and setuid, but that's all in the man pages).

By stringing these together you can do what you want:

chmod a+r * - make all files readable

Because these permissions are relative, they don't destroy existing permission bits that you don't care about. There is no single numeric mode that would do this because no matter what you pick, it's going to muck with the (for instance) execute bits that you don't really want to. This means that you'll end up with directories that you can't get to any more.

Even when you do want to set hardcode permissions, do it with the symbolic mods:

chmod a=rwx * - same as chmod 777
chmod og= * - take away *everything* from others and group, but not touching "user" permissions

I cannot think of a downsize of the symbolic permissions, but I sure as hell can with the numbers.

Steve
I've always liked the Number system
chmod ### filename
chmod ### foldername

0 = - - -
1 = - - x
2 = - w -
3 = - w x
4 = r w x
5 = r - x
6 = r w -
7 = r w x
--
Who do you want to pay off today?

tallisinn

join:2005-04-12
Norwalk, OH
reply to sundaram123
Re: remove CTRL-M characters from a file in UNIX

I believe that the command dos2unix will convert that. If it is available in your flavor of Linux.
Forums » Tech and Talk » OS and Software » All Things UnixGaim alternatives? »
« Need Light Network Enabled Distro..  
page: 1 · 2 · 3 ...9 · 10 · 11 · 12 · 13 · 14


Saturday, 28-Nov 04:22:59 Terms of Use | Privacy Policy | Hosting by www.nac.net - DSL,Hosting & Co-lo | feedback | contact
over 10 years online! © 1999-2009 dslreports.com.
page compression OFF
Most commented news this week
· [121] Time Warner Cable Fires Broadside At Broadcasters
· [112] New AT&T Ad Campaign Hits Back At Verizon
· [96] Apple Joins AT&T Verizon Snark Fest
· [87] New Bill Takes Aim At Higher Verizon ETFs
· [71] TiVo Sees Record Customer Losses
· [69] In-Flight Internet Headed For Bumpy Landing?
· [66] Verizon CEO: Hulu Will Be Dead Soon
· [62] Thanksgiving Open Thread
· [50] Weekend Open Thread
· [40] EFF Wages War On Fine Print
Most people now reading
· Windows 7 boot manager editing questions [Microsoft Help]
· 3.x Feral Druid - Bear Tanking Guide [World of Warcraft]
· [Newsgroups] Newzleech down? [Filesharing Software]
· MagicJack Error Broken Storage [MagicJack]
· [WIN7] Can I use Windows 7 disc to boot up install? [Microsoft Help]
· DIR-655 New Beta 1.32b09 [D-Link]
· Backstab vs screws (not which to use) [Home Repair & Improvement]
· HOW-TO: QoS and Tomato (fixes "choppy voice") [MagicJack]
· Is Gear Score now the new requirement to get pug invite? [World of Warcraft]
· [ PVP] 3.2 DK PvP D/W Spec... [World of Warcraft]