Linux Command
alias
Method 1: put your alias in .alias_pofile
Recommend use this file, will not destory .bashrc file.
1 | cd ~ |
Method 2: edit .bashrc
This method need to reboot to take effect
change directory
change folder or directory
cd : change directory to home ~ directorycd folder: change to specific directory
change upper directory
cd ..: change upper directorycd ../..: change directory to 2 upper directorycd ../folder: move upper directory and go to new direcotrycat ../folder/filename: read upper directory filename
find
- find file type
.shcommand:
find . -type f -name "*.sh"
dump or write file
EOF read multipy line into file
Example 1
1 | cat >>/etc/apt/sources.list<<EOF |
Example 2
1 | cat << EOF > /etc/samba/smb.conf |
Write and Modify File
There are some shortcut key need to know using vi linux edit tool, which often use for edit file. Some people might use nano, nvim, or vim ; this is use for often vim.
- Jump to specific line:
ctrl+G+line - search string:
/or?- search next match string:
n
- save file:
wqorx!: save and exitq!: exit without saving
- string select(visual mode):
ctrl+vselect cursor反白選取文字- copy:
y - cut:
d - paste:
p - undo:
u
- copy:
modify file with advance tool
replace string from a file
- Find and replace string to file
1
sed -i 's/oldstring/newstring/g' xxx.txt
- Search string, and replace with new string and value
SearchTddConfigCommon.PatternType = TDD2and change value likeP1orP21
2#change
sed -i "/TddConfigCommon.PatternType = /c\TddConfigCommon.PatternType = P1" /home/test/Desktop/5GScript/confChange.txt