
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<html>

<head>
 <style type="text/css">
  A:link { text-decoration: none }
  A:visited { text-decoration: none }
 </style>
 <title>unixtips.org</title>
 <meta name="description" content="An informative tips site for all *nix users.">
 <meta name="keywords" content="linux, linux tips, tips, pointers, tricks, freebsd, solaris, information, info, howto, portico, how, unixtips">
</head>

<body
 bgcolor="FFFFFF"
 text="000000"
 link="050C97" 
 vlink="050C97"
 alink="FFFFFF"
>

<table border=0 width=600 cellspacing=0 cellpadding=0>
<tr>
<td>
<font face="arial, helvetica" size="2">

<p>
<a href="/"><img src="/images/unixtips.jpg"
alt="unixtips.org" border="0"></a><br>
<div align="right"><font size="5">the source for unix tips ...</font></div>
</p>


<h3>
  Recommended articles:
</h3>
<ul>
  <li>
    <p style="margin:0;display: inline;"><a href="https://www.plesk.com/blog/various/what-is-devops/">DevOps</a></p> -
    <p style="margin:0;display: inline;"><i>"DevOps is an IT delivery method that brings development and operations departments closer together by combining individuals, tools, and working practices..."</i></p>
  </li>
</ul>

<h3>Tips</h3>
<table border=0 width=100% cellspacing=0 cellpadding=0>

<tr>

 <td valign="top">
 <font face="arial, helvetica" size="1"><b>
 <a href="index.php3?catList=23">samba</a>
 </b></font>
 </th>

 <td valign="top" align="right">
 <font face="arial, helvetica" size="1"><b>
 <a href="http://"> 
 JonH</a>
 at 24 April, 13:02:59 </font></b>
 </td>

</tr>
</table>

<table border=0 width=100% cellspacing=0 cellpadding=0>
<tr width=100%>
<td>

<font face="arial, helvetica" size="2">
Rather than use smbmount to mount your samba volumes, use the mount command with the -t flag to indicate that you intend to mount a samba volume. e.g.

To mount a unix/linux volume...
<i>mount -t smbfs //&lt;server&gt;/&lt;volume&gt; &lt;mountpoint&gt</i>

To mount a windows volume...
<i>mount -t smbfs \\\\&lt;server&gt;\\&lt;volume&gt; &lt;mountpoint&gt</i></font>

</td>
</tr>

<tr>
<td>
&nbsp;
</td>
</tr>

</table>


<table border=0 width=100% cellspacing=0 cellpadding=0>

<tr>

 <td valign="top">
 <font face="arial, helvetica" size="1"><b>
 <a href="index.php3?catList=3">file manipulation</a>
 </b></font>
 </th>

 <td valign="top" align="right">
 <font face="arial, helvetica" size="1"><b>
 <a href="http://www.neverending.org/~ftobin/"> 
 Frank Tobin</a>
 at 30 October, 00:59:07 </font></b>
 </td>

</tr>
</table>

<table border=0 width=100% cellspacing=0 cellpadding=0>
<tr width=100%>
<td>

<font face="arial, helvetica" size="2">
<p>
<kbd>chmod -R a+rX <var>dir</var></kbd> will make <var>dir</var> and every file and directory in the tree below it readable by all (from the +r) and executable <em>if and only if</em> it is a directory or already executable by some user (from the +X).
</p></font>

</td>
</tr>

<tr>
<td>
&nbsp;
</td>
</tr>

</table>


<table border=0 width=100% cellspacing=0 cellpadding=0>

<tr>

 <td valign="top">
 <font face="arial, helvetica" size="1"><b>
 <a href="index.php3?catList=3">file manipulation</a>
 </b></font>
 </th>

 <td valign="top" align="right">
 <font face="arial, helvetica" size="1"><b>
 <a href="http://www.sistemasorion.com"> 
 Saul P.</a>
 at 7 October, 01:55:06 </font></b>
 </td>

</tr>
</table>

<table border=0 width=100% cellspacing=0 cellpadding=0>
<tr width=100%>
<td>

<font face="arial, helvetica" size="2">
If you ever have to delete many, many files but <b>rm</b> returns a "too many arguments" error, use <b>find</b> and <b>xargs</b> to save the day:

