First of all, ordinary Linux users need to make simple copy, delete, move and so on files or folders. Linux common file operation commands are as follows:
Command |
description |
example |
cd |
Toggle directory |
cd/mnt |
ll |
lists all folders and files in the current directory |
ll |
cp |
Copy file or folder |
CP -r/tmp/mnt |
SCP |
remote Copy file |
scp-r [email protected" :/tmp/mnt |
mv |
move a file or folder |
mv/tmp/mnt |
rm |
Delete a file or folder |
rm-r/tmp |
find |
find files or folders |
find/ -name tmp |
chown |
Toggle file User |
chown-r pa As:paas * |
chmod |
Modify file Permissions |
chmod 777 test.txt |
su |
Switch System users |
su PAAs |
Second, the senior Linux users need to directly on the Linux system for file content viewing, editing and other operations. View files can use head, tail and other commands, modify the file is most commonly used in the VI editor. You can also query the file with the grep command and redirect the query results to a new file by >>.
Head and Tail commands
Command |
Description |
Example |
Head |
Display the first 10 lines of the file |
Head Test.txt |
Head-Number of rows |
Display the top n rows of a file |
head-100 Test.txt |
Tail |
10 lines of content after displaying the file |
Tail Test.txt |
Tail-Number of rows |
Displays the contents of the file after n rows |
tail-100 Test.txt |
Tailf |
Real-time display of new additions to files |
Tailf Test.txt |
VI Editor Common commands
Command |
Description |
Example |
Vi |
Opening a file with the VI editor |
VI test.sh |
Dd |
Delete the cursor in the row |
VI page, keyboard input DD |
/ |
Inquire |
VI page in the keyboard input/, and then enter the query keyword, press ENTER to query |
Shift+g |
Jumps to the last line of text |
VI page Keyboard Press SHIFT+G |
I or a |
Enter edit mode |
VI page Keyboard input I or a, enter the edit mode |
: |
Enter command line mode |
VI page Keyboard input I or a, enter the command line mode |
Set number |
Add line numbering to text |
Command line mode, enter set number |
Set line number |
Navigate to a row |
Command line mode, enter set 123 |
Q! |
Do not save forced exits |
command line mode, input q! |
qw! |
Save and Force exit |
command line mode, input qw! |
Esc |
Exit Current Mode |
When the user edits in edit mode, you can exit edit mode by pressing the ESC key |
grep Command and redirection
Command |
Description |
Example |
Grep |
Search for keywords line by row |
grep 123 Test.txt |
>> |
Append redirect |
grep 123 test.txt >> resut.txt |
> |
Overwrite redirects |
grep 123 test.txt > Resut.txt |
| |
Pipe output |
grep 123 Test.txt | GREP ABC |
Finally, Linux programmers need to be able to run programs on a Linux system and analyze the running state of the program.
Running Java programs
Command |
Description |
Example |
Javac |
Compiling the. java file |
Javac Helloworld.java |
Java |
Run the. class file |
Java Helloworld.class |
Java-jar |
Run the executable jar file |
Java-jar HelloWorld |
Querying system resources
Command |
Description |
Example |
Top |
Display system Run Process information |
Top |
Free |
Display memory Information |
Free |
Df |
Display disk information |
Df-h |
Network Query
Command |
Description |
Example |
Ifconfig |
Querying IP configuration |
Ifconfig |
Netstat |
View network Status |
Netstat-anp |
Process Query
Command |
Description |
Example |
Ps |
Query process |
Ps-ef |
Jmap |
Querying JVM Heap Snapshots |
Jmap-heap Process Number |
Advanced Linux Command Trilogy