Skip to main content Skip to navigation

Linux Basiscs

BASICS COMMANDS

ls Shows the home directory.

ls -al Lists all the files in the directory inclusive of hidden files.

ls ~/directoryname Lists the contents of directoryname regardless of the current working directory position

mkdir directoryname Makes a new directory having name directoryname

mkdir ~/directoryname Make a directory in home directory having name directoryname

mkdir ../directoryname Make a directory in the parent directory having name directoryname

cd ~/directoryname Change the current working directory to the directory directoryname present in home directory

cp file1 file2   Make a copy of file1 in the current working directory and give it a name of file2

cp -r dir1 dir2 Make a copy of directory1 and give it a name directory2.

mv file1 file2 Move file1 and give it name file2, used for renaming file

rm file1 Delete file1 from current directory

rmdir directoryname Remove directory having name directoryname from current directory

grep Searches files for specific words or sentences

top | grep user1 Show the functions and command only given by user1 

cat file1 Show the contents of file1

cat > fil1 Redirect the standard output to file1

cat >> file1 Append standard output to a file1

less file1 Show the contents of file1 page by page

head file1 Show the first few lines of file1

tail file1 Show the last few lines of file1

kill -9 process number Kill the process indicated by process number

cp *.f directoryname Copy files of format .f in the directory directoryname

run convert Convert all initial data to new one and used for compilation of convert.f in Solar

convert.e Executes the commands in convert.f in Solar

run ch It compiles the main program ch.f

nohup ch.e > result & It executes the program and redirect the output to file "result" and executes program in background

scp userid@faraway.csc.warwick.ac.uk:input_May05 . Copying file input_May05 to the local machine with the same name

scp input_May05 userid@faraway.csc.warwick.ac.uk:. Copying file input_May05 to the remote machine with the same name

/usr/bin/time -v valgrind --tool=callgrind ./a.out Profiling to optimise the code

kcachegrind Using visual software kcachegrind

valgrind --tool=memcheck ./a.out Checking for any memory allocation problem through compilation of code in gfortran with -g option for debugging

rsync -avd --include='*/' --include='tautotal1.dat' --exclude='*' . /media/My\ Passport/SIMULATION-DATA-Backup/ This commands copy the tautotal1 file from all the sub-directories from the current directory to /media/My\ Passport/SIMULATION-DATA-Backup/ with the same subdirectory structure.

rsync -anvd --include='*/' --include='tautotal1.dat' --exclude='*' . /media/My\ Passport/SIMULATION-DATA-Backup/ The -n addition in -avd will show you the file which it will transfer but it does not transfer in actual so that you can see that which files can be transferred.

meld tautotal1.dat tautotal-old.dat & Graphic version of the diff command. It is a KDE command.

for x in *.eps; do convert $x `basename $x eps`pdf; done This command converts all the *.eps files in the working directory to *.pdf with the same filename .

for i in *; do mv "$i" 3nm_"${i##*_}"; done

find . -name "*.dat" -exec rename .dat .plt {} \; This command changes theextension of multiple files with *.dat extension to *.plt

for i in `find . -name "restrt-64_129_64-248-3.dat"` ; do echo $i ; done This for loop goes through each sub directory from the current directory and finds for name of file restrt-64_129_64-248-3.dat in each subdirectory and then list thembyusing echo command.

for i in `find . -name "restrt-64_129_64-248-4.dat"` ; do mv $i `dirname $i`/../run1/restrt-64_129_64-248-3.dat ; done This command will find all the files in every of the sub directory of the current directory and then it will go one level back from that directory, in which restrt-64_129_64-248-4.dat file is found and then go into run1 directory at that level and move the restrt-64_129_64-248-4.dat from its previous location to the present directory i.e run1, with the new name restrt-64_129_64-248-3.dat.

