Linux beginners need to understand the Bash command operation skills to share

  

Bash is the abbreviation of Bourne-Again SHell, is the shell of many Linux platforms, in fact, Bash command has many operating skills, many beginners may not know, master these Skills can get the job done faster, let's learn together.

tab key complement usage

When we tap once on the tab completion command or file name

When we tap twice on the tab lists all the relevant Optional

cd - equivalent to TV look back

Sometimes we enter a very long directory, and then enter another directory, maybe we still go back to the original long, if Know in advance, we may enter pwd, in order to paste in a while, sometimes forget to enter pwd we may have to enter a long path, we can type cd - try, go directly back to the last entry directory, just like It is a look back button when watching TV. Is it very useful?

View the following example

[root@localhost /]# cd /tmp

[root@localhost tmp]# pwd

/tmp

[root@localhost tmp]# cd /

[root@localhost /]# pwd

/

[root@localhost /]# cd -

/tmp

[root@localhost tmp]# pwd

/tmp

Esc+.

Usage Examples

First touch a file, then edit this file

touch abcdefghijk

Type vi, then Esc+. Find out if abcdefghijk has appeared after vi\\

Escape character usage

Some commands in the system are alias functions, such as rm, mv, etc. we use, actually rm -i and mv -i.

To view system aliases, use the alias command, such as the default alias for the following system.

[root@localhost testdir]# alias

alias cp=‘cp -i’

alias egrep=‘egrep --color=auto’

alias fgrep=‘fgrep --color=auto’

alias grep=‘grep --color=auto’

alias l.=‘ls -d .* --color=auto’

alias ll=‘ls -l --color=auto’

alias ls=‘ls --color=auto’

Alias ​​mv=‘mv -i’

alias rm=‘rm -i’

alias which=‘alias |  /usr/bin/which --tty-only --read-alias --show-dot --show-tilde’

Sometimes when we delete a file, the following prompt will appear, we need one by one Confirm, the reason is that rm defaults to rm -i.

[root@localhost testdir]# cd dir1

[root@localhost dir1]# ls

file1 file2 file3 file4

[root@localhost dir1 ]# rm file1 file2 file3 file4rm: remove regular empty file ? .ile1? . y

rm: remove regular empty file ? .ile2? . y

rm: remove regular empty file ? .ile3? . y

rm: remove regular empty file ? .ile4? . y

We can use the transfer character to invalidate the alias, use the following, delete will not be prompted again.

[root@localhost testdir]# cd dir1

[root@localhost dir1]# ls

file1 file2 file3 file4

[root@localhost dir1 ] # \ m file1 file2 file3 file4

The above is the introduction of the bash command's operation skills. If you want to learn the fine, it is not enough to master the command, but also apply some operational skills flexibly, so that you can get twice the result with half the effort. Have you learnt that?

Copyright © Windows knowledge All Rights Reserved