|
| 1 | +# OpenFOAM Linux Cheat Sheet |
| 2 | + |
| 3 | +## contents |
| 4 | +1. File & Directory |
| 5 | +2. Text |
| 6 | +3. Binary & Package |
| 7 | +4. Process & Environment |
| 8 | +5. Redirection |
| 9 | + |
| 10 | +## File & Directory |
| 11 | +**mkdir [OPTION]... DIRECTORY...** |
| 12 | +* **-p** make parent directories |
| 13 | + |
| 14 | +```bash |
| 15 | +$ mkdir -p $FOAM_RUN |
| 16 | +``` |
| 17 | + |
| 18 | +**cp & mv** **[OPTION]... [-T] SOURCE DEST** |
| 19 | + **[OPTION]...SOURCE...DIRECTORY** |
| 20 | +> forest comment: It's really a problem to input the continuous space in Markdown file. In previous contents of this file, as shown above, I use 中文的空格 to creat the multi-space effect. While, maybe there should be some extent before the 中文的空格. This should be discussed. |
| 21 | +
|
| 22 | +* **-b** make a backup of each existing destination file |
| 23 | +* **-n** do not overwrite an existing file |
| 24 | +* **-i** prompt before overwrite |
| 25 | +* **-r** copy(move) directories recursively |
| 26 | + |
| 27 | +```bash |
| 28 | +$ cp -r $FOAM_TUTORIALS . #注意$FOAM_TUTORIALS有个默认的路径,这个意思是把这个目录复制到当前文件下。 |
| 29 | +``` |
| 30 | + |
| 31 | +**rm** [OPTION]... FILE... |
| 32 | +* **-f** never prompt |
| 33 | +* **-i** prompt before every removal |
| 34 | +* **-r** remove directories recursively |
| 35 | + |
| 36 | + |
| 37 | +```bash |
| 38 | +$ rm -ri 0\.[^o]* |
| 39 | +``` |
| 40 | + |
| 41 | +**ln TARGET... DIRECTORY** |
| 42 | +* **-s** soft link |
| 43 | + |
| 44 | +```bash |
| 45 | +$ ln -s /opt/openfoam30/doc/Guides-a4/UserGuide.pdf ~/Desktop/UserGuide |
| 46 | +``` |
| 47 | + |
| 48 | +**touch [OPTION]... FILE...** |
| 49 | + |
| 50 | +```bash |
| 51 | +$ touch cavity.OpenFOAM # 新建一个算例的数据文件,可以用paraview打开。 |
| 52 | +``` |
| 53 | + |
| 54 | +**chmod [OPTION]...MODE[,MODE]...FILE... |
| 55 | + [OPTION]...OCTAL-MODE FILE...** |
| 56 | + |
| 57 | +```bash |
| 58 | +$ chmod +x Allrun # 提高Allrun文件的执行权限 |
| 59 | +``` |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | +> forest: be added and revised |
| 65 | +find |
| 66 | +[OPTION] [path…] [expression] |
| 67 | +$ find tutorials/ -name simpleFoam |
| 68 | +locate |
| 69 | +[OPTION]... PATTERN... |
| 70 | +$ locate interPhaseChangeFoam.C |
| 71 | +Text |
| 72 | +echo |
| 73 | +[SHORT-OPTION]... [STRING]... |
| 74 | + -e |
| 75 | +enable interpretation of backslash escapes |
| 76 | +$ echo -e '\n'$FOAM_SRC'\n' |
| 77 | +less |
| 78 | +[FILE]... |
| 79 | +$ less $WM_PROJECT_DIR/Allwmake |
| 80 | +vi |
| 81 | +[FILE]... |
| 82 | +$ vi ~/.bashrc |
| 83 | +grep |
| 84 | +[OPTIONS] PATTERN [FILE...] |
| 85 | + -i |
| 86 | +ignore case distinctions in both the PATTERN and the input files |
| 87 | + -h |
| 88 | +Suppress the prefixing of file names on output. |
| 89 | +$ grep -ih build $WM_PROJECT_DIR/Allwmake |
| 90 | +Binary & Package |
| 91 | +whereis |
| 92 | +[-bmsu] filename... |
| 93 | + -b |
| 94 | +Search only for binaries |
| 95 | +$ whereis -b paraview |
| 96 | +whatis |
| 97 | +name ... |
| 98 | +$ whatis evince |
| 99 | +man |
| 100 | +[OPTION] page… |
| 101 | +$ man chmod |
| 102 | +apropos |
| 103 | +[OPTION] keyword… |
| 104 | +$ apropos plot |
| 105 | +apt-get |
| 106 | + |
| 107 | + update |
| 108 | +resynchronize the package index files |
| 109 | + upgrade |
| 110 | +install the newest versions of all packages currently installed on the system |
| 111 | + install |
| 112 | +install packages |
| 113 | + remove |
| 114 | +uninstall packages |
| 115 | +$ sudo apt-get install openfoam4 |
| 116 | +apt-cache |
| 117 | + |
| 118 | + search |
| 119 | +perform a full text search on all available package lists |
| 120 | +$ apt-cache search openfoam |
| 121 | +Process & Environment |
| 122 | +ps |
| 123 | +[OPTIONS] |
| 124 | + -e |
| 125 | +see every process on the system |
| 126 | +$ ps -e |
| 127 | +kill |
| 128 | +[options] <pid> [...] |
| 129 | + -9 |
| 130 | +send SIGKILL |
| 131 | + -l |
| 132 | +list signal names |
| 133 | +$ kill -9 12974 |
| 134 | +env |
| 135 | +[OPTION]... [-] [NAME=VALUE]... |
| 136 | +$ env | grep ^FOAM_ |
| 137 | +alias |
| 138 | +[-p] [name[=value] ... ] |
| 139 | +$ alias mv='mv -i' |
| 140 | +source |
| 141 | +FILE... |
| 142 | +$ source /opt/openfoam30/etc/bashrc |
| 143 | +Redirection |
| 144 | +command1 > file1 |
| 145 | +execute command1, placing the output in file1 |
| 146 | +command1 >> file1 |
| 147 | +append output to the end of the file |
| 148 | +command1 < file1 |
| 149 | +execute command1, with file1 as the source of input |
| 150 | +tr a-z A-Z << END_TEXT |
| 151 | +read from a stream literal |
| 152 | +command1 | command2 |
| 153 | +executes command1, using its output as the input for command2 |
| 154 | +Copyright © 2016 Zhang Qi |
0 commit comments