Useful commands for everyday life in the Linux/Unix world |
|
|
Commands and resources |
Description |
|
|
|
|
ftp://username:*passwd*@abc.yourwebsite_html |
Ever wondered how to supply username and passwd as part of URL? |
|
|
|
|
|
|
|
echo "754b9db19f79dbc4992f7166eb0f37ce filename"|md5sum -c |
Check a file called filename against its md5 checksum. There is a double space between the sum and file name in the argument to echo– this argument is in fact the output produced by “md5sum filename”. |
|
|
|
|
bzcat filename.tar.bz2 | tar xvf - ( same as tar xvjf filename.tar.bz2) |
Decompress and extract a tarred bzipped file |
|
|
|
|
ssh-keygen -p |
change ssh-agent passphrase |
|
|
|
|
kill -1 ‘cat /var/run/syslogd.pid‘ |
Refresh the syslog process |
|
|
|
|
for i in `ls` ; do if [ -d "$i" ]; then echo "$i"; fi; done |
List subdirectories in the current directory |
|
|
|
|
for i in `ls -la *.java *.html *.pdf|grep 'Feb 19'|awk '{print $9}'`; do scp $i Othermachine:MyStuff/;done |
Find the files in the current directory with modification stamp of 'Feb 19' and copy them, using scp, to Othermachine:MyStuff/ |
|
|
|
|
a2ps --columns=2 -j -o filename.ps filename.txt |
Convert a text file to postscript, double column |
|
|
|
|
crontab fields: MINUTE(0-59) HOUR(0-23) DAYOFMONTH(1-31) MONTHOFYEAR(1-12) DAYOFWEEK(0-6) Note 0 = Sunday |
Crontab fields. |
|
|
|
|
touch -t 0104140000 /tmp/stamp |
set timestamp of /tmp/stamp to April 14,00:00, 2001 |
|
|
|
|
touch -t 04140000 /tmp/stamp |
set timestamp of /tmp/stamp to April 14, 00:00 |
|
|
|
|
scp `find ./ -newer file.txt -depth -follow -type f` igraine:CS2/. |
Find all files starting at ./ that have modification times after 'file.txt' and scp them to destination |
|
|
|
|
grep probability `find ./ -name '*'.tex -print` |
|
|
|
|
|
grep oil `find ./ -name '*.tex' -print` |
|
|
|
|
|
cat ex0.tr|grep 'tcp\|ack'|grep ' 2 3 \| 3 2 ' |
|
|
|
|
|
<meta http-equiv="Refresh" content="10;url=http://www.yourpage.com/" > |
Refresh page every 10 seconds |
|
|
|
|
latex2html -long_titles 5 -no_subdir -no_navigation -prefix "myfile” myfile .tex |
Convert LaTex to html using latex2html. |
|
|
|
|
find ./ -name '*.log' -print |xargs rm -f |
Delete all .log files, descending down from the current directory node |
|
|
|
|
find ./ -type f -atime 100 |
Files not accessed in 100 days |
|
|
|
|
find ./ -name '*.nb'|cpio -ovH tar >nb.tar |
Tar archive *.nb files |
|
|
|
|
find /etc -newer back.tar -depth -follow -type f 2>/dev/null |
Find all files in /etc and subdirectories that have modification times later than that of back.tar |
|
|
|
|
find ./ -ctime -1 -type f -exec ls -la {} \; |
|
|
|
|
|
find . -name "*" -exec grep -l "some text" {} ";" |
Find some text within an unknown file and display the name of that file. |
|
|
|
|
find ./ -ctime -1 -type f -exec scp {} linux1: \; |
Find files with modification times within the last 24 hours and scp them to some destination |
|
|
|
|
smbclient -L 192.168.1.12 |
Check available shares on smb server 192.168.1.12 |
|
|
|
|
rpm -q --whatrequires libpq.so.3 |
List of rpm packages that requires libpq.so.3 |
|
|
|
|
rpm -q --whatprovides libpq.so.3 |
rpm package that provides libpq.so.3 |
|
|
|
|
rpm -qlp /usr/local/synce-kde-0.6.1-1.i386.rpm |
List files in rpm package |
|
|
|
|
rpm -qp --filesbypkg /usr/local/synce-kde-0.6.1-1.i386.rpm |
List files in rpm package |
|
|
|
|
rpm -qpR /usr/local/synce-kde-0.6.1-1.i386.rpm |
List packages on which this package depends |
|
|
|
|
rpm -qpi /usr/local/synce-kde-0.6.1-1.i386.rpm |
Extract description of the package |
|
|
|
|
/sbin/ldconfig -p |
List all directories/libraries in current cache |
|
|
|
|
cp /var/spool/mail/yourlogin newmail; cat newmail | formail -t -s procmail -f |
TO MANUALLY PROCESS spooled mail through procmail, you need to pipe it through formail, not procmail directly. Formail splits the spool file into individual messages and pipes each of them through procmail. |
|
|
|
|
mpg123 -w xyz.wav xyz.mp3 |
convert mp3 file to wav file |
|
|
|
|
sox a.wav a.cdr |
convert .wav file to .cdr format for cdrecord to handle it |
|
|
|
|
cdrecord -v speed=32 dev=0,0,0 -audio a.cdr x.cdr y.cdr z.cdr |
Record a bunch of .cdr files to CD |
|
|
|
|
cdrdao write --driver generic-mmc --device 0,0,0 --speed 24 --eject videocd.cue |
Burn a Video CD, assuming appropriate directory structure has been set up |
|
|
|
|
ls -l | sort -nr -k 5,5 (same as ls -laS) |
Sort files by size |
|
|
|
|
for i in `ls *.exe`; do basename $i |sed -e 's/\(.*\)\..*/\1/g'; done |
Strip filenames of .exe extension |
|
|
|
|
cat f | tr -s '[:blank:]' '_' |
Replace horizontal white space in f by _ (underscore) |
|
|
|
|
ls -lA --time-style=+%Y%m%d-%T |
Display times in file listings in the format 20040829-13:57:09 |
|
|
|
|
#!/usr/bin/perl open(LIST, "ls -1 * |"); while (<LIST>) { |
List files in a directory in random order. The ”ls” command lists files in some sorted order, so if you want a randomized list, you can use this script. |
|
|
|
|
#!/bin/sh #get current date – used as backup file
prefix #work direcory for i in `cat /home/Myname/Misc/Backup/MANIFEST-DAILY`; do tar rf /home/Myname/$DATE.tar `find $i -ctime -1 -depth -type f`; done #zip it scp /home/Myname/$DATE.tar.gz remotemachine:Backup/
|
Shell script to scp non-interactively files to a remote machine. Assumes that there are NO passphrases for ssh-agent. The script finds files modified during the last day, from directories listed in the MANIFEST-DAILY plain text file, creates] a gzipped tar file and sends them to the remote machine. Useful for daily cron job. |
|
|
|
|
cat page.css|tr '\015' '\n' >page.css.0 |
replace those annoying ^M characters in a file by \n |
|
|
|
|
dd if=/dev/cdrom of=/somewhere/name_of.iso |
Will copy a CD to an ISO image file |
|
|
|
|
mount /somewhere/name_of.iso /mnt/iso/ -t iso9660 -o loop |
Will mount an ISO image file at mount point /mnt/iso |