Linux Common commands for Hadoop

Source: Internet
Author: User

There are command options at the end of the Linux command, and some options have option values. The options are preceded by a dash "-", with a space separating the commands, options, and option values. Some commands have no options and there are parameters. An option is a command built-in feature, which is a user-supplied content that conforms to the command format.

1.1.1. Command prompt

Right-click on the desktop and select "Open in Terminal" from the pop-up menu.

The system will open the terminal, similar to the command line under Windows. The command line for Windows is a DOS environment, and the command line under Linux is the shell environment. All of our commands are run under the shell, and the commands in all the sections that follow are executed under the shell.

When the user just opened the terminal, the following prompt is displayed, we should pay attention to the content inside the brackets.

The prompt is divided into two parts by the symbol "@", and the previous "root" is the currently logged in user. If you log in using Itcast, you'll see "[[Email protected] Desktop]". After the "localhost Desktop", the space is divided into two parts, the front "localhost" means the host name, is the unique identity of the machine, if we modify the host name, then the value will change; The following "Desktop" indicates the current path displayed by the shell. The "#" behind the brackets is a hint of the shell type, and we only focus on where the black cursor is.

1.1.2. Path operations

* Path Descriptor

In Linux, the path is separated by a slash "/". In a long path that uses "/" to divide, the slash is special, called the root path, if it is "/" at the beginning. The root path uses "/" to indicate, at the beginning of the path, similar to the Windows "My Computer"; "." Represents the current path, no matter where you are, the point number represents the current path; two points "..." Represents the ancestor path, the wavy "~" indicates the home directory, if the root user login, then "~" represents/root, if the user itcast login, then "~" represents/home/itcast.

* Path Jump Command CD

Format: cd Destination path

Execute "CD.." is to jump from the current path to the parent path.

Execute "cd/usr/local" is the local path under the USR path to the root path.

1.1.3. Directory and file operations

Directories are the folders we see, and common actions include create, delete, move, copy, rename, find, view, modify permissions, and more.

* View command ls

Format: LS path

The command "CD ~" means to jump to the root user home directory.

View the path location via "pwd".

The Execute command "LS" shows which files and folders are in the current user's home directory. In Rhel, the Blue font shows a folder, the black font shows the file, a total of 11 files (clips).

The Execute command "ls-a" shows more than the previous command, including "." Start with the various folders. In Linux, "." The beginning of the file (folder) represents the hidden file, only using the command "LS" is not visible, the option "-a" is to display all files (clips), including hidden.

The option "-l" means to be displayed as a list.

Execute the command "Ls-al", the number of files (folders) displayed is the same as the previous command, but the arrangement is not the same, each file (clip) display more comprehensive content. Here "-al" is the shorthand for parameter "-a" and "-l".

Note: Between the command and the option to distinguish between the use of space, a few spaces do not matter, as long as the use of space to distinguish.

* Create directory command mkdir

Format: mkdir directory Name

Using the command "Mkdir–p" to create the parent directory recursively, that is, the parent directory does not exist, the parent directory is created first, and then the own directory is created. In the current environment, readers are asked to perform "mkdir d1/d2/d3/d4" and "mkdir d1/d2/d3/d4" respectively.

* Delete Directory command rmdir

Format: RmDir directory to be deleted

Immediately following the steps above, execute the command

You can see that the test directory has been deleted.

Note: The command rmdir only deletes the directory and is an empty directory. If the directory contains files (folders), the command execution fails and the RM command should be used.

* The most powerful delete command rm

Format: RM pending deletion of directory or file

RM can not only delete files, but also delete directories, even if the directory is not empty.

Using the command "rm-r" to delete test, there will be various prompts, as long as the constant input "Y", press ENTER. Finally successfully deleted. The visible command RM can recursively delete the directory. If you want to avoid tedious hints, use the command "RM-RF" and ask the reader to test it yourself.

Note: the command "RM-RF" in the recursive deletion of the time without any hint, so be careful to accidentally delete the file.

* Create blank File command Touch

Format: Touch file name

This command invites the reader to test itself and no longer demonstrates.

* Edit File VI

The VI command is very complex and takes up too much space, so please ask the reader to check the relevant information on its own.

* Move file (clip) command MV

Format: MV source file (clip) destination path

When moving a file (clip), the command needs to follow two parameters, the first is the source file (folder) path, the second is the target path. The file (clip) is moved from the original path to the new path, and the original path no longer exists.

The command is the same as the move command, if the second parameter is a directory, or a move operation, or if the second parameter is a file, it is the rename operation.

* Copy file (clip) command CP

Format: CP source file (clip) destination path

Copy the file (clip) also with two parameters, the first one is the source, the second represents the destination.

The command "Cp-r" can be copied recursively, that is, all the contents of the source folder are copied to the destination together. If the destination has a file (folder) of the same name, it is prompted to overwrite.

Note: When copying a file and the destination file does not exist, the copy operation has the effect of creating the file.

* View File Contents command Cat

Format: Cat file name

This command invites the reader to test itself and no longer demonstrates.

* View File Contents command more

Format: More file name