gdb GNU debugger, used for backtracking

 /usr/bin/time -v valgrind --tool=memcheck ./a.out &> errors.dat The ampersand "&" before the output means that standard error will be written to erros .dat and without & means that standard output will be written to to the errors.dat and /usr/bin/time -v command tells the time of execution at the end of program.

 tail -f errors.dat The last few lines of errors.dat file is shown and -f means that output is appended dynamically as the file grows

 ~/usr/local/bin/valgrind --tool=memcheck --track-origins=yes ./a.out &> errors.dat To use the new version of valgrind which backtraces the origins of the un intilaised values

 

du -h V1.01.584 Gives the total size of directoryV1.01.584

du * -h . This command will list the size of each sub directories in human readable format .

gfortran SHARED_DATA.f90 MASS_CALC.f90 PROFILES.f90 FLOW_FIELD.f90 COFF_CALC.f90 BOUNDARY_CONDITIONS.f90 SOLVERS.f90 SETUP.f90 COMPUTE_RIGHT.f90 COMPUTE_LEFT.f90 FFT.f90 MULTIGRID.f90 POISSON_SOLVER.f90 POISSON_SOLVER_BLOCK.f90 LES_CALC.f90 UPDATE_FIELD.f90 ran1.f90 fourier.f JET_FLOW.f90 MAIN.f90 -lfftw3 -g && ~/usr/local/bin/valgrind --tool=memcheck --track-origins=yes ./a.out &> errors.dat

This command will compile the V1.01.584 with gfortan in debugging mode and then run the executable file with new version of valgrind with backtrace of uninitialized values (if any) in the same go by using && and then re-direction the standard output as well as standard error file to errors.dat.

wget http://valgrind.org/downloads/valgrind-3.4.0.tar.bz2 This command will download valgrind-3.4.0.tar.bz2 from the link http://valgrind.org/downloads/valgrind-3.4.0.tar.bz2

tar -xjvf valgrind-3.4.0.tar.bz2 This command will unzip this zipped packege by using flags -xjvf.See man tar for more details

set terminal postscript enhanced This command is used to plot graphs by using gnuplot in ps format.

set output "hello.ps" This command must immmediately follow the upper one and the post script file name will be hello.ps.

plot '../transition/tautotal1-xza.dat' w l, 'tautotal1-xza.dat' w l The command will send the data in these files in ps format to hello.ps instead of outputting it to main screen.

cat /proc/cpuinfo To see the information about the computer hard disk, memory,RAM,processor speed.

Procedure to see the memory map of a program using valgrind for a given number of grid points

  1.  valgrind --tool=massif ./a.out
  2. ms_print massif.out .<pid> | less

Where pid is a number which will be created i.e. massif.out.2000 at the end of first step.

 

valgrind --tool=callgrind ./a.out && kcachegrind The command is to check the run time consumed in each subroutine of the code.

 

set multiplot layout 2,2 It is a command in GNUPLOT which draws 4 figures (2 rows and 2 columns) on the output screen.

 

Imagemagick is the software in linux which can place more figures sides by sides by using montage and then it can be named with any extension for later use in Latec. For more details do man imagemagick.

When we write something in Latec then we can compile either by using LATEC or PDF LATEC.LATEC only takes EPS or ps images while PDF LATEC usese all other files extensions except EPS but one can use EPS in PDFLATEC by converting them to pdf by using pstopdf convertor .Beamer uses PDFLATEC.

 

CTRL+D is the command to comment out the select lines in Kile and CTRL+SHIF+D is the command to uncomment. We can have quick preview of the individual frame in Kile by selecting (highlighting) the individual frame and then right click mouse button and then selecting quick preview option instead of compiling whole code again in Beamer.

 

convert is the best option to convert one type of image into other.Try man convert for more details. For example convert test.jpg test.ps converts test.jpg to test.ps file (using ghostscrript)

 

 uname -a Tells the description of computer.

 

cd - Goes to the last directory.

 

xrandr -o 1 Rotates the screen by 90 degree clockwise


xrandr -o 0 Rotates back the screen to original positon

 

find . -type d -maxdepth 1 -mindepth 1 List ONLY subdirectories in the existing directory

 

nm a.out Tells about the symbols of each libraries and the executable.

 

nm a.out | grep fft Greps the symbol containing name fft

 