<p>
<b>find . | grep 'your_filename_filter' | xargs rm -f</b>
<p>
Of course, you can omit piping through <b>grep</b> if you just want to erase the entire directory. Xargs is also usefeul for many other needs; you can take a look at this <a href="http://www.unixreview.com/documents/s=8274/sam0306g/">xargs tutorial</a> if you're interested.</font>

</td>
</tr>

<tr>
<td>
&nbsp;
</td>
</tr>

</table>


<table border=0 width=100% cellspacing=0 cellpadding=0>

<tr>

 <td valign="top">
 <font face="arial, helvetica" size="1"><b>
 <a href="index.php3?catList=3">file manipulation</a>
 </b></font>
 </th>

 <td valign="top" align="right">
 <font face="arial, helvetica" size="1"><b>
 <a href="/cdn-cgi/l/email-protection#ea809a888f9e90aa809a888f9e90c4848f9e"> 
 Joe Betz</a>
 at 30 September, 21:42:01 </font></b>
 </td>

</tr>
</table>

<table border=0 width=100% cellspacing=0 cellpadding=0>
<tr width=100%>
<td>

<font face="arial, helvetica" size="2">
If your file permissions ever get messed up (like mine just did), it is possible to recursively set some permissions on all files, then different permissions to all directories, with:
<p>
<code>
<dd>chmod 664 `find * -type f -print0`</dd>
<dd>chmod 775 `find * -type d -print0`</dd>
</code>
<p>
Keep in mind that <i>chmod -R</i> is dangerous!</font>

</td>
</tr>

<tr>
<td>
&nbsp;
</td>
</tr>

</table>


<table border=0 width=100% cellspacing=0 cellpadding=0>

<tr>

 <td valign="top">
 <font face="arial, helvetica" size="1"><b>
 <a href="index.php3?catList=11">admin</a>
 </b></font>
 </th>

 <td valign="top" align="right">
 <font face="arial, helvetica" size="1"><b>
 <a href="/cdn-cgi/l/email-protection#670d170502131d270d170502131d49090213"> 
 Joe Betz</a>
 at 30 September, 21:42:45 </font></b>
 </td>

</tr>
</table>

<table border=0 width=100% cellspacing=0 cellpadding=0>
<tr width=100%>
<td>

<font face="arial, helvetica" size="2">
Tar is a good tool for moving files because it retains symbolic links and user/group permissions properly.  A simple 'Tar Pipe' can be done to send and get files:
<p>
send:<br>
tar cf - myfiles | ssh remotehost " ( cd /destination/path ; tar xf - ) "
 <p>
get:<br>
ssh remotehost "( cd /source/path; tar cf - desiredfiles ) " | tar xf - 
<p>
multiple ssh connections can be strung together to move the file across multiple machines:
<p>
send through:<br>
tar cf - myfiles | ssh remotehost1 " ssh remotehost2 \" ( cd /destination/path ; tar xf - ) \" "
<p>
get through:<br>
ssh remotehost1 " ssh remotehost2 \"( cd /source/path; tar cf - desiredfiles ) \" " | tar xf - 
<p>
Note that 'tar cf' and 'tar xf' can be replaced with 'tar czf' and 'tar xzf' for gzip compression.  Or, for bzip2 compression: 'tar 'cjf' and 'tar xjf'.
<p>
Use ssh-agent and the 'ssh -A' (ForwardAgent) switch to remove the need to type passwords repeatedly.</font>

</td>
</tr>

<tr>
<td>
&nbsp;
</td>
</tr>

</table>


<table border=0 width=100% cellspacing=0 cellpadding=0>

<tr>

 <td valign="top">
 <font face="arial, helvetica" size="1"><b>
 <a href="index.php3?catList=24">freebsd</a>
 </b></font>
 </th>

 <td valign="top" align="right">
 <font face="arial, helvetica" size="1"><b>
 <a href="/cdn-cgi/l/email-protection#80f2e1f9f6e4c0e2ecf5e4e7e5efeeaeeff2e7"> 
 rayvd</a>
 at 30 September, 21:43:07 </font></b>
 </td>

</tr>
</table>

