file operation:
ls View file
ls-a View all files, including hidden files (starting with.)
ls-l View file details (ll same effect)
ls-lh View file details, humanized display, File size labeling units
file Permissions
-Represents the file, D represents the directory, and L begins with a soft connection
-rw-r--r--u g o owner-owned group other people read R write W execute x
mkdir dir Creating a directory
mkdir-p dir/dir Create a directory recursively, mkdir can create multiple directories at the same time
pwd View current directory (print working directory)
CP [-RP] src des copy command-r copy directory-p preserve file attributes (can be copied to the directory, can also be copied to a file, renamed)
mv [source directory or file] [destination directory] Cut/rename (cut in the same directory is renamed)
RM [-RF] [file or directory]-r Delete directory,-f Force Delete
rmdir Delete Empty directory
touch [filename] Create file
Cat [-n] [filename] Display file contents-n Display line number
TAC [FileName] Reverse display of file contents
More [file name] Paging displays file contents, suitable for long files
[space/F] page
[carriage return] line break
[Q or Q] Exit
less [filename] More than more pageup/up can page up [/keywords] search [n] Next keyword location
head [-n][num] [filename] the NUM line before viewing the file (-n Specifies the line number)
tail [-n][num] [filename] After viewing the file num Line (-n Specifies line number)
[-F] dynamically displays changes at the end of the file
File Search:
find[Search Range] [match condition]
-name matching file name
-size matching file size
-user matching file owner
-group matching files belong to group
-a and simultaneously satisfy
- o or meet one
-type matching file types
-inum Match I node (ls-i)
locate-file name in Repository search (FAST)
The which-command searches the directory where the command is located
Grep-iv [Specify string] [file] matches the execution string output in a file
- i is case insensitive
- v excludes the specified string
Man view command Help
Help view Shell built-in command assistance
Rights Management:
only the file owner and root user can change file permissions
chmod [{Ugoa} {+-=} {rwx}] [file or directory] in the middle, separated
[421][file or directory]
- R Recursive modification
number notation (bits):
r----4,W----2,X----1
7 have all permissions
6 No Execute permission
5 No Write permission
chown[User [file or directory] to change the owner of a file or directory
chgrp[User Group [file or directory] changes the owning group of a file or directory
umask-s View default permissions for new files or directories
The default new file in Linux is not X-permission
useraddusername Adding user commands
passwdusername setting a password for username users
Modify your password and enter passwd directly
who view current logged-in user information
W View details of the currently logged in user
uptime Viewing the current machine load
Decompression Command:
gzip[file name] compress files to gzip type file
gunzip[file name] Unzip the gzip type file
tar[-zcvf][file name] [file name/directory]
- C Packaging
- v Show more information
- F Specify file name
- Z Package simultaneous compression
tar[-zxvf][FileName] Unzip
- Z Decompression
- x Unpack the package
- v Show more information
- F Specify unzip file
zip[-r][file name/directory name]
- r Compression Directory
unzip[file name] Unzip
bzip2[-k][file name]
- k Preserve source files
bunzip[-k][file name]
. tar.bz2 with. tar.gz Z Change to J
shutdown [CHR] Time
- C cancels the previous shutdown command
- H shutdown
- R Restart
Network command:
ping[-c num][Destination address] ping num times to destination address
ifconfig [Nic][ip] Manually set the IP address for the network card
Last view computer all user logon time and information, restart time, etc.
lastlog[-u User Name] View information about the last time a user logged in
traceroute [host address] View the path between packets to the host
netstat[Options] View network-related information
-TTCP Protocol
-UUDP Protocol
- L Monitoring
- R Routing
-n Display IP address and port number
- p display PID and process name
Common examples:
Netstat-tlun Viewing the port number of the native listener
Netstat-an View all network connections on this computer
Netstat-rn viewing the native routing table
netstat-an|grep ': 80 ' view 80 port status
NETSTAT-ANP viewing ports and process status
mount[Mount device [Mount Point] Mount device (umount uninstall)
vim common commands:
I enter insert mode
: Set Nu sets line number
: Set Nonu cancel line number
GG to First line
g to last line
ng to nth row
: N to Nth Row
$ move to end of line
0 Move to the beginning of the line
x Delete the character at cursor location
NX removes the n characters after the cursor is located
DD Delete the line where the cursor is located
ndd Delete n rows
DG Delete Line to end of line
d Delete the cursor at the end of the line
: n1,n2d Deletes a specified range of rows
yy copy Current line
Nyy Copy the current row following n rows
DD cuts the current line
NDD cuts the current row following n rows
p/p Paste on the current line or the next line
R replaces the character at which the cursor is located
R starts the replacement character at the beginning of the cursor, and ESC ends
u Cancel previous step
/string Search for specified string, set IC ignores case, set Noic
N Search for the next
: w Save changes
: w newname Save as specified file
: Wq Save changes and exit
zz Shortcut keys, save changes and exit
: q! forced exit
: wq! force save changes and exit
ip address configuration:
setup tool configuration IP, subnet mask, gateway, DNS
modify/ect/sysconfig/network-scripts/ifcfg-eth0
Modify the onboot= "no" to onboot= "yes"
service Network restart restart networking service
Span style= "font-size:15px;" > package management:
rpm-ivh install RPM package
yumsearch keyword query keyword-related packages
yum-y Install package name installation
-y Auto Answer yes
yum-y Remove Package name package Uninstall
File System command:
df[option [Mount point] File system view
-a displays all file system Information
-H Use custom units to display capacity
-t display file system type
-m displays capacity in megabytes
-K displays capacity in kilobytes, default
du[options [directory or file] statistics directory or file size
-a displays disk usage per child file
-H Use custom units to display disk consumption
-S Statistics Occupation total
Service Management:
Service directory: etc/rc.d/init.d/, with service command
Turn the service into self-booting: chkconfig [service name] on
Process Management:
PS aux view all processes in the system (BSD standard)
Ps-le viewing all processes in the system (Linux standard)
Top View the health status of the process and update it dynamically.
pstree[Options] View process tree
- p display process PID
-U Displays the user who owns the process
kill-l to view supported signals
1 Restart (common)
2 terminating the foreground process (Ctrl + C)
9 forced termination (common)
15 normal termination (common)
19 Pausing the foreground process
pkill[option [signal] Process name terminates process by process name
- T terminal number kicks the user according to the terminal number
Jobs[-l] View work in the background
-L Show working PID
fg% Work number restores background paused work to foreground execution (% can be omitted)
bg% Work number restores background paused work to background execution
vmstat[Refresh delay [Refresh Count] Monitor system resources
Free[-b|-k|-m|-g] View system memory usage status
dmesg| grep CPU View CPU Information
uname[Options] View kernel-related information
-A view all relevant information about the system
- R View Kernel version information
- s view kernel name
File/bin/ls Viewing the current number of system bits
lsb_release-a View current LUnix system release
lsof[Options] Lists the file information that the process opened or used
-C string: Only files opened with a process beginning with a string are listed
- u user name: List only files opened by a user's process
-P PID: Lists files opened by a PID process
pidofp_name: Lists the PID of the specified process
Lsof-i: Port number View the occupancy of a port
Linux Common Command Review