Linux commands (1) and linux commands (

Source: Internet
Author: User

Linux commands (1) and linux commands (

Linux commands

In the linux environment for work and study, we spend more time beating our fingers on the keyboard. Here, let's talk about how to use linux commands.
In a linux environment, you obviously cannot write down all the commands and their usage rules. At this time, the man and help commands are particularly important.
For man commands, emphasize
For the level and scenario of the command we need to find, pay attention to the seat check.
The second is to tell us that the options provided on the man page usually need to be noted: DESCRIPTION, return value )..

Search for a string in man in the following way:/str up search ,? Str search up
Eg: Find the ls character in the manual:/ls
Then press N (next)

FILE command

Ls-list Directories
Ls-al-list hidden files with formatting
Cd dir-Change directory to dir
Cd-change to home directory
Pwd-display the current directory
Mkdir dir-create directory dir mkdir-p dir1/dir2-recursively create dir1, which contains dir2
Rm file-delete file rm-r dir-delete directory dir
Rm-f file-force delete file rm-rf dir-force Delete directory dir *
Cp file1 file2-copy file1 to file2
Cp-r dir1 dir2-copy dir1 to dir2; Create dir1 if dir2 does not exist
Mv file1 file2-Rename or move file1 to file2; If file2 is an existing Directory, move file1 to file2
Ln-s file link-create a symbolic link for file
Touch file-Create file
Cat> file-add standard input to file
More file-View file Content
Head file-view the first 10 rows of file
Tail file-view the last 10 rows of file
Tail-f file-view the file content from the last 10 lines

Process Management

Ps-display current active process pstree-Tree display process
Top-display all running processes
Kill pid-kill process id pid kill-l-display signal information
Killall proc-kill all processes named proc *
Bg-list stopped or background jobs
Fg-bring the latest job to the foreground
Fg n-bring job n to the foreground

File Permission

Chmod octal file-change file Permissions
● 4-read (r)
● 2-write (w)
● 1-execution (x)
Example:
Chmod 777-Add read, write, and execute permissions to all users
Chmod 755-add rwx permissions to the owner and rx permissions to the group and other users
For more options, see man chmod.

SSH

Ssh user @ host-connect to the host as a user
Ssh-p port user @ host-connect to the host as a user in the port
Ssh-copy-id user @ host-Add the key to the host for password-less Login

Search

Grep pattern files-search for files that match pattern
Grep-r pattern dir-recursive search for the content matching pattern in dir
Command | grep pattern-search for the content matching pattern in the command output

System Information

Date: displays the current date and time.
Cal-display calendar of the current month
Uptime-display the system running time from startup to now
W-display logon users
Whoami-view your current user name
Finger user-displays user-related information
Uname-a-display kernel information
Cat/proc/cpuinfo-view cpu Information
Cat/proc/meminfo-view memory information
Man command-display command instruction manual
Df-Displays disk usage
Du-displays the directory space usage
Free-Display memory and swap zone usage

Compression

Tar cf file.tar files-create a tar file containing files
File.tar
Tar xf file.tar-Extract files from file.tar
Tar czf file.tar.gz files-create with Gzip Compression
Tar file
Tar xzf file.tar.gz-use Gzip to extract tar files
Tar cjf file.tar.bz2-use Bzip2 to compress and create a tar file
Parts
Tar xjf file.tar.bz2-use Bzip2 to extract the tar file
Gzip file-compress the file and rename it file.gz
Gzip-d file.gz-decompress file.gz to file

Network

Ping host-ping host and output results
Whois domain-Get whois information of domain
Dig domain-Get DNS information of domain
Dig-x host-reverse query host
Wget file-download file
Wget-c file-resumable upload

Install from source code

./Configure
Make
Make install
Dpkg-I pkg. deb-installation package (Debian)
Rpm-Uvh pkg. rpm-installation package (RPM)

Shortcut Key

Ctrl + C-stop the current command
Ctrl + Z-stop the current command and use fg to restore
Ctrl + D-log out of the current session, similar to exit
Ctrl + W-delete words in the current row
Ctrl + U-delete the entire row
!! -Repeat the previous command
Exit-cancel the current session
* Use it with caution.

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.