<table border=0 width=100% cellspacing=0 cellpadding=0>
<tr width=100%>
<td>

<font face="arial, helvetica" size="2">
When trying to serve a directory mounted with mount_smbfs on FreeBSD with the Apache 2.0.x server, large files (over 100K or so) won't transfer correctly.  To fix this problem use the EnableSendfile off directive within your Global, Directory or VirtualHost config.</font>

</td>
</tr>

<tr>
<td>
&nbsp;
</td>
</tr>

</table>


<table border=0 width=100% cellspacing=0 cellpadding=0>

<tr>

 <td valign="top">
 <font face="arial, helvetica" size="1"><b>
 <a href="index.php3?catList=26">bash</a>
 </b></font>
 </th>

 <td valign="top" align="right">
 <font face="arial, helvetica" size="1"><b>
 <a href="/cdn-cgi/l/email-protection#066b736a69466b676d636b6364676228686372"> 
 mulo</a>
 at 30 September, 21:43:22 </font></b>
 </td>

</tr>
</table>

<table border=0 width=100% cellspacing=0 cellpadding=0>
<tr width=100%>
<td>

<font face="arial, helvetica" size="2">
To lowercase files in current $PWD

#!/bin/sh
for x in *
do
  newx=`echo $x | tr "[:upper:]" "[:lower:]";`
  mv "$x" "$newx"
  echo "$x --> $newx"
done
</font>

</td>
</tr>

<tr>
<td>
&nbsp;
</td>
</tr>

</table>


<table border=0 width=100% cellspacing=0 cellpadding=0>

<tr>

 <td valign="top">
 <font face="arial, helvetica" size="1"><b>
 <a href="index.php3?catList=26">bash</a>
 </b></font>
 </th>

 <td valign="top" align="right">
 <font face="arial, helvetica" size="1"><b>
 <a href="/cdn-cgi/l/email-protection#ddb7b5b4b9bcb1bab29db4bef0b4a9beaff3bcbef3beaf"> 
 Jose</a>
 at 30 September, 21:43:33 </font></b>
 </td>

</tr>
</table>

<table border=0 width=100% cellspacing=0 cellpadding=0>
<tr width=100%>
<td>

<font face="arial, helvetica" size="2">
For one fast and effective `clear' use
<code>echo e='\ec'</code>

It does more that `clear'
</font>

</td>
</tr>

<tr>
<td>
&nbsp;
</td>
</tr>

</table>


<table border=0 width=100% cellspacing=0 cellpadding=0>

<tr>

 <td valign="top">
 <font face="arial, helvetica" size="1"><b>
 <a href="index.php3?catList=11">admin</a>
 </b></font>
 </th>

 <td valign="top" align="right">
 <font face="arial, helvetica" size="1"><b>
 <a href="http://www.mi2.hr"> 
 marcell</a>
 at 30 September, 21:44:02 </font></b>
 </td>

</tr>
</table>

<table border=0 width=100% cellspacing=0 cellpadding=0>
<tr width=100%>
<td>

<font face="arial, helvetica" size="2">
Don't forget to compile alsa drivers if you use 2.4.x kernel after you did make modules modules_install.
</font>

</td>
</tr>

<tr>
<td>
&nbsp;
</td>
</tr>

</table>


<table border=0 width=100% cellspacing=0 cellpadding=0>

<tr>

 <td valign="top">
 <font face="arial, helvetica" size="1"><b>
 <a href="index.php3?catList=27">programming</a>
 </b></font>
 </th>

 <td valign="top" align="right">
 <font face="arial, helvetica" size="1"><b>
 <a href="http://"> 
 malkav</a>
 at 30 September, 21:44:18 </font></b>
 </td>

</tr>
</table>

<table border=0 width=100% cellspacing=0 cellpadding=0>
<tr width=100%>
<td>

<font face="arial, helvetica" size="2">
How to search recursively through your source code directories and find all your java files with foo.

find . -name '*.java' -exec grep -li foo {} \;</font>

</td>
</tr>

<tr>
<td>
&nbsp;
</td>
</tr>

</table>


<table border=0 width=100% cellspacing=0 cellpadding=0>

