Putty tool command Learning

Source: Internet
Author: User
Tags import database
1. Basic commands

A. display file source code
cat ooxx.php
Yes, cat is a common command for viewing Source Code. Its advantage is that it is very convenient and cute. The disadvantage is that all source code is directly refreshed and displayed. If the file is too long, you can only see the code behind your ass.

B. view the current directory
pwd
PWD is not a password, but a view of the current directory. The complete path is output.

C. Change directory change Directory (cd)
cd /path/to/directory/
If you have a basic dos, you should smile awkwardly. The path can be relative or absolute.

D. List Files/subdirectories listing files/subfolders (LS)
ls
By default, only the file name is displayed. You can also play with a parameter, for example
ls -alh
The output with-ALH will be nice... Try it by yourself. Big cats like to set LS-ALH to ll.
-A: displays all files.
-L detailed list
-H what humans can understand, for example, display 1024 as 1 K

E. Help
Command -- Help
If any command is followed by a-HELP command, a simple version of help will be displayed. If you cannot remember the parameters, check them.

F. Obtain the remote file wget
wget http://ooxx.me/me.jpg
You will get the remote me.jpg file to the current directory.
Let the server get data from another server, the speed will be completely different from that of men

G. compression and decompression
unzip wordpress.zip
If the file is in ZIP format, for example, if you have just obtained a compressed package from the WordPress main site wget, you only need to enter the unzip file name to decompress it to the current directory.
tar -czvf ooxx.tar.gz *
Pack all files in the current directory as ooxx.tar.gz files by using the tar command.
-C create
-Z: gzip Compression
-V shows the compression process
-F creates a file.
tar -xzvf ooxx.tar.gz
Decompress ooxx.tar.gz to the current directory.
-X Extract
-Z: gzip Compression
-V shows the compression process
-F creates a file.

2. File System commands

A. Display disk usage
df
Displays the total capacity and ratio of the entire host.

B. list file/subdirectory usage (DU)
du
Will list the size of all files and subdirectories, not viewed by people...
du -sh
-S is summary and only the total capacity of the current folder is output.
-H is generally the meaning of human in Linux, which converts 1048580b to 1 MB.
du -h --max-depth=1
Hey, only list the occupied size of the current folder and the first-level subdirectory

C. commands that are not suitable for deleting files (RM) always need to be confirmed.
rm -vf miao.in
To forcibly delete the file Miao. In, you do not need to confirm the list of deleted files.

Force Delete, do not execute, unless you know what you are doing...
-A vlike v parameter indicates a display process.
-F will words of rape be spelled out? F-U-C-K abbreviation, not sure direct F-word
rm -rf ooxx
Delete the ooxx folder, including its sub-files and sub-folders.

The following command is used to delete a file. However, when deleting a folder, you need to traverse the file.
-R is localized. It is the abbreviation of "day". It indicates recursive in all commands. Note that some commands are in uppercase.

D. copy a file (CP)
cp ooxx.me miao.in
Copy the ooxx. Me file and rename it Miao. In.

E. Move file/Rename (MV)
mv ooxx.me miao.in
Rename ooxx. Me as Miao. In
If a path is added, it is moved to a path and renamed as Miao. In.
Unlike dos, changing the way of moving files and renaming is actually a routine, isn't it?

F. Create an empty file (touch)
touch miao.in
This very pornographic command creates an empty Miao. In file.
If you touch an existing file, the file will be updated to the current date.
If the touch count is too high

3. File Permission

A. Change the File Permission (chmod)
chmod 777 miao.in
The default file is 644, And the folder is 755.

Tip:
1st digit = owner; 2nd = group; 3rd = Other
(-Rwxrwxwrx = 777,-rwxr-XR-x = 755,-RW-r-= 644, etc .)
7 = read + write + Execute
6 = read + write
5 = read + Execute
4 = read
3 = write + Execute
2 = write
1 = Execute
0 = All Access Denied

4. Advanced commands

A. Search for Common commands. Let's look for files larger than 10 MB.
find . -type f -size +10000k -exec ls -lh {} /; | awk '{ print $5 ": " $9 }' |sort -n

B. grep, holding a big watermelon in his hand
ls -alh | grep ooxx
Only the columns containing ooxx are displayed. Of course, it is very convenient for you to use it with some fields in the file during cat.

C. Paging (less/more)
less miao.php
If the source code is very long, it will be displayed on pages, the up and down arrows scroll, enter Q to exit
tail -n 1000 /var/log/httpd/error_log | more
You can use the | more parameter to scroll the page or line.

5. MySQL database

Export Database
Mysqldump-u database username-P Database Name> db_ooxx. SQL
The exported database is db_ooxx. SQL.

Import Database
Mysql-u database username-P database name <db_ooxx. SQL -- default-character-set = utf8
Import the db_ooxx. SQL in the current directory in utf8 encoding. Of course, if you were a GBK, change it to GBK.
This is often the case when a Chinese Blog is not careful ??? Question mark

6. vi

Pay attention to every key typed in vi... ...

7. Create a system-level user useradd-r user name for logging on to SSH passwd [user name]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.