Original: itsOli @ front-end 10,000 hours this article was first published in the public number "front-end 10,000 hours" this article belongs to the author, without authorization, please do not reprint! This article is adapted from "sparrow" private pay column "front end | ten thousand hours from zero basis to easily obtain employment"Copy the code


❗ ️ ❗ ️ ❗ ️

The following link is the latest erratum to this articleBe a Samson and make the OPERATING System behave like a Sheep: A Command Line Primer


1. Which of the following applications can be used to enter and run commands (multiple options) ✅ terminal in Linux ✅ terminal in Mac ✅ Command prompt in Windows ✅ Windows Install GitBash parameter Note in Windows 2. To view the current full path, run ❌ la -al ❌ la -a ❌ dir ✅ PWD 3. What command is used to display detailed information about all files in the current folder? (including hidden files) ❌ list ✅ ls -al ❌ ls -l ❌ dir 4. What is the difference between CD ~ and CD /? ✅ CD /, switch to the root directory. On the Mac, the directory is ✅ CD ~. Switch to the home directory, for example, /Users/Oli, where Oli is the login user name ✅ CD ~. Oli is the login user name ❌ CD ~. Switch to the home directory. In Windows, the root directory of drive C is 5. What is the command to switch to the parent directory? ❌ CD.. ❌ CD. ✅ CD.. ❌ CD.. ❌ CD ~ ✅ CD.. / 6. The terminal displays the following information: -bash: CD.. : Command not found what do you think is the reason? ❌ no problem ✅ user wanted to output CD.. ✅ bash: your command does not exist ❌ the terminal is down 7. Which of the following is the command to create the A.M.D file? ✅ touch a.m. d ❌ mk A.M. d ❌ mkdir a.m. d ❌ create A.M. D 8. What is the difference between rm command and RM-rf? ✅ the former can delete files but cannot delete folders ❌ the latter can delete files but cannot delete folders ❌ the latter can delete empty folders but cannot delete folders ✅ the latter can delete files and folders, regardless of whether the folder is empty or not, and the deletion cannot be restored 9. After opening the Vim editor, you can press? ✅ I used to insert content ✅ a used to insert content ❌ Press enter used to insert content ❌ Esc used to switch to editing modeCopy the code



Preface: in the previous “from zero basis to ease employment | to do a good job, must first sharpen his – software installation, environment building, we have completed the basic software installation, and preliminary environment set up, then let’s try to come to our operating system command, try to don’t use the mouse can also be quickly finish a lot of operation.

Of course, this is also a necessary skill for us to talk to the backend server later in the development process.


1 The first thing to notice

  • The command line is case-sensitive.

  • Spaces must not be forgotten or omitted;

  • Distinguish commands. Don’t use multiple commands as one command.


2 Basic command learning

Methods open the corresponding system of the terminal, specific to see “from zero basis to ease employment | first-time front, we want to understand which noun?”

2.1 Viewing the Current Full Path

pwd
Copy the code

2.2 Viewing Files in the current directory

  • Contains no hidden files:
ls
Copy the code
  • View all files in the current directory (including hidden files) :
Ls -a (Note: hidden folders are files that begin with a.)Copy the code
  • View all files in the current directory (including details of hidden files) :
ls -al
Copy the code

2.3 Changing directories

  • Give an absolute path directly to the file location:
cd /c/project
Copy the code
  • To code in the current folder:
CD code or CD./code (note:. Represents this directory)Copy the code
  • Skip to the previous folder to the CSS file:
cd .. / CSS (Note:.. Represents the parent directory)Copy the code
  • Jump to home directory and then to Desktop:
cd ~/Desktop
Copy the code

2.4 Creating a File

Touch readme.md (note: this example refers to creating a Markdown file)Copy the code

2.5 Creating a Folder

Mkdir projects (memory: mkdir is short for "make directory")Copy the code

2.6 Deleting a File

rm readme.md
Copy the code

2.7 Deleting folders completely

Rm -rf projects 💡 -f forcibly deletes the file without prompting.Copy the code

2.8 Renaming a File

Mv readme. Md readme. MdCopy the code

2.9 Clearing the CLI

clear
Copy the code


3 Learning file path operation commands – Root directory, home directory

3.1 Accessing the Root Directory

cd /
Copy the code

3.2 Accessing the Home Directory

cd ~
Copy the code

💡 explanation:

  • The home directory is the directory created by your current user (name);

  • The root directory is the directory created by Linux;

  • We usually log in in our own username directory – home directory;

  • The root directory is equivalent to when Windows opens the computer without entering any drive letters;

  • The home directory can be viewed as entering a drive letter on the basis of the above.


4 Vim editor

We can’t talk about the Linux command line without mentioning the Vim editor. A Vim editor is included in any terminal that comes with our system or is installed as an extra.

4.1 ViM editor can be simply divided into

  • Command mode

  • Edit mode

4.2 Steps to use vim Editor

1. Vim a.d Initially enters the command mode of vim editor. 2. I or a go into edit mode; (Note: Text and code can be written after entering the editing mode) 1. Esc enters the command mode at the upper left corner of the keyboard; 2. :wq Save and exit; (remember: wq is short for write and quit.) 3. Forced exit without saving.Copy the code



Postscript: Command line learning and use will run through our whole front-end learning and working life, we need to start from the most basic command to learn more complex commands. Can refer to “bird elder brother Linux private house dishes” a book, fine water long to learn. There’s no end to learning, and the front end is worth the 10,000 hours you and I spend on the back.

I wish you good, QdyWXS ♥ you!