unixtips.org

the source for unix tips ...

Recommended articles:

  • DevOps

    -

    "DevOps is an IT delivery method that brings development and operations departments closer together by combining individuals, tools, and working practices..."

Tips

samba JonH at 24 April, 13:02:59
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... mount -t smbfs //<server>/<volume> <mountpoint> To mount a windows volume... mount -t smbfs \\\\<server>\\<volume> <mountpoint>
 
file manipulation Frank Tobin at 30 October, 00:59:07

chmod -R a+rX dir will make dir and every file and directory in the tree below it readable by all (from the +r) and executable if and only if it is a directory or already executable by some user (from the +X).

 
file manipulation Saul P. at 7 October, 01:55:06
If you ever have to delete many, many files but rm returns a "too many arguments" error, use find and xargs to save the day:

find . | grep 'your_filename_filter' | xargs rm -f

Of course, you can omit piping through grep if you just want to erase the entire directory. Xargs is also usefeul for many other needs; you can take a look at this xargs tutorial if you're interested.

 
file manipulation Joe Betz at 30 September, 21:42:01
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:

chmod 664 `find * -type f -print0`
chmod 775 `find * -type d -print0`

Keep in mind that chmod -R is dangerous!

 
admin Joe Betz at 30 September, 21:42:45
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:

send:
tar cf - myfiles | ssh remotehost " ( cd /destination/path ; tar xf - ) "

get:
ssh remotehost "( cd /source/path; tar cf - desiredfiles ) " | tar xf -

multiple ssh connections can be strung together to move the file across multiple machines:

send through:
tar cf - myfiles | ssh remotehost1 " ssh remotehost2 \" ( cd /destination/path ; tar xf - ) \" "

get through:
ssh remotehost1 " ssh remotehost2 \"( cd /source/path; tar cf - desiredfiles ) \" " | tar xf -

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

Use ssh-agent and the 'ssh -A' (ForwardAgent) switch to remove the need to type passwords repeatedly.

 
freebsd rayvd at 30 September, 21:43:07
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.
 
bash mulo at 30 September, 21:43:22
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
 
bash Jose at 30 September, 21:43:33
For one fast and effective `clear' use echo e='\ec' It does more that `clear'
 
admin marcell at 30 September, 21:44:02
Don't forget to compile alsa drivers if you use 2.4.x kernel after you did make modules modules_install.
 
programming malkav at 30 September, 21:44:18
How to search recursively through your source code directories and find all your java files with foo. find . -name '*.java' -exec grep -li foo {} \;
 
network Eric Garnel at 30 September, 21:44:37
quick & dirty dhcp client script (works on redhat, maybe others...) /sbin/ifdown eth0;/sbin/ifup eth0; ping Alternatively use ifconfig eth0 down; ifconfig eth0 up;
 
bash nexz at 30 September, 21:44:50
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 --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!
 
admin DJ at 30 September, 21:46:49
I usually use this PS1 in the default /etc/profile

This way users will always know where they're located

bash:
export PS1='\t \[email protected]\h \w $ '

 
rpm Ryan at 30 September, 21:45:01
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:

rm -f /var/lib/rpm/__db.00*
rpm --rebuilddb

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

 
emacs Sacha Chua at 8 March, 13:46:10
EmacsWiki (http://www.emacswiki.org) is an excellent Emacs site with tons of tips.
 
results 1 through 15 next 15

 

  |   Add tip   |   Articles   |   Categories   |   Links   |   Random   |   Tips


Copyright 1998-2004 Scott Parish and George Lewis.
Send feedback to [email protected].