command [options] [parameters]
------------------------Positioning------------------------
CD webapps/--Navigate to WebApps
Cd.. --Go back to the parent directory
CD---go back to the previous directory
CD--Back to home directory
--Displays the full path of the current file
Pwd
--Clear screen
Ctrl+l
------------------------Show------------------------
LS--Display file list
---show more information
Ll-h (file shown in KB)-A (Show All files)-D (Show current folder non-folder content)
Eg:ll-h/data/www/
------------------------Directory------------------------
mkdir test--Create a new folder
Mkdir-p Test/test2--Recursive Create folder (-p for recursion)
RmDir Test--delete folder (must be an empty folder)
---Recursive Delete file (directory) command (do not use the-R to perform all files-f means enforce without prompting)
RM-RF Webroot.zip
--Copy files to the pointing directory (cut MV)
CP-RF Linux.txt/data/backup
---View all directories under Folders
Find-type d (All folders)
Find-type f (All files)
------------------------file------------------------
--View File contents
Cat Jdbc.properties
--Make the file in edit mode
VI Database.propertie
--activate edit mode, save exit (do not save exit)
I esc:wq! (: q!)
--Replace file (replace 58.68.237.36 all to 127.0.0.1)
Sed-i ' s/58.68.237.36/127.0.0.1/g ' Database.propertie
--Screen scrolling command
Ctrl+u: First half screen to file
Ctrl+d: Half-screen to the end of the file
------------------------Upload and download------------------------
--Upload (prompts to select a folder after executing the command)
Rz-by
--Download the file (the file will be downloaded directly, the default directory can be viewed in Option-x/y/zmodem)
Sz
------------------------Link Command------------------------
ln adms.log/home/test/adms.log.hard--hard link (similar to a copy of a file)
Ln-s adms.log/home/test/adms.log.hard--Soft link (shortcut)
-----------------------------File Lookup----------------------------------
--Class Database Lookup
--locate (Database index Lookup)
Eg:locate Install.log
--updatedb (does not immediately index the newly created file database, this command can be updated)
--System Command Lookup
--whereis (System command lookup-show file location and help document)
Eg:whereis Ls/whatis Ls/whoami
--which (Show command aliases)
--Directory Lookup
--find (retrieves the entire directory consumption resources)
(1) Find/home-name Adms.log--Exact match (case insensitive-inname not differentiated)
(2) Find/home-name "adms.log*"--matches files beginning with Adms.log
(3) Find/home-name "adms.lo[gm]*"--matches any one of the characters within the brackets (only one is qualified)
--Search by Time
Find/var/log-mtime +10 (+10 10 days ago, 10 days before,-100 days)
--Search by size
Find/home-size 25k (+-= range, 25m--find megabytes file note case)
Eg:find/home-size +1k-a-size-5k (find files greater than 1k or less than 3k or-O)
--File Search
--grep (Retrieving a file)
grep "url" adms.log
-----------------------------help Command----------------------------------
Man passwd--display first command help document by default
Man-f passwd--See a few help documents to interpret
Man 4 passwd--View corresponding to the fourth kind of interpretation
--Query the Help document that contains the keyword command
Man-k passwd
-----------------------------Compression Decompression----------------------------------
--zip
Zip Log.txt.zip log.txt--Compress files
Zip-r img.zip img--Compression directory
Unzip-o Log.txt.zip/img.zip--Unzip the file/directory (the same file will appear overwritten)
unzip-d./img_new./img.zip (unzip the file into the Img_new directory of the current directory)
Unzip-v Img.zip (view files under compressed package file)
--View the size of the uncompressed directory
DU-HS img
--Current Directory Decompression war package
JAR-XVF Game.war
--gzip
Gzip Log.txt--source files disappear after compressing files
Gzip-r img--only the sub-files in the directory are compressed
Gunzip log.txt.gz/gzip-d log.txt.gz--Unzip the file
--BZIP2 (only files can be compressed)
Bzip2 Log.txt--The source file disappears after compressing the file
Bzip2-k Log.txt--The source file does not disappear after compressing the file
BUNZIP2 log.txt.bz2/bunzip2-d log.txt.bz2--Unzip the file
--tar (Pack)
TAR-CVF img.tar img (-c means keep source file-V display compression process-F Specify compressed file name)
TAR-XVF Img.tar--Decompression (-X)
Then compress eg:
Gzip Img.tar
Bzip2 Img.tar
--tar Direct Compression
TAR-ZCVF img.tar.gz img--Compressed into tar.gz
TAR-JCVF img.tar.bz2 img--Compressed into tar.bz2
TAR-ZXVF img.tar.gz--Decompression tar.gz
TAR-JXVF img.tar.bz2--Decompression tar.bz2
--Compress to the specified directory (compressed name to write absolute path)
tar-zcvf/home/img.tar.gz img
--Compress multiple files (to compress files separated by spaces)
tar-zcvf/home/img.tar.gz IMG1 Img2
--Extract to the specified directory (add-c after the specified directory--c uppercase)
TAR-ZXVF IMG.TAR.GZ-C/tmp
-----------------------------Mount Command----------------------------------
--Hanging on the disc (that is, the inserted disc can be found in the catalog)
(1) Set up a mount point (accustomed to the MNT directory)
Mkdir/mnt/cdrom
(2) Hanging on disc (/dev/sr0 similar to drive)
Mount/dev/sr0/mnt/chrom
(3) View disc contents
Cd/mnt/chrom-->ls
(4) run out of uninstall (you will not be able to uninstall if you want to exit the current directory)
Umount/mnt/chrom
--Mount USB Drive
(1) View drive letter
Fdisk-l
(2) Mounting USB stick
Mount-t Vfat/dev/sdb1/mnt/usb
Note: 1.SDB1 is a drive letter name (will vary) 2.VFAT refers to FAT32 (usually USB stick)
Note: NTFS files are not supported by Linux by default, drivers need to be installed, and data cannot be written
-----------------------------Shutdown Restart----------------------------------
Shutdown-r 02:30--two days and a half morning restart
CTRL + C--Interrupt current command
Shutdown-r 02:30 &--two days and a half morning restart (put the command in the background does not occupy the current terminal)
Shutdown-h--Restart
Shutdown-c--Cancels the previous shutdown command
-----------------------------Other Commands----------------------------------
--View the current time of the system
Date
--Update the user password (need to enter the original password)
sudo passwd root
--Switch User (WWW user cannot perform restart command)
Su
--Write an executable script
exe.sh
#!/bin/bash--Must be written here
echo "Ni hao!"
--Give executable permission
chmod 755 exe.sh
./exe.sh--Run command set
--Query login user Information
W
--Query System login Restart time/Last login time
Last/lastlog
------------------------Permissions------------------------
Chown-r www.www *
Linux Common commands