Common Linux commands and common linux commands

Source: Internet
Author: User
Tags clear screen

Common Linux commands and common linux commands

1. User-related
Useradd [user name] create a user
Passwd [user name] change the password for the user
Su-User Name Switching
Exit to the root user


2. Create files and directories
(1) create a file: touch [file name]
(2) create a directory: mkdir (make directories)
Mkdir-p [directory name]
-P recursive Creation

3. Switch directory: cd (change directory)
Cd [Directory]
Simplified operation:
Cd/enter the home directory of the current user
Cd-go to the last directory
Cd .. go to the upper-level directory
Cd. Enter the current directory


4. delete a file or directory: rm (remove)
Rm-rf [file or directory]
Option:
-R: delete a directory.
-F force
(Commonly used) rm xxx-fr (force) force delete any files or folders


5. copy command: cp (copy)
Cp [Option] [original file or directory] [target directory]
Option:
-R copy directory
-P joint file property Replication
-D if the original file is a linked file, copy the link Property
-A is equivalent to-pdr.
Cp-r xxx xxxxxx copies all content in xxx to xxxxxx (-r indicates recursion)


6. cut or RENAME command: mv (move)
Mv [original file or directory] [target directory]
The original file and the target file are not in the same directory and are cut.
The original and target files are renamed in the same directory.


7. file search command:
(1) locate file name function: search by the content in the file name
Search in the/var/lib/mlocate Database
Updatedb force updates the database after the file is updated
Advantage: Quick Search and low resource consumption
Disadvantage: You can only search by file name, but not more complex content.
(2) find [search range] [search criteria]
Find/-name install. log
The file to be searched must be exactly the same as the search criteria
To implement fuzzy search, wildcards must be used.
* Match any content
? Match any character
[] Matching any character in brackets
Example: find/-name "install. log *"


8. command search commands: whereis and which
Whereis can only query system commands
Which can see the alias of the command


9. string SEARCH Command: grep
Grep [Option] string file name
# Match the matching string in the file
Option:
-I case-insensitive
-V: exclude specified strings


10. Help Command: man (manual)
Man command to get help from the specified command
The man-f command is equivalent to the whatis command.
Man-k Command command is equivalent to a keyword


11. Other help commands
Command -- help to get help of Command Options
Help shell internal commands get help from shell internal commands
Info command detailed Command help


12. compression and decompression (the compressed package is displayed in red)
(1).zip format compression:
Zip compressed file name original file compressed file
Zip-r compression file name original directory compression directory
Decompress in. zip format:
Unzip compressed file unzipped. ZIP file
(22.16.gz format compression:
The gzip source file will disappear.
Gzip-c source File> compressed file source file retained
The gzip-r directory compresses all the sub-files in the directory.
Decompress in. gzip format:
Gzip-d compressed file uncompressed .gz File
Uncompress A gunzip file. GZ File
(32.16.bz2 format compression:
Bzip2 source file will disappear
Bzip2-k source file retained
Note: The bzip2 command cannot compress directories.
. Bz2 format decompression:
Bzip.2-d compressed file-k keep compressed file
Bunzip2 compressed file-k keep compressed file
(4) tar czvf xxx.tar.gz * Create Compression
Extract tar xzvf xxx.tar.gz
(5) rpm installation software:
Rpm-ivh lftp-4.xxxxxx.rpm installation package
Rpm-e lftp uninstall the rpm package (only the package name is used without the version number)
Run rpm-ql samba to view the path of the packages released after the samba package is installed.
Run rpm-qf/etc/samba/smb. conf to view the samba package installation source.


13. Other commands
(1) shutdown: poweroff/init 0/halt/shutdown-c now (it is best not to use the first three types)
(2) restart: reboot/init 6/shutdown-r now (shutdown-h command to cancel shutdown or restart)
(3) link command: ln (link)
(4) graphic interface and non-graphic interface switch: init3 <-> startx
(5) query the current directory location: pwd (print working directory)
(6) view the ls-l = ll list
(7) ctrl + shift ++/-zoom in/out font
(8) ctrl + l clear screen
(9) view Network Information in ifconfig
(10) view the file content: cat/more
(11) check which users are logged on to the current system: who/w
(12) Desktop location:/root/Desktop
(13) double-click Tab: Prompt
(14) ctrl + shift + t open a new window on the terminal
(15) Switch alt + 1 to the first window
(16) ctrl + c stop ping
(17) view the directory size by du-sh directory name
(18) init: a user-level process started by the kernel
View previous and current levels: runlevel
#0-Shutdown (never set initdefault to 0)
#1-single-user mode
#2-multiple users without NFS
#3-full multi-user mode (standard running level)-character Interface
#4-useless
#5-graphic interface
#6-Restart (do not set initdefault to 6
(19) modify the default running level of the system: vim/etc/inittab
Id: 3: initdefault: Enter the character page
(20) exit command after xshell and other remote tools are used: logout
(21) ctrl + a move the cursor to the beginning of the command line
(22) Move ctrl + eto the end of the command line
(23) ctrl + u Delete from cursor position to first line
(24) ctrl + z place the command in the background
(25) ctrl + r collect records in historical commands
(26) ls-alh: list all files and display details
(27) date: display the current time
(28) Suicide command: sudo rm-rf/(use 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.