./configure --prefix=/home/esrgai/usr/local CC=icc F77=ifort Makes the make files in folder home/esrgai/usr/local.

 

make -j 3 Compiles all the Makefile in directory /home/esrgai/usr/local.

 

make install Installs the software and it will generate lib and include (bin and shared optional) in the directory /home/esrgai/usr/local.

 

fftw = -L/home/esrgai/usr/local/lib -lfftw3 Puts this into your makefile to tell the compiler from where to get lfftw3.

 

montage k-2-fine-residual.png k-3-fine-residual.png -geometry 1167x525+10+10 -tile 1x2 finegrid-residual.png This command pastes two figures into one figure with one above other with pixel 1167x525with 10 pixle border.

 

montage fine-P-k1-restr.png fine-P-k2-restr.png -geometry 1167x525+10+10 -tile 1x2 -title Fin-grid-Residual -font Times-New-Roman-Regular -pointsize 20 fine-P-residual.png This command produces two figures one above other with a title in new roman font with font size 20 in pixels.

 

java -jar JabRef-2.4.2.jar This command in directory /hom/esrgai/jab-ref opens a jab-ref for creating *.bib files.

 

Pre-processing compiling and linking PETSc

Modules to be loaded

1) intel-fc-9.1.040-x86_64

2) mpich2-1.0.3-intel-9.1-x86_64

3) intel-cc-9.1.045-x86_64

4) intel-mkl-10.0.5.025-x86_64

du -sh * ./ This command will show the human readable size of all sub directories and files in the current directory

du -sh */ This command will show the human readablesize of all sub directories ONLY in the current working directory.

mpi compilers on Godzilla

 a) mpich2-1.0.7-intel-10.1-x86_64

 b) intel-mkl-10.0.5.025-x86_64

 

when we put -lfftw3 in compiler option then compiler looks for fftw3.so first (in case of shared library) or fftw3.a (in case of static archive library) which can be located by writing locate libfftw3 and when we want to give the path to the compiler that where to look the file during the compilation that is by -L/directory name -lfftw3 which, in the case of locating fftw on SKUA, is -L/home/esrgai/usr/local/lib -lfftw3 because the libfftw3.so is in directory /home/esrgai/usr/local/lib

 

callgrind_control -b

 valgrind ./a.out &> result Sends the standard output as well as error to result file.

 ./a.out -mat_view >result Shows the matrix entries which are put by user in PETSC in the result file.

meld penta-output.dat petsc-output.dat & This command shows two files side by side with highlighting the differences between files by different colours

 ./a.out -h This command shows different option for PETSC in standard output

-mat_view_draw -draw_pause -1 To physically see the picture of matrix

mat_view_info Gives the info of the matrix

 ./a.out -ksp_view To view solution convergence

 source ~/.bashr c To execute/run bashrc files if any changes are made.

which mpirun Tells the full path of the command mpirun which is standared mpi command which is replaced by mpiexec in newer mpi versions

 -traceback -CB To trace back error on any intel compiler

modules on SKUA

 a) module load intel-fc-9/9.1.040

 b) module load intel-cc-9/9.1.045

 valgrind --tool=callgrind ./a.out

 callgrind_control -b To backtrace dynamically

module on franceca

 module load intel/ompi-1.3-64

 

/usr/bin/time -v mpiexec -np 2 ./a.out

/usr/bin/time -v ./a.out -pc_type asm -ksp_gmres_restart 200 > result

usr/bin/time -v valgrind --tool=callgrind ./a.out -ksp_view -info -pc_type asm > result

 /usr/bin/time -v valgrind --tool=callgrind ./a.out -ksp_view > result

mpiexec -np 2 xterm -e gdb ./a.out

 

./configure CC=gcc FC=gfortran --prefix=/gpfs/esrgai/usr/local To compile the fftw3 on francesca.

ldd ./a. out Print shared libraries dependency.

/usr/bin/time -v mpiexec -np 4 valgrind --tool=callgrind ./a.out To profile multiprocessor job

 

 

