Basic operation of linux, experience of using linux

1. Commonly used commands in the terminal

Order result expand
cd
 
Switch directory (both absolute and relative paths are acceptable) cd ~ Return to the user directory (one level below the home directory)

cd .. Back to the previous directory

cd - go back to the last directory you were in
pwd Display the absolute path of the current directory
ls List the contents of the directory ls -a includes hidden files (files beginning with .)
ls -l lists all information, including file type, size, last modification time, etc.
ls -R lists all files, and further lists the files in subfolders, that is, expands all
mkdir create a new directory
is rm delete an empty directory
touch create a file
 cp Copy files or empty directories cp -r recursively copies all contents of a directory
rm Delete files or empty directories rm -r removes a directory and its contents
mv Move or rename files and directories mv filename folder path move file
mv filename1 filename2 rename file
 cat View the file content under the terminal There are extended options, but commonly used gvim view
history View command history for keystrokes After the history record is opened, copy the 100th command to the terminal via !100
grabbed -R Searches for matching characters in files under a directory

grep -R good file.v Search for the character good in the file file.v

grep -R good Search for the character good in all files in the current directory
source  Reload configuration file (or execute shell script)

Terminal split screen: ctrl+shift+t

d9c929a727744f998bf375817d6b98ce.png

 2. Configure environment variables through bash scripts

If there is a bash script in the system, you can configure environment variables through it.

Open the shell script configuration file through gvim ~/.bashrc (the configuration file usually starts with a dot and ends with rc, and is placed in the home directory and hidden, and can be viewed through ls -a). After configuration, you need to reload the configuration file through source ~/.bashrc to take effect.

2.1. Simplified command configuration (alias)

Through alias configuration, such as alias c2='cd ../..', you can easily return to the upper two-level directory. Similarly, you can also simplify the operation of opening gvim by setting g='gvim'.

c949256190cb4c2e85bb264d1038d981.png

 2.2. Configuration path

Configure the path through export ROOT=/home/..., and then enter $ROOT in the file to replace this string of paths. You can verify whether the path can jump normally through gf.

20990820f906469fa83acc7e66dfb51d.png

Guess you like

Origin blog.csdn.net/weixin_55225128/article/details/128512597