Finding big files
find -size +50M -exec ls -lh {} \; | awk '{print $5" - "$9}'
More details about
big files
-----------------------------------------------------------------------------
Finding files:
whereis
ldd
locate
find
-----------------------------------------------------------------------------
Ubuntu:
aptitude -- Get information on package.
apt-get
sudo apt-get install build-essential -- Install gmake
sudo apt-get install gfortran-4.4 -- Install gfortran
-----------------------------------------------------------------------------
Utilities:
acroread -- Adobe Acrobat Reader
evince -- Gnome PDF Reader (use instead of ghostview).
gedit -- GUI editor
kate -- GUI editor (Replaces kwrite).
-----------------------------------------------------------------------------
Operating system (OS) information:
uname -a
cat /proc/version
To find what version of redhat is running:
cat /etc/redhat-release
Lab computers:
https://wiki.lepp.cornell.edu/lepp/bin/view/ACC/CesrComputing
cesrulib lib area:
/nfs/acc/libs/bin
-----------------------------------------------------------------------------
Mac stuff:
Taking Screenshots in Mac OS X:
Screenshot saved in file on the desktop:
Command-Shift-3: Take a screenshot of the screen
Command-Shift-4, then select an area: Take a screenshot of an area
Command-Shift-4, then space, then click a window: Take a screenshot of a window
Screenshot saved on the clipboard:
Command-Control-Shift-3: Take a screenshot of the screen
Command-Control-Shift-4, then select an area: Take a screenshot of an area
Command-Control-Shift-4, then space, then click a window: Take a screenshot of a window
In Leopard and later, the following keys can be held down while selecting an area
(via Command-Shift-4 or Command-Control-Shift-4):
Space, to lock the size of the selected region and instead move it when the mouse moves
Shift, to resize only one edge of the selected region
Option, to resize the selected region with its center as the anchor point
Mounting PC50 disk
In finder: Go->Connect to Server (Apple-K)
Server Address: smb://pc50
Proper scroll with less and man, etc:
setenv LESS -X
Converting CR/LF from Mac standard to unix:
tr "\015" "\012" < in_file > out_file
in_file and out_file may not be the same.
or run "mac2unix" command.
Xcode: Debugging with an exe not built under Xcode:
Open: Command Line Utility -> Standard Tool
Build (to get a dummy exe)
Replace exe with real one.
Run Debug
macports:
port variants -- Give variants
port info --variants -- Give variants.
port -v ... -- Verbose output.
port list -- List packages.
Info on plplot:
http://trac.macports.org/browser/trunk/dports/science/plplot/Portfile
-----------------------------------------------------------------------------
Windows Stuff:
XMing -- X Window System for connecting to Unix.
-----------------------------------------------------------------------------
Apachie xerces compile:
On OSF used:
xerces-c-src_2_6_0/src/xercesc> ./runConfigure -ptru64 -ccc -xcxx -z-std
-----------------------------------------------------------------------------
Setting up scp with scripts:
The "client" machine is the machine running the script
The "server" machine is the machine to be copied to/from.
1) Generatoe a public/provate key pair on the client machine:
ssh-keygen -t rsa
Defaults are:
Your identification has been saved i/Users/dcs/.ssh/id_rsa.
Your public key has been saved in /Users/dcs/.ssh/id_rsa.pub.
2) Copy the public key file (id_rsa.pub) to the server machine to:
~dcs/.ssh/authorized_keys
If the authorized_keys file already exists then just append the public key file.
-------------
To set up the ssh-agent daemon to hold the passphrase for the duration of a session:
1) Use sshkeychain on mac (sshkeychain.org).
-----------------------------------------------------------------------------
gmake:
VERBOSE=y -- To get verbose output.
-----------------------------------------------------------------------------
Profiling (timing of application programs):
---------------------------------
For OSF:
Manual:
man atom
man hiprof
atom is a general purpose program that can be used to "instrument" an
application program.
hiprof is a profiller that uses atom to instrument an application program
with timing analysis routines.
Example command:
atom ../bin/bmadz -tool hiprof -toolargs="-hiout textout -textout -sigdump USR1 -calltime"
This command will produce an instrumented application program in the local directory:
bmadz.hiprof
Arguments:
-toolargs Passes the arguments from atom to hiprof
-hiout textout Specifies a name for the .hiout profile file.
-textout When used with the -calltime, -cputime, or -pagefaults
options, produces a text-format profile file instead
of a binary profiling data file.
-sigdump USR1 Normally killing the program with "kill" will not produce data.
This allows the command "kill -USR1 " to produce data.
-calltime Causes hiprof to apply more precise, pthread-dependent profiling.
Running the program will produce a profile file.
---------------------------------
For Linux:
1) Compile and link program using the profiller flag: [Set EXTRA_FFLAGS and/or EXTRA_LFLAGS]
-p (ifort compiler)
-pg (ifort or gnu compiler)
2) Run program.
A gmon.out file will be produced
3) Run gprof:
gprof > out
This will create a profile of the run in file "out".
"man gprof" gives more information.
Also see:
VProf
KProf [Needs KDE]
-----------------------------------------------------------------------------
Leak Detection:
Valgrind
-----------------------------------------------------------------------------
"man tcsh" gives a list of commands and other stuff
-----------------------------------------------------------------------------
History list: (man history and man tcsh for more details)
history -- Give history list
! -- Executes command numbered
! -- Executes last command that began with .
!! -- Execute previous command.
!! | more -- Execute previous command and pipe it into more.
[M-p] -- Finds command beginning with and places it
on the command line
-----------------------------------------------------------------------------
Making X windows work after su or ksu
If you get the following error message
> xclock
X11 connection rejected because of wrong authentication.
X connection to localhost:10.0 broken (explicit kill or server shutdown).
The problem is that X uses an authentication mechanism called xauth
which runs when you log in. When you use su or ksu to switch your
identity, the xauth file of the new identity has different magic
cookies than your local X server knows about and you get the above
message.
To fix this, you need to take your original magic cookie that xauth
initially sets up and copy it into the xauth file of the new
identity. Under your original identity, do the following:
unity% echo $DISPLAY
localhost:10.0
This tells you the display number that was setup for you via SSH. In
the example the display number is 10.
unity% xauth list unix:10
linux00xen.unity.ncsu.edu/unix:10 MIT-MAGIC-COOKIE-1 79f6967b5f825931b17dfc0002f45748
Note the display number in the above command! This prints out the
cookie for your display. Put that string into your copy buffer. Next
switch to the new identity:
unity% sudo su -
Password:
# xauth add linux00xen.unity.ncsu.edu/unix:10 MIT-MAGIC-COOKIE-1 79f6967b5f825931b17dfc0002f45748
xauth: creating new authority file /root/.Xauthority
You should now have the authentication for X setup. Try running the X app and it should work.
-----------------------------------------------------------------------------
Key bindings: (man tcsh for more details)
bindkey -- Gives list of keybindings
bindkey "^o" overwrite-mode
-- Binds ^o to overwrite toggle (case sensitive).
^A -- Beginning of line (a la EMACS).
^E -- End of line.
-----------------------------------------------------------------------------
Script loop: (tcsh)
foreach file (*.txt)
set newname="$file.old"
cp "$file" "$newname"
end
To do this on the command line use ";" between lines.
-----------------------------------------------------------------------------
C++ Compiling
cxx -c -- Compiles but does not link.
-----------------------------------------------------------------------------
Man Command:
Return or Enter
Advances the display by one line.
Space Bar
Advances the display by one screen.
u Backs up the display by one half screen.
/string
Searches for the first instance of the specified string.
n Searches for the next instance of the string specified by a preceding
/string directive.
q Stops the display.
-----------------------------------------------------------------------------
Colors:
see the file for a color list:
/usr/lib/X11/rgb.txt
-----------------------------------------------------------------------------
Emacs:
F90 lisp input file:
/usr/local/share/emacs/19.34/lisp/f90.el
To Use the delete key on the mac:
1) Put the followin in .Xmodmap:
keycode 59 = Delete
2) Put the following in .Xresources:
xterm*.deleteIsDEL: true
xterm*.backarrowKey: false
xterm*.ttyModes:erase ^?
The system wide .xinitrc runs both these files at startup
To run emacs under UNIX and edit a file directly on the control
cluster via internal ftp to your $ account, you follow the
following example for the cesr29:
Ctl-x Ctl-f
Then type the following for the file name in the mini-buffer
/dcs$$@cesr29:./directory/file.txt
You will be asked for your password in the mini-buffer window.
In this case the first "." in the path will be the [cesr]
directory (I have never figured out how to do absolute paths on
VMS using Unix syntax - sigh....). Also note, you really need the
2 "$" symbols. In general, you can also use emacs to edit files on other
UNIX/LINUX (Windows too???) platforms as:
/user@computer:/directory/file.txt
/computer:/directory/file.txt
For example
/dcs@lnx6166.lepp.cornell.edu:/home/dcs/new_lib/bmad/code/bmad_parser.f90
-----------------------------------------------------------------------------
Compress/Decompression:
compress -d -- Decompress .Z files
patch -- Patch in patch file
tar/gzip:
tar cf -- Archive and name it
gzip
undo
gunzip -- Unzip a .zip file
tar xf -- Unarchive .tar files
-----------------------------------------------------------------------------
Disk Quota:
Use the du command to see how much space your files are taking up.
Use the df command to see how much space a disk has left.
/disk1 is the local disk which has no disk quota limits.
On cesr39: /cdat/cesr38/disk1 -- To path to /disk1
On lns101: /usr/sbin/quota -- Show disk quota on lns101
-----------------------------------------------------------------------------
CESR Unix machines:
CESR38 -- 500 MHz
CESR65 -- 433 MHz
CESR66 -- 1GHz, Coordinate with Zipi and Rongli Geng
-----------------------------------------------------------------------------
Copying Directories from one computer to another:
For example:
scp -r local_dir @mc66.lepp.cornell.edu:~
This could copy local_dir to the root directory on mc66.
-----------------------------------------------------------------------------
Programs available on Linux:
acroread -- Adobe Acrobat reader
gfortran -- On lnx6166
-----------------------------------------------------------------------------
Directory Stuff:
$HOME -- Home directory
~ -- Your Home directory
~welch -- Home of Welch
. -- Current directory
.. -- Parent directory
* -- Wild Card
-----------------------------------------------------------------------------
Command Line Magic:
| -- Pipe
; -- Separates commands on a line
&& -- Executes if completes OK
& -- Executes in background or with detatched process.
> -- Redirect Extablishes where output goes
>! -- Output to even with noclobber on.
>& -- Redirect both standard and error output (tcsh)
2> -- Redirect both standard and error output (bash)
>> -- Append output to
< -- Establishes where input comes from
`` -- Execute this command and put the output on
the command line.
cp `grep -l abc *` .. -- Takes all files in the current directory where
there is a match to the string "abc" and makes
a copy in the parent directory.
-----------------------------------------------------------------------------
Command List:
cat -- Type contents of on screen
cat > .... ^D -- Create with input terminated with ^D
cat > -- Concatinate and and direct result
into
cat >> -- Append and to
cd -- Change to Home directory
cd ~/ -- Change to $HOME/
cd -- Change to subdirectory
cd .. -- Change to parent directory
421421421
drwxrwxrwx -- Permission field: directory|user|group|others
chmod 777 -- Change permission
chmod +r -- Grant write permission
chmod -r -- Remove write permission
chmod +x -- Grant execute permission
chown -- Changes owner of directories or files
cp -- Copies to
cp . -- Copies to the current directory.
cp -r -- Copies recursively from one directory to another
dos2unix -- Convert from DOS CR-LF line endings to Unix LF.
dcp -- Dec copy from to
dcp lns62/dcs/xxx::"u:[...]x.y" x.y
df -- Displays disk space statistics.
du -ks . -- File size total from current directory down
du -ks * -- File size totals of sub-directories of current dir.
dvips -D -p -l -o
-- LaTex dvi to ps converter
dvips -o -f -- Default on Linux is to send output to lpr. -o gives a file.
dvips -P generic -- [Linux] Creates a .ps file suitable for conversion to pdf.
dvips -P pdf -- [OSF] Creates a .ps file suitable for conversion to pdf.
enscript -- Like lpr: Converts file to PostScript and then spools the
file to a printer.
find ~/ -name -- Finds which directory is in
find -name "" -- List files matching searching all
subdirectories of .
ghostview -- PS viewer.
gpg -c -- Encript file. code key56doc
grep -- Find lines in that contain expression
groups -- List groups is associated with.
kill -- Kill process . Also see stop.
kill -KILL -- Kill even the the SOB who otherwise ignores a plain kill
kill 0 -- Kill all processes except those with PIDs 0 and 1.
kill -KILL 0 -- This will kill even your login shell
kinit -l 7d dcs@LNS.CORNELL.EDU
-- Kerberos: Stores login password for a week.
krsh dcs@cesr66 -- Kerberos Login.
kpasswd -- Changes the user password. Also see passwd.
kpasswd dcs/net -- Change the network password (for mail).
ldd -- Shows shared object library name and location used by a program
ln -s -- Create a softlink.
ls -- List files
ls -1 -- List one file per line
ls -a -- List .* files also
ls -l -- List files with security
ls -s -- List size of each file
ls -- List files in subdirectory
ls -R -- List files and subfiles of
/usr/sbin/lsof | grep
-- Lists info about files opened by processes.
Good for the situation when rm gives a "Device or resource busy" message.
man - k -- Search 1 line descriptions for keyword
more (sys V: pg) -- Type
mkdir -- Create a directory
nm -- Shows the subroutine names in an object file.
mv -- Move (rename) to
mv . -- Move to the current directory.
passwd -- Changes the user password. Also see kpasswd.
ps -- Displays processes.
pr -- Convert text file for printing. Output to Standard Output.
pr -o 4 -- Add 4 spaces.
ps2pdf -- PDF to PS converter. Not the greatest.
pushd ~ -- Make home directory your current directory
pwd -- Displays the working directory
rm -i -- Remove with require query
rm -- Remove multiple files
rm -r -- Remove directory and all subfiles
rmdir -- Remove directory if directory is empty
rehash -- Remakes the PATH hash table.
script -- Create a log file of a shell session. "exit" ends the recording.
set -- Shows settings
set -- Sets variable. See also "unset".
set noclobber -- Prevents overwriting of files by output redirection.
screen -- For running a detached (batch like) job.
setenv DISPALY -- Open X-windows on remote node
sort -r -- Reverse sort of
sort > -- Sort and direct into
source .cshrc -- Reread .cshrc file.
spell -- Spell check
stop -- Stop (but not kill) process . "%" to restart.
sudo -s -- Run a shell with root access.
/usr/sbin/traceroute
-- Displays the communication times and the route
between computers
unix2dos -- Convert from Unix LF line endings to DOS CR-LF.
unset -- Unset something that has been set.
xev -- Program to show keystroke translations.
xfontsel -- Program to view the fonts on your computer.
xrdb -- X server resource database utility.
xrdb .Xresources -- Load .Xresources file.
xrdb -query -- Shows what has been loaded.
tac -- Output lines in reverse order. Pipe other commands to this.
top -- Show top processes on the computer (like DISPLAY)
unstripe -- Unstripes a PS file.
wc -- Word Count: Output number of lines, words, and characters in
wc -l -- Ouput number of lines in
wget -r -np -nH -cut-dirs=1
-- Get (download) file or files via the web. Can also do ftp.
[Remember to set "n" in -cut-dirs]
which -- Shows path of