rsync -ruav --timeout=30 esrgai@francesca.csc.warwick.ac.uk:/gpfs/esrgai/TEST_SIMULATIONS/NEW_SIMULATIONS_12-05-2010/NEW_UNSTEADY/RAMP-UP/tp-5/sim8/ /media/FREECOM\ HDD/2d_filtering-Data/NEW_UNSTEADY/NEW_UNSTEADY/RAMP-UP/tp-5/sim8 :

 

This command updates all the files in directory /media/FREECOM\ HDD/2d_filtering-Data/NEW_UNSTEADY/NEW_UNSTEADY/RAMP-UP/tp-5/sim8 and the files are updated from remote server from esrgai@francesca.csc.warwick.ac.uk:/gpfs/esrgai/TEST_SIMULATIONS/NEW_SIMULATIONS_12-05-2010/NEW_UNSTEADY/RAMP-UP/tp-5/sim8/

 

makeindex nomenclature.nlo -s nomencl.ist -o nomenclature.nls


%s/home\/esrgai/home\/eng\/esrgai/g : Replaces the root directory path names


qsub -I -q fat -l nodes=1:ppn=1,pvmem=10gb,walltime=00:30:00 -X: for interactively accessing GUI on Minerva.

 

SUB VERSION CONTROL

svnadmin create ./repos This command creates a new repository names as repos in the current directory

svn import ./temp file:///home/esrgai/svn-test/repos/ This command imports the contents of "./temp"directory to the "repos" repository which can include files and sub directories.

svn import ~/CHAN_CODE/V1.01.598 file:///home/esrgai/SVN-VERSIONS/IBM/V2.01.001 -m "initial import" This command imports all the files/sub directories in the ~/CHAN_CODE/V1.01.598 diretory to the repositrt directory V2.01.001.

Now if we want to checkout the directory V2.01.001 for editing than we should move to the directory /location where we want to have the working copy ofV2.01.001 and then type

svn checkout file:///home/esrgai/SVN-VERSIONS/IBM/V2.01.001

svn status -u -v Gives the detail of all changes made after the last commit.

svn diff > patchfile The differences in all files made after the last commit are moved to patchfile.

svn log Gives the one line overview of the changes made at every revision.

svn log -r 27 SOLVERS.f90 Gives the log of 27th revision of SOLVERS.f90.

svn diff -r 26 SOLVERS.f90 The present working copy of SOLVERS.f90 is compared with the revision 26 of SOLVERS.f90 in repository.

svn diff -r 26 27 SOLVERS.f90 The revision 26 of SOlvers.f90 is compared with revision 27 of SOLVERS.f90 in the repository.

svn checkout -r 1729 # Checks out a new working copy at r1729

svn update -r 1729 # Updates an existing working copy to r1729

svn delete file:////home/esrgai/svn-test/repos/ This will delete all the files and sub direcotries in th repos repository

svn list file:////home/esrgai/svn-test/repos This command will list all the files and sub directories in the repos repository.

 

Matlab curvefitting

 

Import data :

D=dlmread('mass-history-les_FULL_RANGE.dat')

col1=A(:,1)

col2=A(:,2)

cftool

 

 

 

mencoder -oac copy -ovc copy -o output.avi input1.avi input2.avi

 

split -l 50000 -a 3 pdf-2d-yp-1.dat yp1

 

 

Correct embedding of avi files

First set bitrate of all files:

mencoder file.avi -ovc lavc -lavcopts vcodec=mjpeg:vbitrate=1257 -o out1.avi

Then to combine files:

mencoder -oac copy -ovc copy out1.avi out2.avi -o final.avi

Running Macros through starccm

 

Load module : module load starccm

starccm+ -rsh ssh

starccm+ -rsh ssh -np 2 -batch d23.java

 

Using Hector

Login : talha@login.hector.ac.uk

Unload cray compiler : module unload PrgEnv-cray/4.0.30

Load pgi compiler : module load PrgEnv-pgi

Load fftw compiler : module load fftw/3.3.0.0

 

budgets : show you the AUs left for the project

checkScript que.pbs : it tells you that how much AUs will be cost