Ask the reader to test the command yourself and no longer demonstrate. The difference with cat is that when a lot of file content, a screen display, cat will scroll to the end of the file, more display a screen after the stop, the user press the SPACEBAR, continue to scroll to the next screen. To put it simply, more is the split screen display content.

 

* The Encyclopedia of the Command Man

Format: Man command name

The command man is the Linux Help system and can be found in man for any command. The usage is "man a command". If the display Help content too much, will split the screen, if you want to quit, please press "Q" key.

* Modify Permissions command chmod

When we execute the command "ls-l", we see the following output

Now tell the meaning of the first 10 characters of each line of output.

The first character indicates the file type, if "D", indicates the folder, if "-", is a normal file. You can see that "File1" is a file and "Test1" is a folder.

The following nine-bit character that represents the permissions for the file (clip). Divide nine characters into three groups according to three groups. Among them, the first group of users representing the file, with U (can be understood as the owner of the file, English is the user), the second group represents the group of owners of the file, in G (English is the group), the third group of other people, with O to indicate (English is other) permission.

Each group includes three-bit characters. Where the first character represents the Read permission, the R is the read, the second character represents the Write permission, the W is the write, and the third character represents the Execute permission, denoted by X (in English, execute). If you have this permission, the character of the corresponding position is used, and if you do not change the permission, the "-" is used.

The command format is "chmod [permission mode] File", which represents the Execute permission mode on a file.

The following examples illustrate

Explain:

The command "chmod u+x file1" means to increase the execution rights for the user;

The command "chmod o+wx file1" means to add write and execute permission to other people;

The command "chmod a-r file1" means: Remove Read permission for everyone.

In addition, each group of three-bit permission symbols can also be represented by a number, "R, W, X" corresponding to the numbers are "4, 2, 1". If a user's corresponding permission bit is "rw-", the number is 6 (that is, 6=4+2), see the following example:

The use of digital Express permissions more concise, we will often say that a file has 755, 644 permissions, readers should understand the user, group, other people are what permissions.

1.1.4. Network-related

* Host name Command hostname

Format: hostname

This command can view the host name.

If the command "hostname new hostname" is used, it means that the hostname is modified but only valid for this session and fails after restarting the machine.

* View IP Command ifconfig

Format: ifconfig

You can view the configuration information for all network cards. The command "ifconfig eth0" Only view the configuration information of the specified network card;

L Service Management Command service

Command "service" users to manage a variety of Linux services, including four types of start, stop, restart, status. The first three meanings are very clear, and the fourth means to view the current running state of the service.

The command "service network Restart" indicates that the NIC settings are restarted.

1.1.5. System-related

* Change Password passwd

Format: passwd user name

The purpose of this command is to modify the password.

L Aliases Command alias

Format: Alias aliases = "New command definition"

The purpose of this command is to give a long command a short name, to facilitate memory and use. For example:

* Unzip Command tar

The command tar can be compressed or uncompressed. We are concerned about decompression.

Our common compression format is "*.tar", which refers to packaging using the Tar tool. More commonly, "*.tar.gz" refers to packaging using the tar tool and compressing it into "GZ" format.

The Common Operations Command is "TAR-XZVF [file. tar.gz]". Now explain these parameters:

The parameter x indicates the decompression operation;

The parameter z means to unzip the file using Gzip;

The parameter v indicates that the file details are displayed during the decompression process;

The parameter f indicates the specified file name, followed by a file name;

* View File Size command du

Format: Du file (clip)

The command is to view the file size. Common Way "du-hs [File (clip)]"

* View disk Capacity command DF

Format: DF

View disk capacity, Common command "df-h"

* View Process Command PS

Format: PS

View the process using the command "PS", plus the parameter "-ef", to view the currently active process.

In the display, we relate PID and CMD Two, which represents the process number, which represents the process name.

* End Process Command Kill

Format: Kill process number

The KILL command is used to end a process, and we are generally forced to end a process with the command format "kill-9 process number". The process number here is the PID that the command PS sees.

The reader can end the CMD process as "bash" and try the results.

* Piping

Pipe with the symbol "|", both sides of the left and right are commands. Represents the output of the left command as input to the right command. As the following command:

Explain:

The command "cat/etc/sysconfig/network" means to view the contents of the file;

The command "Wc-l" indicates the number of rows in the statistics file;

The two commands are connected together using pipelines, which represent the output of the command "cat" as input to the command "WC", displaying 2 rows.

* redirect

The shell command default input information is from the command line, and the default output information is also to the command line. If the input is not from the command line, the output is not to the command line, then redirection is required.

Redirects are expressed using ">>" or ">". The former represents an append, the latter represents an overlay.

Use the command "cat file1 >> file2" to append the contents of the File1 file to the contents of the file2. Note the use of ">>" in the command, if you change to ">", is the overwrite operation, and there is no hint.

Note: There are many Linux commands, and the above commands are only part of the most commonly used commands. Even if the use of the commands mentioned above is a very small part, these commands and functions are necessary for learning this book, more commands and functions ask Baidu or use powerful command "man".

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.