Unix & Perl Quick Reference by vinsads1


									A & D’s Unix & Perl Quick Reference
Command passwd logout Description Set your login password terminate login session fg jobs kill ps top move a background process to the foreground list background processes stop a running process list my running processes and their status show a list of running processes (all users) fg %1 Jobs kill %1 kill -9 1234 ps -u username top

Getting help
Command man command apropos word Description Display manual entry for command" List manual entries related to "word" Example man fortune apropos sex

Command date find Description show current date/time search the directory tree for a file display last commands used Interactively communicate with another user show information about logged in users show current user name Example date find . -name 'lostfile' -print History

Command cat chmod cp diff grep head more mv rm tail gzip gunzip tar Description Concatenate and display files modify access permissions to a file copy files compare two files and list the differences search for a string inside files print the first lines of a file display contents of files page by page move or rename a file remove or delete a file display last lines of a file compress a file to file.gz decompress a file produce an archive (file.tar) of a set of files unarchive directories and files Example cat myfile cat file1 file2 > bothfiles chmod 755 myfile cp file1 copy-of-file1 cp file1 subdir/copiedfile diff file1 file2 grep word file grep "two words" file head somefile more mylongfile mv oldfile newname mv oldfile subdir/newfile rm trashfile tail longfile gzip file gunzip file.gz tar cvf file.tar files tar xvf file.tar



talk someone@host.domain.net

w / who




tcsh tricks
Command up/down arrows right/left arrows tab key ^D Alias Description browse through the las commands Move in the command line complete word or command Show alternatives for word or command completion list/define alternate names for commands Example ^| |v <- -> ->| ^d alias alias nuke "rm -ri"



Command cd ls ls –al ls -lt ln -s mkdir pwd rmdir df -k quota -v

Description changes current directory list contents of a directory list full contents List full contents by date last modified create a shortcut to a file or directory create a directory print current working directory remove a directory show free space on disks show disk space available to me (user)

Example cd subdir cd .. ls directory ls –al directory ls –lt directory ln –s mkdir subdir pwd rm -i subir/* ; rmdir subdir df –k quota -v

Command about word del dir less ren

Description list manuals of commands related to "word" remove a file after asking for confirmation show an "annotated" directory listing display a file one screen at a time rename a file asking before overwriting anything

Example about celibacy del oldfile dir subdir less mylongfile ren oldfile subdir/newfile


show a file one screen at a time

type longfile

Mega Useful Stuff Command grep –c ‘>’ file.fasta sort –n +X file Description count no of sequences in a FASTA file sort ‘file’ numerically on field X count hits in a BLAST output file open a text based web-browser to URL show differences between file1 and file2 create a test file show list of recent commands show information on other users count lines words and characters in a file Interactively talk to another logged in user

I/O redirection

grep –c ‘Query= ‘ blast.out
Example Ls -l > directory.listing sort -k9 < directory.listing Ls -l | sort -k9 | less

Command > < |

Description send output to a file get input from a file use output of first command as input for the second

lynx URL diff file1 file2 touch history finger wc

Process control

Command ^Z ^C bg

Description suspend the current job stop current job put a stopped process in the background

Example ^z ^c bg


A & D’s Unix & Perl Quick Reference
FTP commands Command ftp somehost ls ls –al bin get Description Open an ftp transfer to somehost list files on remote host directory list full contents on remote host Set transfer type to binary Transfer file from the remote host To the local machine transfer files from the remote host transfer file to the remote host transfer files to the remote host Example ftp snap.mcb.harvard.edu ls directory ls –al directory bin get file Unix and Perl character codes Code \a \n \r \t \f \e \d \D \w mget *.pdf put file mput *.pdf \W \s \S ^ $ Matches Alarm (beep) Newline Carriage return Tab Formfeed Escape A digit, same as [0-9] A nondigit A word character (alphanumeric), same as [azA-Z_0-9] A nonword character A whitespace character, same as [\t\n\r\f] A non-whitespace character Anchor at start of line Anchor at end of line

mget Put Mput

To top