Linux Common commands
One, the format of the Linux command
1. command [options] [parameters]
Lslist displaying content in the directory
① command name: ls
Command English original: list
Command path:/bin/ls
Execute Permissions: All Users
Function Description: Display directory file
②ls Name Direct Enter, display the contents of the directory
Ls-l long format display (thumbnail option with a minus sign, complete option with two minus)
-RW-------1 root root 1190 08-10 23:37 anaconda-ks.cfg
First entry:-RW-------permission bit
Second entry: 1 reference count
Third item: Root owner
Fourth item: Root Group
Fifth item: 1190 size
Sixth item 08-10 23:37 last modified time
Seventh Item anaconda-ks.cfg file name
Ls-a Show all files (including hidden files)
Ls-al
The Ls-hl file size is displayed as a common size unit BKBMB
ls-d display the directory itself, not the child files inside
Ls-l file name
Prompt: (special characters)
[Email protected] src]#
[Current login user @ hostname current directory]#
#超级用户
$ normal User
Current directory: ~ User home Directory
Administrator/root
Normal User/home/user name
Second, directory Operation command
1) The directory where the CD is switched
① Command name: CD
Command English original: Change directory
Command path: Shell built-in command
Execute Permissions: All Users
②cd/usr/local/src
Relative path: Look for the current directory. Be sure to first determine the current directory. Root] #cd. /usr/local/src
Absolute path: CD/USR/LOCAL/SRC is specified from the root directory, and a recursive lookup is found at the first level. In any directory, access to the specified location
CD ~ Enter the current user's home directory/root/home/aa/
Cd
CD-Go to last directory
Cd.. Go to the top level directory
CD. Go to the current directory
2) PWD Displays the current directory
Command name: pwd
Command English original: Print working directory
Command path:/bin/pwd
Execute Permissions: All Users
3) Common Linux directories
/root directory
/bin command to save directories (commands that ordinary users can read)
/boot directory to start related files
/dev Device File save directory
/etc configuration File Save Directory
Home directory for normal users
/MNT System Mount Directory
/media Mount Directory
/root home directory for super users
/tmp Temp directory
/sbin command to save directory (a directory that can be used by super users)
/proc write directly to memory
/USR system software Resources directory
/usr/bin/system command (normal user)
/usr/sbin/system command (super User)
/var system related document content
/var/log/System Log Location
4) Create a directory
mkdir Directory Name
Command name: mkdir
Command English original: Make directories
Command path:/bin/mkdir
Execute Permissions: All Users
Mkdir-p 11/22/33/44 Recursive build directory
5) Delete Directory
RmDir directory can only delete empty directories
Command name: rmdir
Command English original meaning: remove empty directories
Command path:/bin/rmdir
Execute Permissions: All Users
Third, the file Operation command
1) Create an empty file or modify the file time
Touch file name
Command name: Touch
Command path:/bin/touch
Execute Permissions: All Users
2) Delete
RM-RF file name
-R Delete Directory
-F Mandatory
Command name: RM
Command English original meaning: remove
Command path:/BIN/RM
Execute Permissions: All Users
3) Cat file name View all file contents
Command name: Cat
Command path:/bin/cat
Execute Permissions: All Users
-N List Line numbers
4) More filename split screen display file contents
Command name: more
Command path:/bin/more
Execute Permissions: All Users
Space down page b page up Q exit
5) Head file name shows the first 10 lines of the file tail
Command name: Head
Command path:/usr/bin/head
Execute Permissions: All Users
Head-n number of rows file name specifies the first n rows of the display files
Head-n 20 file name
HEAD-20 file name
CTRL + C forced termination
Ctrl+l Clear Screen
6) Linked files
ln
Command name: LN
Command English original meaning: link
Command path:/BIN/LN
Execute Permissions: All Users
Shortcut
New links that occupy different hard disk locations
Modify a file, both change
Delete source file, soft connection cannot open
Ln-s source file The file name must write absolute path
Iv. commands that can be manipulated by files and directories
1) RM Delete file or directory
2) Copy
Command name: CP
Command English Original: copy
Command path:/BIN/CP
Execute Permissions: All Users
CP Source file target Location
-R Copy Directory
-P Joint File attribute copy
-D If the source file is a linked file, copy the link property
-A equals-pdr
CP aa/tmp/formerly copied
CP aa/tmp/bb renamed Copy
3) Cut or rename
Command name: MV
Command English Intent: move
Command path:/BIN/MV
Execute Permissions: All Users
MV Source File Destination location
mv/root/aa/tmp/
MV AA BB
V. Rights Management
1 Permission Bits
-rw-r--r--1 root root 0 08-11 01:45 AA
The permission bit is 10 bits
First bit: Represents the file type
F Common Files
D catalog File
L Link File
Nine-bit master permissions u=user Group permissions G=group others rights o=other
R-Read 4
W Write 2
X execution 1
2 Modify Permissions
chmod
Command name: chmod
Command English Original: Change the permissions mode of a file
Command path:/bin/chmod
Execute Permissions: All Users
chmod u+x AAAA file owner plus execute permission
chmod u-x AA
chmod g+w,o+w AA
chmod u=rwx AA
chmod 755 AA
chmod 644 AA
3 Permission meanings:
1) permissions on the meaning of the file
R: Read file contents cat more head tail
W: Edit, add, modify file Contents VI echo Nano
But does not contain delete files
X: Executable
2) permissions on the meaning of the directory
R: Can query the directory under the file name LS
W: has permission to modify the directory structure. such as creating new files and directories, deleting files and directories under this directory, renaming files and directories under this directory, cutting touch RM MV CP
X: Access to the catalog CD
4 Generic and Group commands
Chown
Command name: Chown
Command English Original: Change file ownership
Command path:/bin/chown
Execute Permissions: All Users
Chown user name filename Change file owner
Chown User1 Aauser1 must exist
Chown user1:user1 aa Change Genus master simultaneous change group
Useradd User name Add user
passwd User Name set user password
Vi. Help Commands
1man command name Help for viewing commands
Command name: Man
Command English original meaning: manual
Command path:/usr/bin/man
Execute Permissions: All Users
2 command--help Common options for viewing commands
Vii. Find Commands
1whereis command name find commands for command, and see Help document location
Command name: Whereis
Command path:/usr/bin/whereis
Execute Permissions: All Users
2find Search Command
Command name: Find
Command path:/usr/bin/find
Execute Permissions: All Users
Find by file name
Find Find location-name file name
Find/-name aabbcc by file name
-iname Search by file name, case insensitive
by user
-user user name to find files according to the master user name
-group group names find files by group name
-nouser to find documents that are not owned by the Lord
by file type
-type type Find by file type F: normal D: Directory L: Link
by permissions
Find/root-perm 644 Search by permissions
by file size
-size-5k +5k k M G
Two-time filter
-exec command {} \;
3grep "string" file name finds the word serial that matches the criteria.
Command name: grep
Command path:/bin/grep
Execute Permissions: All Users
Grep-i "Root"/etc/passwd
-V Reverse Selection
-I ignores case
4 Pipe Break
Command 1 | Command 2 execution result of command 1, as the execution condition of command 2
Cat file name | grep "string" Extracts a line containing a string
grep "string" file name
Ls-l/etc | More split screen display LS content
Viii. Compression and decompression
. gz.bz2linux common compression formats that can be recognized
. tar.gz.tar.bz2 common compression and packaging commands
Compress and package at the same time
TAR-ZCVF compressed file name source file
TAR-ZCVF aa.tar.gz AA
-Z recognition. gz format
-C: Compression
-V: Show compression process
-F: Specify the name of the compressed package
TAR-ZXVF compressed file name decompression and unpacking
TAR-JCVF compressed file name source file compression at the same time package
TAR-JCVF aa.tar.bz2 AA
TAR-JXVF AA.TAR.BZ2 Solution Package Simultaneous decompression
View Puzzle Package
TAR-ZTVF aa.tar.gz View Puzzle Package
TAR-JTVF aa.tar.bz2
-T only view, no pressure
TAR-JXVF root.tar.bz2-c/tmp/Specify the decompression position
Ix. closing and restarting commands
1) shutdown-h now no special case, use this command
-H shutdown
-R Restart
Shutdown-r now
Command name: Shutdown
Command path:/sbin/shutdown
Execute permissions: Root
2) reboot
Command name: Reboot
Command path:/sbin/reboot
Execute permissions: Root
Ten, Mount command
All Linux storage devices must be mounted for use, including hard drives
Command name: Mount
Command path:/bin/mount
Execute Permissions: All Users
CD mount
/DEV/SDA1 First partition of the first SCSI hard drive
/dev/cdrom Disc
/DEV/SR0 Disc
Mount device description File mount point (empty directory already exists)
Mount/dev/cdrom/mnt/cdrom
CD Uninstall
Umount/dev/cdrom
Umount/mnt/cdrom Focus: Exit the mount directory before uninstalling
Fdisk-l View Device Name/DEV/SDA/DEV/SDB/DEV/SDC
Mount/dev/sdb1/mnt/usb
Umount/mnt/usb (exit mount point) Uninstall
XI. Network Command
1ifconfig Query Native Network information
Command name: ifconfig
Command English original meaning: interface configure
Command path:/sbin/ifconfig
Execute permissions: Root
2ping Testing of network connectivity
Command name: Ping
Command path:/bin/ping
Execute Permissions: All Users
PING-C Frequency IP Detection network unobstructed
Linux (ii) common Linux commands