Linux Getting Started notes

Source: Internet
Author: User
Tags download redis parent directory readable install node

At first, there is always some conflict with Linux, black Command box do not know how to start, this time because of the handover of work needs to be responsible for the former colleague's node backend section, Node,redis These are deployed on Linux, saw several operations of the classmate Crackling knock command, black white flash a flash, I have not seen clearly what knocks, admiration of the feeling arises spontaneously. No way, not counseling ah, so began to learn Linux, first installed a virtual machine to play on their own. Environment Preparation 1. Installing VMware Workstation This does not explain 2. Install CentOS next  CentOS-7-x86_64-Minimal . Tutorial: http://www.linuxidc.com/Linux/2016-05/131701.htm setting up a root account and a common account basics Linux is a command operation, many commands are not easy to remember, you can use man to see the use of a command. With a long command, the TAB key can be used to complete the completion. The following are only classified according to my own habits. The content is basically from the bird Brother's private food Foundation, the book is very large, there is time to fine research.  1. Login [Ctrl] + [Alt] + [F1]~[F6] means 6 terminals. The Command window and Image window can be toggled by [Ctrl] + [ALT] + [F1] and [Ctrl] + [ALT] + [F2]. Exit exits the current user. Common account does not have the installation permission, can use Su to cut to the root account. This is still the current environment after root login. Root is the most privileged account in the system, so don't use root.   But the root password forgot the whole? Do you want to reinstall it? Bird's private cuisine gives the method: Log in single-player maintenance mode to change the root password. Restart the virtual machine, press any key while reading the second to enter the following interface: Press E to enter edit mode, move the cursor to the kernel line, then press E to enter the edit of the line and then add a single to enter the individual maintenance mode, and then press ENTER Pressing B at this time is equivalent to gaining control as root. Then enter passwd to change the password. When logging in, remember that the user name is root and not a custom stone.   But do you think it's possible to change the root password of someone else's machine in this way? 2. Shutdown restart
Shutdown-h now//  shut down immediately/ / restart now

Shutdow is commonly used, if root can also be used init,linux a total of seven levels of execution first look at these four

0356: Restart

So you can shut down the machine like this:

0 // turn off the machine

Restart the same. Reboot,poweroff can also.

3. The file directory directory is a very common command section
// represents this layer directory : // represents a previous level directory // represents a previous working directory // represents the directory where the current user resides
Cd://Switch directory (change directory)Pwd://Show current directory (Print working directory)Mkdir://Create a new directoryMkdir-p test1/test2///Create multiple directoriesRmDir//Delete an empty directory. A subdirectory will promptRmdir-p Test1/test2//There are subdirectories deleted at one time. Only empty directories are deleted. Rm-r Test//No matter if test is not empty, it is erased. Echo $PATH//Show system PathMV Text.txt//Text1 Move the text.txt from the current directory to the Text1MV Text.txt.//move the text.txt from the current directory to the parent directory. MV Text.txt T1.txt//Rename to T1.txtCp//copy files and directories. Cp-r test1 Test2//If there are other directories under Test1, use-R

We can see which files are under the current directory with the LS command. Ls-al//lists permissions and attributes for all files. Contains the hidden.

LL will list the permissions and size information for all the files, the first column, the file, and D indicates the directory. R indicates that Read,w is writable and X is executable.

[-] [RWX] [R-x] [R--]1 234 567 8901 is: For this file name is the directory, 234 is: The owner's permission, in this case is readable, writable, executable (RWX), 567 is: The same group user power, in this case is readable executable (RX), 890 is: Other user rights, in this case is readable (r) whether a Linux file can be executed is related to the 10 attributes of his first column. Has no relation to the file name. It can be executed as long as there are x in the permission. But does not mean that the executable succeeds。 4. Compression and decompression

*z, *.tar, *.tar.gz, *.zip, *.tgz: all represent compressed files. The different names are different because of the different compression methods. Just remember that the tar command is OK.

tar [-j|-z] [CV] [-F file or directory] filename

For example: $ tar-zcv-f t.tar.gz t1.txt. -j and-Z represent different compression algorithms. -J is compressed by means of the Bzip2 method, and the suffix is also recommended to be compressed *.tar.bz2-z means gzip. The recommended suffix is *.tar.gz.

-C for compression, and-V to display the name in the file. Extract:

X means decompression. -C means extracting to the specified directory.

And this time, there's the. xz suffix. such as node's binary installation package. Node-v6.10.2-linux-x64.tar.xz

Need first:

Xz-d node-v6. 10.2-linux-x64.tar.xz

Unzip into. Tar. Then unzip it with tar.

You can view the contents of the compressed file with Zcat.

5. Text editing

1) Nano

Nano  // Open or create a new text named XX.  ctrl+o  Save, F2 or Ctrl+x exit. 

You can view the content through cat.

Cat Xx.txt

2) VI Editor

All UNIX like systems will be built into the VI document editor.
// Create a document. 
Press I, O, a and other characters to enter edit mode. Press CTRL + C to exit edit, enter command mode and enter: Wq save and leave. This command indicates write and leave, and can also be used separately. Force can be added!
// to search.  // navigate directly to Word string.  // Copy the line where the cursor is located. p  // paste data. x  / / Delete data u  / / undo /  redo. 

3) Vim

