linux:shellcommands
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| linux:shellcommands [2015/07/25 02:05] – [In top command] admin | linux:shellcommands [2022/10/29 16:15] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 20: | Line 20: | ||
| ==== date ==== | ==== date ==== | ||
| * set date< | * set date< | ||
| - | date +%Y%m%d -s " | ||
| - | date +%T -s " | ||
| date +%Y%m%d -s " | date +%Y%m%d -s " | ||
| date +%T -s " | date +%T -s " | ||
| - | date +%Y%m%d -s " | ||
| - | date +%T -s " | ||
| </ | </ | ||
| * display date< | * display date< | ||
| Line 33: | Line 29: | ||
| * convert unixtime< | * convert unixtime< | ||
| date -d @1098181096 | date -d @1098181096 | ||
| - | </ | + | </ |
| + | * sync time:< | ||
| + | ntpdate | ||
| + | </ | ||
| ===== file and directory commands ===== | ===== file and directory commands ===== | ||
| ==== dirname ==== | ==== dirname ==== | ||
| Line 44: | Line 43: | ||
| ls -1 | ls -1 | ||
| </ | </ | ||
| - | ==== find ==== | + | ==== find files in directory==== |
| - | find . -name dev | + | <code bash> |
| + | find . -name filename | ||
| + | </ | ||
| ==== ln ==== | ==== ln ==== | ||
| ln [OPTION]... TARGET [LINK_NAME] | ln [OPTION]... TARGET [LINK_NAME] | ||
| Line 56: | Line 57: | ||
| df -ah | df -ah | ||
| df -h | df -h | ||
| + | ==== lock/unlock file and directory ==== | ||
| + | <code bash> | ||
| + | cd / | ||
| + | lsattr -a | ||
| + | -------------e- ./web | ||
| + | ----i--------e- ./. | ||
| + | -------------e- ./.. | ||
| + | -------------e- ./dns | ||
| + | -------------e- ./mail | ||
| + | </ | ||
| + | And remove this attribute< | ||
| + | chattr -i / | ||
| + | </ | ||
| ===== Shell Security ===== | ===== Shell Security ===== | ||
| ==== chmod ==== | ==== chmod ==== | ||
| chmod a+w | chmod a+w | ||
| => | => | ||
| - | ===== Job and process commands ===== | + | ===== Job and process, threads |
| ==== whereis ==== | ==== whereis ==== | ||
| whereis java | whereis java | ||
| Line 123: | Line 137: | ||
| apache | apache | ||
| </ | </ | ||
| - | ==== check memory information ==== | + | ==== Check memory information ==== |
| Memory space is divided into memory **used by processes, disk cache, free memory and memory used by kernel** | Memory space is divided into memory **used by processes, disk cache, free memory and memory used by kernel** | ||
| Some basic parameters in memory information: | Some basic parameters in memory information: | ||
| Line 265: | Line 279: | ||
| 00007f1b27b18000 | 00007f1b27b18000 | ||
| 00007f1b31f4a000 | 00007f1b31f4a000 | ||
| + | </ | ||
| + | ==== Get all threads of process ==== | ||
| + | * Get all threads in linux< | ||
| + | ps -efL | ||
| + | </ | ||
| + | * Get all threads of MySQL(base on config **thread_cache_size**):< | ||
| + | ps -efL | grep mysql | ||
| </ | </ | ||
| ===== List Open Files for Process ===== | ===== List Open Files for Process ===== | ||
| Line 331: | Line 352: | ||
| => get content none sign "#" | => get content none sign "#" | ||
| ==== sed ==== | ==== sed ==== | ||
| - | sed is a program used for editing data | + | Basic syntax:< |
| - | + | sed -i ' | |
| - | * Example search and replace string< | + | </ |
| + | Explain options: | ||
| + | * -i = --in-place (i.e. save back to the original file) | ||
| + | The command string: | ||
| + | * s = the substitute command | ||
| + | * original = a regular expression describing the word to replace (or just the word itself) | ||
| + | * new = the text to replace it with | ||
| + | * g = global (i.e. replace | ||
| + | Below are some basic examples for searching and replaccing | ||
| cat intro | cat intro | ||
| + | </ | ||
| The Unix operating system. Unix system | The Unix operating system. Unix system | ||
| - | + | </ | |
| - | sed ' | + | * Substitute Unix with UNIX: <code bash> |
| - | The UNIX operating system. Unix system | + | sed ' |
| - | + | </ | |
| - | sed --in-place ' | + | The UNIX operating system. Unix system</ |
| - | + | * Substitute Unix with UNIX in file intro: <code bash> | |
| - | sed ' | + | sed --in-place ' |
| + | </code> | ||
| + | * Substitute Unix with UNIX<code bash> | ||
| + | sed ' | ||
| </ | </ | ||
| * example with -n option< | * example with -n option< | ||
| - | sed -n ' | + | sed -n ' |
| - | => Just print the first 2 lines | + | * Just print lines containing UNIX: <code bash> |
| sed -n '/ | sed -n '/ | ||
| - | => Just print lines containing UNIX | + | </code> |
| * example Deleting Lines< | * example Deleting Lines< | ||
| sed ' | sed ' | ||
| - | => Delete lines 1 and 2 | + | </ |
| + | * Delete all lines containing UNIX:< | ||
| sed '/ | sed '/ | ||
| - | => Delete all lines containing UNIX | + | </code> |
| + | * Delete all characters before string< | ||
| + | sed ' | ||
| </ | </ | ||
| ==== awk ==== | ==== awk ==== | ||
| Line 522: | Line 556: | ||
| ( rsync is a program that behaves in much the same way that rcp does, but has many more options and uses the rsync | ( rsync is a program that behaves in much the same way that rcp does, but has many more options and uses the rsync | ||
| The rsync remote-update protocol allows rsync to transfer just the differences between two sets of files across the network connection, using an efficient checksum-search algorithm described in the technical report that accompanies | The rsync remote-update protocol allows rsync to transfer just the differences between two sets of files across the network connection, using an efficient checksum-search algorithm described in the technical report that accompanies | ||
| - | <code bash> | + | * rsync in local<code bash> |
| - | rsync -avz | + | rsync -avz |
| + | </ | ||
| + | * rsync to remote host< | ||
| + | rsync -avz --exclude=" | ||
| </ | </ | ||
| ==== rsync on windows ==== | ==== rsync on windows ==== | ||
| Line 559: | Line 596: | ||
| 00000520 T Java_HelloWorldJNI_sayHelloWorld__ | 00000520 T Java_HelloWorldJNI_sayHelloWorld__ | ||
| 00000534 T Java_HelloWorldJNI_sayHelloWorld(int0_t) | 00000534 T Java_HelloWorldJNI_sayHelloWorld(int0_t) | ||
| - | ==== svn ==== | + | |
| - | Create script to checkout on linux: | + | |
| - | <code bash> | + | |
| - | # | + | |
| - | SVN_USER=" | + | |
| - | SVN_PASS=" | + | |
| - | SVN_REPO=" | + | |
| - | SVN_SOURCE="/ | + | |
| - | WEB_SOURCE="/ | + | |
| - | svn checkout $SVN_REPO --username $SVN_USER --password $SVN_PASS $SVN_SOURCE/ | + | |
| - | rsync -auvz --exclude=" | + | |
| - | svn checkout http:// | + | |
| - | </ | + | |
| ===== Cygwin ===== | ===== Cygwin ===== | ||
| ==== Install Cygwin ==== | ==== Install Cygwin ==== | ||
linux/shellcommands.1437789957.txt.gz · Last modified: (external edit)