<tr>

 <td valign="top">
 <font face="arial, helvetica" size="1"><b>
 <a href="index.php3?catList=19">network</a>
 </b></font>
 </th>

 <td valign="top" align="right">
 <font face="arial, helvetica" size="1"><b>
 <a href="/cdn-cgi/l/email-protection#6500170c06250204170b00094b060a08"> 
 Eric Garnel</a>
 at 30 September, 21:44:37 </font></b>
 </td>

</tr>
</table>

<table border=0 width=100% cellspacing=0 cellpadding=0>
<tr width=100%>
<td>

<font face="arial, helvetica" size="2">
quick & dirty dhcp client script
(works on redhat, maybe others...)
/sbin/ifdown eth0;/sbin/ifup eth0;
ping <some external address>

Alternatively use ifconfig eth0 down; ifconfig eth0 up;</font>

</td>
</tr>

<tr>
<td>
&nbsp;
</td>
</tr>

</table>


<table border=0 width=100% cellspacing=0 cellpadding=0>

<tr>

 <td valign="top">
 <font face="arial, helvetica" size="1"><b>
 <a href="index.php3?catList=26">bash</a>
 </b></font>
 </th>

 <td valign="top" align="right">
 <font face="arial, helvetica" size="1"><b>
 <a href="http://"> 
 nexz</a>
 at 30 September, 21:44:50 </font></b>
 </td>

</tr>
</table>

<table border=0 width=100% cellspacing=0 cellpadding=0>
<tr width=100%>
<td>

<font face="arial, helvetica" size="2">
Finding out all the commands installed on your box?

At the prompt, press tab twice and it will ask you if you want to see all the commands. Say y and it will show you all the commands that you installed on your box including shell syntax. Very easy to find out and to familiar yourself with the commands you don't know (btw, this only searches according to path variable set in bash login files).

But be careful if you are the root; try <command> --help or man page first before blindly type into it.

If all the commands listed are in single column and you can't see the top, edit .bash_profile or .bashrc to include this alias: alias ls="ls -C". Then you should be able to see all. One other alternative might be to increase the buffer for the terminal so that it will hold more characters.

Hope this helps!</font>

</td>
</tr>

<tr>
<td>
&nbsp;
</td>
</tr>

</table>


<table border=0 width=100% cellspacing=0 cellpadding=0>

<tr>

 <td valign="top">
 <font face="arial, helvetica" size="1"><b>
 <a href="index.php3?catList=11">admin</a>
 </b></font>
 </th>

 <td valign="top" align="right">
 <font face="arial, helvetica" size="1"><b>
 <a href="http://"> 
 DJ</a>
 at 30 September, 21:46:49 </font></b>
 </td>

</tr>
</table>

<table border=0 width=100% cellspacing=0 cellpadding=0>
<tr width=100%>
<td>

<font face="arial, helvetica" size="2">
I usually use this PS1 in the default /etc/profile
<p>
This way users will always know where they're located
<p>
bash:<br>
export PS1='\t \u@\h \w $ '</font>

</td>
</tr>

<tr>
<td>
&nbsp;
</td>
</tr>

</table>


<table border=0 width=100% cellspacing=0 cellpadding=0>

<tr>

 <td valign="top">
 <font face="arial, helvetica" size="1"><b>
 <a href="index.php3?catList=13">rpm</a>
 </b></font>
 </th>

 <td valign="top" align="right">
 <font face="arial, helvetica" size="1"><b>
 <a href="http://ryan.barrett.name"> 
 Ryan</a>
 at 30 September, 21:45:01 </font></b>
 </td>

</tr>
</table>

<table border=0 width=100% cellspacing=0 cellpadding=0>
<tr width=100%>
<td>

