Change directory command:
cd Change directory
CD / usr switch to the usr directory
cd .. switch to the parent directory
cd ../ .. transferred to the upper layers of the current directory
cd / switch to the root system
cd ~ switch to your home directory
cd - switch to a directory
Directory Operations Command
pwd displays the current directory
ls displays all files and directories in the current directory
ls -a view all files and directories under the directory, including hidden directory
ls -l to view details of all catalog files in that directory
For more information directories and files after viewing grep XXX Screening | ls -l
Vi / VIM editor (difference: vim vi is similar to an upgraded version, the color change can occur, such as comments will turn blue, vi will not)
ESC will jump directly to the last line
Enter the appropriate command SHIFT :()
First switch to the desktop: [root @ localhost ~] # cd / root / Desktop
Copy system files to do the exercises: [root @ localhost Desktop] # cp /etc/kdump.conf a.conf
Vi and vim test were used, the contents of the file comments vim will change its color, exit the editor to change the file type: q and then press Enter
[Root @ localhost Desktop] # vi a.conf
[Root @ localhost Desktop] # vim a.conf
Three vim editing mode (a, i, o)
a: after edit cursor
i: edit before the cursor
o: Wrap editor
: Set nu show line numbers
: Set nonu hide line numbers
dd Delete the current line
dnd Delete how many rows (from the beginning of the tail deleted)
u undo the current operation
yy Copy
p Paste
The end of the shift + g cursor to the file
Input N, then move the cursor to shift + g N-th row
After editing, click ESC, into the command line:
q: Normal exit (without modifying things)
q! : Force Quit (to modify things, not saved)
wq: Save and exit
Ctrl + L to clear the screen
ifconfig to view ip address
Tap completion
man View Manual
View man ls ls command related to manual (press q to exit the current manual)
View related command ls ls --help Manual
date Date
cal Calendar
Create a directory mkdir xxx
mkdir -px / y / z create multi-level directory
Create a file touch xxx
vim xxx create and edit documents
delete empty directories rmdir xxx
rm xxx delete files or subdirectories
rm -r xxx asks, recursive delete, you can delete subdirectories
rm -rvf xxx will not be asked to display the deleted information
rm -rf xxx not ask, do not display the deleted information
cp xxx (to be copied file) xxx (to a location) copies of documents
cp -rv xxx xxx together with the subdirectory copy, and displays information
mv xxx (source file name) xxx (new file name) rename
mv xxx / xxx directory name to move files to a location
cat xxx view the file, the general view smaller files
more xxx view the file, the general view large files
more and less xxx Similarly, different key operation
View from the tail began to tail xxx
tail -N xxx View N lines from the tail
tail -f xxx follow the view, generally used to view the log
history View history commands
find [Search Path] [matching condition] find a file or directory
If you do not specify a search path, the default look from the current directory
-name by name, find accurate
Find -iname by name, ignoring case
*: All matches
?: Matches any single character
For example, find / etc -name "init ???" beginning to look for init in the directory in / etc, and there are three behind file
find and locate xxx similar to search through the index, faster, and together with updatedb
updatedb to create an index, and then use the index will show locate xxx
tar -zcvf xx.tar.gz xxx.txt archive
-z to use gzip compression
-c create a compressed file
-x Extract the file
-v Displays file information
After -f specify the compressed file name
tar -zxvf xxx.tar.gz decompression
ps -aux View system processes information
-a displays all process information
-u displays process information in a user format
-x display background process parameters
ps -aux | grep xxx screening process
ps -ef shows all the current process in full format
kill pid kill the current process by process pid
kill -9 pid forced to kill the process (common)
For example: Right open a terminal on the desktop of the virtual machine vm, and then find the corresponding process pid bash on Xshell
Use kill -9 3577 kill 3577 and tested
systemctl start service name (xxx.service) to start the service
systemctl restart the service name (xxx.service) restart the service
systemctl stop service name (xxx.service) stop the service
systemctl status service name (xxx.service) to view the service
E.g:
systemctl status firewalld.service View firewall
systemctl stop firewalld.service turn off the firewall
Because the firewall as a virtual machine to start automatically, to avoid trouble, we can permanently turn off the firewall
[Root @ localhost Desktop] # systemctl list-unit-files | grep firewalld find firewall
[Root @ localhost Desktop] # systemctl disable firewalld.service turn off the firewall
netstat -anp | grep 8080 to see if the port is occupied 8080
useradd xxx (username) new users
passwd xxx (user name) to set the user password
su - xxx (user name) to the user
whoami / who am i to view the current user
id xxx (user name) to view the current user
Ctrl + Z: abort using fg / bg operation continues foreground or background task,
fg command to restart the foreground task is interrupted, bg command the interrupted task in the background.
Ctrl + C: Force Quit