preface

Hello, everyone, I am Xu Zhu, occasionally check whether their kung fu learned home, but also through continuous absorption of the essence, in order to output beautiful huan wonderful practical good article. Today I will tell you how the front end can quickly understand the Linux server system and use Linux commands.

My motto: to serve you and me is to motivate yourself and achieve yourself. 👈

I have been dealing with the server a lot recently, and I use the Linux operating system. I am a little unfamiliar with many commands of Linux, because I seldom used them before. But now I use all my commands at my fingertips. He doesn’t know me, BUT I know him. Follow-up in order to facilitate their own use, but also convenient for everyone to quickly find, specially spent a lost time carefully comb a Linux common command treasure book, as a front-end son enough, back-end ok, inadequate operation and maintenance.

I remember that when I first came into contact with this area, after the front-end development of a project, they asked me to start deployment (test service, production service), so the technical boss or operation and maintenance colleagues would directly throw a server, at that time, confused, do not know where to start. Have to look up all sorts of data according to operation on the net after just be done. Although I encountered some potholes on the way, I gained a new understanding of new things and learned a lot.

If you want to practice excellent martial arts, the key is to have a good basic skills. It is recommended that the officers read it carefully, and then put the commands listed below into their own manual practice once, and put them in their pockets for a rainy day.

Common scenarios

  • The interview scene
  • To guide the couple
  • Company project deployment (front and back)
  • Individual project deployment (full stack)
  • Database Deployment
  • Smart Contract Deployment
  • Underlying blockchain deployment
  • You can blow NB😉

Personnel & degree

  • Front End Engineer (Basic)
  • Back-end Engineer (Familiar)
  • Full stack Engineer (Skilled)
  • Big front End Engineer (Skilled)
  • Blockchain Engineer (Skilled)
  • Operation and Maintenance Engineer (Skilled)
  • System Architect (Proficient)
  • Database Engineer (Skilled)
  • Embedded Engineer (Proficient)

Remotely connect to the server (for the front-end)

  • Xshell (Paid version)[1]
  • FinalShell (Free)[2]

I have used Xshell tool for a while before, and it is still good. Later, due to the charge, I switched to the free version of FinalShell tool, which is enough for developers, so I have been using it now. Of course, if you want to use the premium version, it is not necessary, you do not need money.

After successful installation, open the interface, as shown below:

GUI Login

SSH Login Commands

# -p indicates the port number
# root indicates the server user name
# 192.168.14.147 indicates the server IP address
Enter your password to log inSSH [email protected] - p. 22Copy the code

System directory structure

After logging in to the system, enter the following command in the command window:

ls /
Copy the code

You should see something like this:

Tree directory structure, as shown below:

For more details on Linux, I recommend reading the Getting Started Linux tutorial. [3]

Collection of common commands

The following are some common commands that are sufficient for front-end partners. In addition to recommend a Linux command daqo [4] quick check website, very good, if you forget some commands or some commands do not understand can be solved here.

Directory switch command

Switch to the specified directory

cd /usr
Copy the code

Switch to the previous directory

cd.Copy the code

Switch to the system root directory

cd / 
Copy the code

Switch to the user home directory

cd
Copy the code

Switch to the previous directory

cd -
Copy the code

Directory Operation Commands (Add, Delete, Modify, and Search)

Create/delete an empty directory

The mkdir directory nameCopy the code

Rmdir directory nameCopy the code

Ls Displays information about the current directory

# Suggest using abbreviations
ls -l or ll # ll is shorthand for displaying all files and directories in bytes without hiding them
ls -lh or ll -h # ll-h is shorthand for displaying all files and directories without hiding in units readable
Copy the code

# A is the same as -a, but does not list "." (current directory) and ".." (Parent directory)
ls -a # show all files and directories that contain hidden files
ls -al Display all file and directory details in bytes
ls -alh # Display by unit readable contains hidden details of all files and directories
Copy the code

Find the directory

Find directory argumentCopy the code
  • List all files and folders in the current directory and subdirectories:find .
  • in/optFind a file name ending in. TXT:find /opt -name "*.txt"
  • Same as above, but case is ignored:find /opt -iname "*.txt"
  • Find all files ending in.txt and.js in the current directory and subdirectories:find . \( -name "*.txt" -o -name "*.js" \) 或 find . -name "*.txt" -o -name "*.js"

Directory move/rename

Mv Original directory name New directory name/new directory locationCopy the code

Copy directory