Vim has the program editing ability, can highlight. The same is CTRL + C entering the command mode set NU setting line number. Set Nonu Cancel line number when we press V or V or [ctrl]+v, the place where the cursor moves will begin to turn white, indicating that it is selected. Then press Y to copy. Press p to paste. 6. Program management in a Linux system, whenever an event is triggered, the system defines it as a program and gives the program an ID, the PID. Ppid represents his father's program ID, and honestly, Linux can hardly be a machine. Because he can kill a trapped program at any time. Then re-execute the program without restarting. Assuming the interface dies, you can randomly press ALT+F1--F7 to cut to the other terminal interface, then ps-aux to find the wrong program and kill it.
Kill-signal% jobnumber-1  reads the configuration file of the parameter again, similar to reload. -2 represents the same operation as the keyboard input CTRL +C. -9  Force removal of a job immediately. - terminate a work in a normal manner.
If you want the background work program to continue running after logout, use Nohup with & This is used when we start the Redis service.
PS aux  Observation System for all program data.
A all of the process is displayed. -A not all process related to the terminal. -U valid user-related PROCESSX lists the complete information. -L Just watch your bash-related programs.
Top Dynamic Observation program changes
Relative to PS is a point-in-time program state, top is the state of continuous detection program operation. top-d | Top [-bnp]-d represents the number of seconds, the preset is 3 seconds. -B is the batch execution top. n indicates a few executions. -P indicates that a PID is specified for observation. Press Q to exit.
 Free // direct view of memory

// Viewing System Information
-A: All system related information, including the following data will be listed;-S: System core name-R: Core version-M: the hardware name of the system, such as i686 or x86_64,-p:cpu type, not-m similar, just is the type of CPU is displayed! -I: Hardware platform (ix86)
// Verify that the network is viable

Ping

Determine if the route is OK. DNS resolution 7.BASH View variable environment variables can be viewed through the dig domain name:
Echo $PATH
Defining variables
echo $mynamemyname=vbird   // no spaces on either side of the equals sign
Usually the larger letters are the system default variables, and the lowercase are the custom variables. You can define a directory with a variable. But after exiting, there was no more. Can be used to write a Linux script read to define a variable and accept the user's input as a value. The second behavior enters the content.
"" named
You can also enter hints and time timings.
declare [-AIXR] variable  // declaration Variable Type
A is an array, I is a number, x is defined as an environment variable, and R is read-only. grep is a common and commonly used instruction, and his most important feature is string comparisons. Print them in accordance with the requirements. Xshellxshell is really a good thing, the default command box operation on Linux always feels tied. Cannot copy and paste like Windows, window switch is also troublesome. Xshell very comfortable. You can use the new session link machine, follow the prompts to enter the IP and account and password. Remember, the next time you can open it directly. You can also enter an IP link in the address bar. You can also use the command
192.168. 92.128

You can also choose a color scheme in the tool:

Linux small rookie instantly on a grade. Don't say I'm still aiming at the OPS crew. Hey. The main is really convenient, you can copy (select Right button), you can paste (shift+ insert). The installation software also has a progress bar. Software installation to use when the time has come, how to install a noed it? 1. Install node

It is best to use uname-r to look at your system first. Because Linux 64 is not compatible with 32.

I'm 64, and I'm not going to get a 32-bit run. There will be libstdc++.so.6 related errors. Cannot run node.

To obtain a compressed package with wget:

wget--no-check-certificate  Https://nodejs.org/dist/v6.10.2/node-v6.10.2-linux-x64.tar.xz

--no-check-certificate is used to ignore certificate checks. After the download is complete, the Tar.xz file is first extracted to. Tar.

Xz-d node-v6. 10.2-linux-x64.tar.xz

Then unzip with tar:

Then go to the extracted bin directory

Execution./node-v can get the version description right. However, it is necessary to set the global variables to be useful. Need to first cut to root with the SU command

Then open profile. Insert node's directory in:

Save it again. Can be viewed with echo:

Look at the node version. It's OK.

2. Installing Redis

Just now node download down directly can be used binary, in fact, a lot of software also need our own compiled. Download Redis

wget http://download.redis.io/releases/redis-3.2.8.tar.gz

Then unzip:

Tar xzf redis-3.2. 8. tar.gz

Re-entry Directory

CD redis-3.2. 8

Make:

Make

This time if the SRC directory does not appear under Redis-server

Indicates that the installation failed. If make CC command not found error appears
Yum Install GCC

GCC needs to be installed. If run redis-server appears you need TCL 8.5 or newer in order to run the Redis test error

Yum Install Tcl

TCL installation is required. No way, this minmal CentOS still lacks a lot of things. But it's good to experience it all over again.

Running Src/redis-server: The service started successfully. Note the & in the back so that the interface is not blocked. Try again redis-cli read and write also normal. You can build another work directory and install a Redis module with NPM. Then use VIM to create a new app.js.
var redis=require (' Redis '); var client=redis.createclient (); Client.on (' Connect ',function() {Console.log ( ' Redis connected '); Client.set (' author ', ' Stoneniqiu ', redis.print); Client.get (' author ', Redis.print);});

OK, run:

Now it's time to play happily alone. Summary: When I first learned Linux, I felt that Windows was a great product and a human design. Learned a few days of Linux, also think this is very fun.  These are just personal entry notes. Reference: "Bird's private Cuisine Basics" Linux deployment node:http://www.cnblogs.com/dubaokun/p/3558848.html

Linux Getting Started notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.