Common commands
LS Display files and directories
- -L Display file details (some Linux can be shortened to ll, you can add alias ll= ' Ls-l ' in ~/.BASHRC, and use the source ~/.BASHRC in effect configuration)
- -A View all files (including hidden files)
mkdir Creating a Directory
- -P consecutive creation of multiple directories (ignored if the directory already exists)
CD Switch Directory
Touch Create blank file or modify file time
- -A modify "Access time"
- -M Modify "Change Time"
- -D simultaneous modification of access time and change time
- -T to change into the time [Mm/dd/yy hh:mm]
echo string output to Terminal
Cat View Text File
CP Replication
MV Move or rename
RM Delete
- -R Recursive Delete, can delete subdirectories and files
- -F Force Delete
Find File
Number of lines, words, and bytes of WC statistics text
- -L displays only the number of rows
- -W displays only the number of words
- -C displays only bytes
grep searches for text
RmDir Delete Empty Directory
Tree structure display directory, need to install tree package
PWD Displays the current directory
LN creates a hard link
More, less pagination displays text file contents
Head, tail display file header, tail content
Sed-n "1,5" p/etc/passwd show/etc/passwd 第1-5 Line
Mount Mount
System administration Commands
Stat Displays details of the specified file, more detailed than LS
Who shows current login
WHOAMI Show Current User
Hostname Display host name
UNAME-A Display System Information
Top Monitor the activity and load of the system process
Iotop Monitoring System disk IO (installation required)
PS aux view process and status
Du-h Viewing the directory size
Df-h Viewing disk size
Ifconfig Viewing network status
Ping Test network connectivity
NETSTAT-TUPLN viewing the native port connection status (Ss-ntul more efficient)
Clear Clear Screen
Alias set command Alias
Kill kills the process
Package Compression command
Tar: Packaging compression
- -C Compressed File
- -X Unzip the file
- -T view files within a compressed package
- -Z gzip unzip or compress files
- -j bzip2 unzip or compress files
- -V shows the compression or decompression process V (view)
- -F Target File name
- -C extract to the specified directory
Power off restart
Shutdown-h now, Init 0, Halt, Poweroff shutdown
Shutdown-r, reboot, init 1 restart
Package Management
RPM-IVH Installing the Software
RPM-UVH upgrade Software
RPM-E Uninstalling Software
RPM-QPI Viewing Package description information
RPM-QPL listing the file information for the software
RPM-QF query file belongs to that rpm
Yum Software Warehouse
Centos-yum Package Management
Vim
Three modes of VIM: Command mode, insert mode, edit mode. Use ESC, I, or: Toggle mode
Command mode:
: Q exit
: q! Force exit
: Wq Save and exit
: Set number Displays line numbers
: Set Nonumber hidden line number
: command to execute the command
: integer jumps to the row
/String search string from top to bottom. Press n Next, N prev
DD Clipping cursor Line (6DD clipping 6 lines starting at cursor)
YY the copy cursor is in the row
P Paste
Users and user groups
Useradd Creating a new user
- -D Specify home directory
- -E account expiration date (YYYY-MM-DD)
- -g Specifies an initial user group
- -g specifies one or more extended user groups
- -U Specify user uid
passwd Modifying user passwords
- -L Prohibit Login
- -U Allow Login
- -E Force next logon Change password
USERDEL-RF Delete all user tables
- -F Force deletion of users, home directories and their associated files
- -R Delete users, home directories and their associated files at the same time
Usermod Modifying user Properties
- -d-m used to reassign user's home directory and transfer old data
- -E Account expiry time (YYYY-MM-DD)
- -G Change the owning user group
- -G Change Extended user group
- -L Prohibit Login
- -U Allow Login
- -U Modify user uid
Groupadd Creating a group
/ETC/PASSWD user Account
/etc/group Group account
/etc/shadow Password for user account
Password for/etc/gshadow user group account
File Rights Management
Example:-rw-rw-r--. 1 HT HT 0 May 10:35 1.txt
- The first character "-" denotes a normal file; "l" means a link; "D" means a directory
- The 第2-4 character rw-represents the currently owned user right
- The 第5-7 character rw-represents the currently owned group permission
- 第8-10 character r--represents other user rights
Then the permission for the file is 664
chmod permissions to modify a file or directory. Format: chmod [parameter] permission file or directory name
The Chown command is used to modify a file or directory to belong to the main and owning group. Format: chown [parameter] owner: owning group file or directory name
- The command parameters of chmod and chown are simple----write-R (recursive, modify the properties of all files within the directory) for the directory
Linux Common commands