linux:shellcommands
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
linux:shellcommands [2015/09/25 00:32] – [svn] admin | linux:shellcommands [2017/04/18 09:38] – [rsync] admin | ||
---|---|---|---|
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 ==== | ||
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 338: | Line 352: | ||
=> get content none sign "#" | => get content none sign "#" | ||
==== sed ==== | ==== sed ==== | ||
- | sed is a program used for editing data | + | Basic syntax:< |
+ | sed -i ' | ||
+ | </ | ||
+ | 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 all and not just the first occurrence) | ||
+ | Below are some basic examples: | ||
* Example search and replace string< | * Example search and replace string< | ||
cat intro | cat intro | ||
The Unix operating system. Unix system | The Unix operating system. Unix system | ||
- | sed ' | + | sed ' |
The UNIX operating system. Unix system | The UNIX operating system. Unix system | ||
- | sed --in-place ' | + | sed --in-place ' |
sed ' | sed ' | ||
Line 529: | Line 552: | ||
( 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 ==== |
linux/shellcommands.txt · Last modified: 2022/10/29 16:15 by 127.0.0.1