The cp command can be used to copy directories, files, compressed packages, etc. In addition, files and compressed packages are copied without -rCp -r Directory name Target location for directory copy# -r stands for recursive copy
Copy the code

Delete the directory

# -rf Force delete, use caution
# -r recursively deletes all directories and filesRm -r[f] Directory, file, or compressed packageCopy the code

File operation Command (add, Delete, modify and search)

The new file

Touch the file nameCopy the code

Viewing file Contents

The cat filenameCopy the code

File move/rename

Mv Original file name New file name or new file locationCopy the code

Modifying file Contents

Vim filenameCopy the code

Vim File -> Enter file -> Command Mode -> Press I/A to enter editing mode -> Edit file -> Press Esc to enter bottom line mode -> enter :wq / :q!

Comments:

  • Enter wq to write and exit and save
  • The input q! Indicates forcibly exits without saving

Copy the file

Cp -r File name Specifies the file copy destinationCopy the code

Decompress the operation command

Tar compressed file

Tar -zcvf Compressed file Target fileCopy the code

Decompress tar files

Tar -zxvf Compressed fileCopy the code

Zip file

Zip Compressed file Destination fileCopy the code

Unzip Decompresses the file

Unzip compressed fileCopy the code

If zip does not work, download the zip installation package and run the following command to install it:

yum install zip unzip
Copy the code

Permission to command

View current file/directory permissions

ls -l or ll  # ll shorthand
Copy the code

Example Modify file/directory permissions

Chmod Permission directory/fileCopy the code

  • There are three permissions: W, R, and X
  • For files, only r permission is required to read the contents of the file
  • For directories, you must have r and X permissions to access the contents of the directory. Only R permissions are meaningless
  • The root user is not restricted by any permissions

Chmod command description [5]

At the end of the article, a link is attached to explain the detailed analysis of the results shown in the above picture [6]

Added command

Displays the current working directory

pwd
Copy the code

Find executable file paths

whichThe query targetCopy the code

View the Linux version command

cat /proc/version Check the Linux kernel version
cat /etc/redhat-release Check the CentOS system version
Copy the code

Viewing process Status

ps -ef|grep nginx 
or
ps aux|grep nginx
Copy the code

The file transfer

Curl URL address: port number# return the HTML content, indicating that the page was captured successfully
Copy the code

The curl command [7] is very powerful. For more details, see the link at the end of this article.

Find keywords in files

grep "Keywords"The file nameCopy the code

Clear the screen

clear
Copy the code

Viewing Real-time Logs

tail -f debug.log
Copy the code

Whether the port number is accessible

Telnet Server IP Port numberCopy the code

Kill the process

Select PID from ps process
kill -9 pid # -9 indicates forcible termination
Copy the code

View the current system nic information

ifconfig
Copy the code

Displays process dynamics in real time

top
Copy the code

The top command is a commonly used performance analysis tool in Linux. It displays the resource usage of each process in the system in real time, similar to the Task manager in Windows. A detailed explanation of the top command is attached at the end [8]

Check whether the host is connected

Ping Server IP address/domain name addressCopy the code

Check whether the port number is occupied

Netstat tunlp | grep port numberCopy the code

The related resources

  • Xshell:www.netsarang.com/zh/xshell/
  • FinalShell:www.hostbuf.com/t/988.html
  • Linux tutorial: www.runoob.com/linux/linux…
  • Linux command: www.runoob.com/linux/linux…
  • The chmod command a: www.runoob.com/linux/linux…
  • A: ll command to view the file shows the result analysis blog.csdn.net/LEON1741/ar…
  • Curl command: man.linuxde.net/curl
  • The top command a: www.cnblogs.com/niuben/p/12…
  • Linux Basics for front-end & back-end programmers: juejin.cn/post/684490…

conclusion

Write this, as a new generation of migrant workers these basic skills must be mastered. Of course, this is just the tip of the iceberg, and different roles require different things. Just as the beginning of the article said that the use of personnel and master degree, skills do not pressure the body. If you feel that this article has a little help, please click to encourage, thank you.

In addition, if there is something wrong with this article, please criticize and correct it. I would like to communicate and discuss with you, learn and make progress together.

Pay attention to the public number [lazy code farmers], get more project actual combat experience and a variety of source resources. If you also love technology and are fascinated by it, please add us to wechat [LazyCode520], and we will invite you to join our front-end combat communication group to create more bugs and program for happiness ~ 🦄