unixsurvivalguide522020-11-23 15:57:18OlafHauk512017-01-04 13:05:39ClareCook502017-01-04 13:03:54ClareCook492017-01-04 12:59:40ClareCook482017-01-04 12:54:17ClareCook472017-01-04 12:48:57ClareCook462017-01-04 12:44:36ClareCook452013-03-08 10:28:25localhostconverted to 1.6 markup442012-05-16 14:15:59YaaraErez432012-05-16 14:00:55JasonTaylor422012-05-16 13:56:57YaaraErez412012-05-10 14:22:37YaaraErez402012-05-01 10:25:32YaaraErez392012-04-30 11:25:06YaaraErez382012-04-26 13:59:29YaaraErez372012-04-16 16:46:54YaaraErez362012-04-13 12:59:31JasonTaylor352012-04-13 12:52:41JasonTaylor342012-04-13 12:37:43YaaraErez332012-04-10 14:27:13YaaraErez322012-03-27 11:02:24DennisNorris312012-03-22 18:13:01YaaraErez302012-03-22 17:44:35YaaraErez292012-03-22 14:44:17YaaraErez282012-03-22 12:58:48YaaraErez272012-03-22 12:57:42YaaraErez262012-03-22 12:56:47YaaraErez252012-03-22 12:55:46YaaraErez242012-03-22 12:53:02YaaraErez232012-03-22 12:52:13YaaraErez222012-03-22 12:51:49YaaraErez212012-03-22 12:51:07YaaraErez202012-03-22 12:47:47YaaraErez192012-03-22 12:45:15YaaraErez182012-03-22 12:40:36YaaraErez172012-03-22 12:37:48YaaraErez162012-03-22 12:36:59YaaraErez152012-03-22 12:32:14YaaraErez142012-03-22 12:31:57YaaraErez132012-03-22 12:31:03YaaraErez122012-03-22 11:01:08YaaraErez112012-03-22 11:00:43YaaraErez102012-03-22 10:59:29YaaraErez92012-03-21 18:58:50YaaraErez82012-03-21 18:58:22YaaraErez72012-03-21 18:57:35YaaraErez62012-03-21 18:56:56YaaraErez52012-03-21 18:55:52YaaraErez42012-03-21 18:54:55YaaraErez32012-03-21 18:53:14YaaraErez22012-03-21 18:52:01YaaraErez12012-03-21 18:31:08YaaraErezYour Survival Guide to Unix at the CBSUWhat you see below probably seems like a list of arbitrary incantations and may put you off ever going near a unix command line. However, you'll soon find that simple combinations of unix commands (possibly written as a shell script) can do things instantly that would take hours of pointing and clicking on a Mac or PC. Commands for Navigation, File Manipulation etc.Function Command Examples
Show contents of current directory ls * details: ls –l * hidden files: ls –a * output to file: ls > file.txt wild cards: ls *.txt
Change directory cd <newdir> * cd /home/myname/mydatadir * one up: cd .. (e.g. cd ../batchfiles) * to home directory: cd ~
Make directory mkdir <newdir> * mkdir ./tmp creates directory 'tmp' in current directory * mkdir ../tmp creates directory 'tmp' one level above current directory * mkdir /home/yourname/subdir/tmp creates 'tmp' in /home/yourname/subdir/ * mkdir ~/tmp creates 'tmp' in your home directory (same as mkdir /home/yourname/tmp)
Copy file/directory cp <old> <new> Copy directories: cp -r <old> <new>
Move file/directory mv <old> <new>
Delete file/directory rm <filename> delete directory: rm –r <dirname>, suppress warning prompt: rm -f <filename>
Create link between a new filename and an existing file ln <filename> <linkname> symbolic link: ln -s <filename> <linkname>, to see whether a file is "real" or a symbolic link, use ls -l
Find a file in directory structure find * find myfile.txt in current directory and below: find . -name myfile.txt * wildcards: find . -name \*results\*.txt
Find letter string within text grep grep error logfile.txt, ps -ef | grep <yourname>
See list of previous commands history
Execute command from history list !<x>, where x is number in history list e.g. !112 to get command 112 from history list
Send output of a command to text file > e.g. ls -l > listoffiles.txt, >> appends instead of overwriting
Send output of a command directly to another command ("pipes") | e.g. ls -l | grep myfile.txt
Send output of a command to text file AND standard output (screen) tee e.g. ls -l | tee listoffiles.txt, tee -a appends instead of overwriting
Run progress in background (keep command prompt) & e.g. matlab &, runmybatch.sh &
Changing access permissions chmod e.g. chmod 755 <myfile> or chmod go-w <myfile>
Changing group of a file chgrp e.g. chgrp imaging <myfile>
Create shortcut for command alias e.g. alias cd_batch "cd <mybatchdir>", alias h history
Convert text files from DOS to Unix dos2unix <filename>
Edit files nedit, emacs, vi e.g. type nedit & to keep command prompt
Help on linux commands man <yourcommand> turn page using space bar, quit typing q
Short description of commands whatis <yourcommand>
System-Related CommandsCBU Cluster Utility Functions e.g. login_load, freenodes, showallmatlab see CBU intranet
Disk usage information du estimate space usage of directories and files, e.g. du –sh /imaging/xy01/experiment1
Change linux box ssh <machine> e.g. ssh l42
Show your jobs/processes in current session jobs
Show current processes ps more details: ps -ef
Kill a process kill kill <processID>, where <processID> is from ps output
Show most CPU-intensive tasks on current processor top
Checking where an executable file is located which <filename>
Show name of current linux box hostname ip address: hostname -i
Show features of current linux box uname more details: uname -a
Check your user name whoami
Get time or date time, date
Useful TricksUse cursor keys up/down to get previous commands
Copy/paste: mark text with left mouse button, click to destination, click middle mouse button
Auto-complete commands: start typing, then “Tab” to complete to next unique possibility
Type the beginning of a previously used command, then simultaneously press Esc p to autocomplete to last used command with same beginning
Move cursor to beginning Ctrl+a or end Ctrl+e of command line
Run linux commands from within matlab using ! <command> (e.g. ! hostname) or [s,r] = unix(<command>) (e.g., [s,r] = unix('hostname')), where s returns the status (0=pass, nonzero=fail) and r is the result (e.g., 'l41').
GeneralIntro to Unix:
More computing-related intros
Primer on shell scripting
VNC (UsingVNC): start Putty, vncserver –geometry 1280x1024 –name <somename>, for OpenGL graphics: vncserver.glx -geometry 1280x1024 -name <somename>
Access home space: Windows \\home\username; Linux /home/username