Common directives
LS Display file or directory
-l list File details L (list)
-a lists all files and directories under the current directory, including Hidden A (all)
mkdir Creating a Directory
-P Create directory, if no parent directory, create p (parent)
CD Switch Directory
Touch creates an empty file
Echo creates a file with content.
Cat View File Contents
CP Copy
MV Move or rename
RM Delete File
-R Recursive Delete, can delete subdirectories and files
-F Force Delete
Find searches a file system for a file
WC statistics Text line number, word count, number of characters
Grep finds a string in a text file
RmDir Delete Empty Directory
Tree structure display directory, need to install tree package
PWD Displays the current directory
LN creates a linked file
More, less pagination displays text file contents
Head, tail display file header, tail content
CTRL+ALT+F1 command line full-screen mode
System Administration Commands
Stat Displays details of the specified file, more detailed than LS
Who shows online login
WHOAMI Show current Operation user
Hostname Display host name
Uname Display System Information
Top dynamic display currently consumes the most resources process information
PS Display transient process status Ps-aux
Du view directory size Du-h/home with units display directory information
DF View disk size df-h with unit display disk information
Ifconfig Viewing network conditions
Ping Test network connectivity
Netstat Displaying network status information
Man command's not going to work. such as: Man ls
Clear Clear Screen
Alias renamed the Command as: Alias showmeit= "Ps-aux", in addition to de-use Unaliax Showmeit
Kill kills the process, you can first view the process ID with the PS or Top command, and then kill the process with the kill command.
Packaging compression-related commands
Gzip:
BZIP2:
Tar: Packaging compression
-C Archive File
-X Compressed file
-Z gzip Compressed file
-j bzip2 Compressed Files
-V shows the compression or decompression process V (view)
-F Use file name
Cases:
TAR-CVF/HOME/ABC.TAR/HOME/ABC only packaged, not compressed
TAR-ZCVF/HOME/ABC.TAR.GZ/HOME/ABC packaged and compressed with gzip
TAR-JCVF/HOME/ABC.TAR.BZ2/HOME/ABC packaged and compressed with bzip2
Of course, if you want to decompress, just replace the above command TAR-CVF/TAR-ZCVF/TAR-JCVF "C" in the "X".
shut down/ Restart the machine
Shutdown
-R shutdown Restart
-H shutdown does not restart
Now turn the machine off.
Halt shut down the machine
Reboot restart
Vim Use
Vim three modes: Command mode, insert mode, edit mode. Use ESC or I or: to toggle the mode.
Command mode:
: Q exit
: q! Force exit
: Wq Save and exit
: Set number Displays line numbers
: Set Nonumber hidden line number
/apache find Apache in the document press N to jump to the next, Shift+n previous
YYP Copy the cursor line, and paste
H (move left one character ←), J (next line ↓), K (previous line ↑), L (move right one character →)
User and user groups for changing files
sudo chown [-r] Owner[:group] {file| Directory}
For example: Also take jdk-7u21-linux-i586.tar.gz as an example. belongs to user Hadoop, group Hadoop
You want to switch the users and groups to which this file belongs. You can use commands.
sudo chown root:root jdk-7u21-linux-i586.tar.gz
File Rights Management
Three basic permissions
R read value represented as 4
The W write value is represented as 2
X executable value represented as 1
, the permissions for the jdk-7u21-linux-i586.tar.gz file are-rw-rw-r–
-rw-rw-r– altogether 10 characters, divided into four segments.
The first character "-" indicates a normal file, and the "L" link may also appear in this location; "D" means the directory
The No. 234 character "rw-" represents the permissions of the currently owned user. So the value is expressed as 4+2=6
The No. 567 character "rw-" represents the permissions for the group that is currently owned. So the value is expressed as 4+2=6
The No. 890 character "R –" represents other user rights. So the value is represented as 2
So the permission to manipulate this file is represented by a value of 662?
Change permissions
sudo chmod [u belongs to user g belongs to group O Other User a All users] [+ Increase permissions-reduce permissions] [r W x] directory name
For example: There is a file filename, the permission is "-rw-r--x", the permission value is changed to "-rwxrw-r-x", with a numeric representation of 765
-
- sudo chmod u+x g+w o+r filename
The above example can be represented by a numerical value
-
- sudo chmod 765 filename
Linux Common commands