Linux Commands frequently used
3 min readJan 10, 2021
Row Labels
Check network communication
ping domain name or ip
ping www.google.com
Check the configuration of the ip address
ifconfig
There will be ip related information, gateway, subnet mask, ipv4, ipv6, etc.
Check the disk space
df -h
Will display usage, total, remaining amount and other information
Copy file and rename
cp filename1 filename2
cp 1.php 2.php in the current directory, copy 1.php and rename it to 2.php
create a new file
touch filename
touch 1.php Create a new 1.php file to support the creation of multiple files, just keep writing
Delete empty directories
rmdir filename
rmdir test delete empty folder test
Delete specified file
rm filename
rm 1.php delete 1.php file
drop out
exit
Just close the black window
Edit file
vi filename i
vi 1.php enter the editing environment, press iexecute to edit
Enter the specified directory
cd filename
cd test switch to the test folder
Exit editing
Esc :wq!
First press the exit key on the upper left corner of the keyboard, then enter :wq!, save and exit the editing environment
Force delete
rm –rf filename
Comes with circular deletion, even if the directory is not empty, note that the deletion under the Linux command cannot be recovered
Move files
mv filename path
mv 1.php …/ Move 1.php to the upper directory
New directory
mkdir filename
mkdir test creates a test folder
Rename file
mv filename1 filename2
mv 1.php 2.php renamed 1.php to 2.php, support to change the extension name under window does not support the creation of the .beginning of the file, you can use this to achieve rename
Return to last stay
cd-
Similar to return key
Return to the root directory
cd /
Note that the root directory is not equal to the desktop
Return to the upper directory
cd ..
cd… switch from the test directory to the previous directory
Show your current directory
pwd
Absolute path return ->/c/Users/Administrator/Desktop
View the effect after editing
cat filename
cat 1.php View the edited 1.php file
Wildcard*
rm *.txt
Delete files with .txt extension
Other commands:
- wc Statistical text information (number of lines, words, characters)
- date View or modify the date and time of the system
- echo output string or variable value
- tar -zxvf filename.tar.gz unzip to the current directory
- ps -ef |grep java View all running java processes
- kill -9 pid force to kill the specified process id
I like to learn new and better ways of doing things when working on a scale, and feel free to ask questions and make suggestions.
Also, check out another story on this.
Thanks for reading this.