<font face="arial, helvetica" size="2">
Sometimes the rpm database gets fscked, and every attempt to rpm just hangs, even rpm --rebuilddb. This is a recurring bug in rpm. To fix it, do this as root:
<p>
rm -f /var/lib/rpm/__db.00*<br>
rpm --rebuilddb
<p>
Remember that rpm --rebuilddb doesn't output anything by default and often takes a while, especially for a complete rebuild like this. So don't worry if it sits there for a while. (You can check that it's actually running with top.)</font>

</td>
</tr>

<tr>
<td>
&nbsp;
</td>
</tr>

</table>


<table border=0 width=100% cellspacing=0 cellpadding=0>

<tr>

 <td valign="top">
 <font face="arial, helvetica" size="1"><b>
 <a href="index.php3?catList=28">emacs</a>
 </b></font>
 </th>

 <td valign="top" align="right">
 <font face="arial, helvetica" size="1"><b>
 <a href="/cdn-cgi/l/email-protection#8efdefede6efcee8fcebeba0e0ebfaa0fee6"> 
 Sacha Chua</a>
 at 8 March, 13:46:10 </font></b>
 </td>

</tr>
</table>

<table border=0 width=100% cellspacing=0 cellpadding=0>
<tr width=100%>
<td>

<font face="arial, helvetica" size="2">
<a href="http://www.emacswiki.org">EmacsWiki (http://www.emacswiki.org)</a> is an excellent Emacs site with tons of tips.</font>

</td>
</tr>

<tr>
<td>
&nbsp;
</td>
</tr>

</table>

<table width=600 border=0><tr><td align="left" width=33%>
<font face="arial, helvetica" size=2>
</font></td><td align="center" width=34%>
<font face="arial, helvetica" size=1>
results 1 through 15</font></td><td align="right" width=33%>
<font face="arial, helvetica" size=2>
<var><b><a href="index.php3?catList=&step=15">next 15</a></b></var>
</font></td></tr></table>
<p>&nbsp;</p>

<center>
<table align="center" border=0 width=600>
<tr><td align="center">
 <font face="arial, helvetica" size="2" color="#858585">
 &nbsp; | &nbsp; <a style="color: #454545" href="/addtip/">Add tip</a>
 &nbsp; | &nbsp; <a style="color: #454545" href="/articles/">Articles</a>
 &nbsp; | &nbsp; <a style="color: #454545" href="/categories/">Categories</a>
 &nbsp; | &nbsp; <a style="color: #454545" href="/links/">Links</a> 
 &nbsp; | &nbsp; <a style="color: #454545" href="/random/">Random</a>
 &nbsp; | &nbsp; <a style="color: #454545" href="/">Tips</a>
 </font>
</td></tr>
<tr><td align="center">
<form method="post" action="/search/index.php3?search">
<font face="arial, helvetica" size="1">
<input type="text" name="searchString" size=40 value="">
<select name="searchCat">
	<option>All</option>
	<option value=11>admin</option>
<option value=15>apache</option>
<option value=26>bash</option>
<option value=35>browser</option>
<option value=1>console</option>
<option value=20>database</option>
<option value=31>e</option>
<option value=28>emacs</option>
<option value=14>email</option>
<option value=3>file manipulation</option>
<option value=17>filesystems</option>
<option value=24>freebsd</option>
<option value=21>hardware</option>
<option value=18>irc</option>
<option value=6>job control</option>
<option value=9>kernel</option>
<option value=8>misc</option>
<option value=19>network</option>
<option value=33>openbsd</option>
<option value=22>printing</option>
<option value=27>programming</option>
<option value=12>programs</option>
<option value=34>python</option>
<option value=13>rpm</option>
<option value=23>samba</option>
<option value=2>security</option>
<option value=10>sendmail</option>
<option value=25>sound</option>
<option value=16>ssi</option>
<option value=7>system</option>
<option value=29>vi</option>
<option value=4>window maker</option>
<option value=5>X</option>
<option value=30>zsh</option>
</select>
<input type="hidden" name="search" value="search">
<input type="submit" name="button" value="search">
</font>
</form>
</td></tr>
</table>
</center>


<p>
 <hr width="250" align="left" color="#777777" height="1">
 <font size="-2" color="#555555">
 Copyright 1998-2004
 <a href="http://srparish.net">Scott Parish</a> and
 <a href="http://schvin.net/">George Lewis</a>.<br>
 Send feedback to <a href="/cdn-cgi/l/email-protection#7403111619150700110634011a1d0c001d04075a1b0613"><span class="__cf_email__" data-cfemail="710614131c100205140331041f1809051801025f1e0316">[email&#160;protected]</span></a>.
 </font>

</font>
</td>
</tr>
</table>

<script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script></body>
</html>

