Common Linux commands for the big data base

Source: Internet
Author: User
Tags touch command

Big Data Lab environment is generally Linux, familiar with Linux operation is very necessary, summarize common Linux commands as follows.

1.CD command

Go to Folder:

cd dirname

To enter a multilevel folder:

cd /usr/local/Cellar

To return to the upper directory:

cd ../

Return to upper layer:

cd ../../

Back to home folder

cd
2.ls command

The LS command is used to list the current files and directories, plus parameters to do more things.
Running LS with no parameters lists files and directories

ls

Switching to long list mode with the-l parameter displays a long list of the contents of the current directory:

ls  -l

Plus the-LH parameter shows the file size:

ls -lh

Add the-a parameter to show hidden files:

ls -a

If you want to list only directories:

ls -d */

Recursively lists all subdirectories:

ls -R

By modifying the time list:

ls -lt

List Sub-directories:

ls ~

List Parent Directories:

ls ../ls ../../

Add/Tag Directory

ls -p
3.mkdir and RmDir commands

MkDir is used to create a folder, you should make sure that there is no folder with the same name as the directory under which it resides.

mkdir A

Create multiple folders at once:

mkdir B C D

Add the-p parameter to create a folder with subdirectories:

mkdir -p dira/dirb/dirc

To delete a directory:

rmdir abc

To delete a folder with subdirectories recursively:

rmdir -p dira/dirb/dirc
4.CP command

The CP command is a copy File command for Linux.
Copy the a.txt to B directory under the A directory:

cp A/a.txt B/

If A.txt is already present in the B directory, ask whether to overwrite before copying, plus the-I parameter:

cp -i A/a.txt B/overwrite B/a.txt? (y/n [n])

Copy the entire folder:

cp -R A B

Ask whether to overwrite before copying:

cp -R -i A B
5.MV command

MV commands are used to move files or directories, file Rename, or backup, and MV is the abbreviation for move.
Move the a.txt under the A directory to the B folder:

mv A/a.txt B

If a file with the same name already exists in the B directory, ask if you want to back up:

Rename the operation and rename the A.txt to A1.txt:

mv A/a.txt A/a1.txt

Move all files under the A directory to B:

mv A/* B
6.RM command

The RM command deletes a file or directory, deletes one or more files or directories under one directory, or deletes the entire directory and all files and subdirectories below it. RM is the abbreviation for remove. RM is a dangerous command, use with special care, before executing RM to confirm the directory and the operation to be deleted, do not mistakenly delete.
Delete a file:

rm A/a.txt

To delete a folder that is not empty:

rm -r A/B

Ask before deleting:

rm -i A/a.txt
7.cat command

The purpose of the cat command is to connect files or standard input and print, which is commonly used to display the contents of a file, or to connect several files to display. Cat has three main functions

    1. Show the entire file at once:

      cat filename     
    2. Create a file from the keyboard

      cat >filename
    3. Combine a few files into 1 files

      cat file1 file2>file

Command parameters:

    • -B: Number of non-null output lines
    • -N: The travel number for all lines
8.TAC command

The cat command can display the contents of the file, which in turn is the TAC, and the TAC happens to be a Linux command, its function is to display the contents of the file in turn, the last line of the file content is displayed first, the first line is displayed.

tac filename
9.more command

The cat command displays the contents of the entire file, and the more commands are easy to read on a page-by-page display. Press the Blank key (space) to display the next page, and the B key returns to the previous page.

more filename

Command parameters:

    • +n: Starting from Nth line
    • -N: Defines the screen size as n rows
    • -C: Clear the screen from the top and then display
10.head command

The head command is used to display the beginning of the document to standard output.
Show the first 6 lines of the file:

head -n 6   filename

Displays the contents of the first n bytes of a file:

head -c 20   filename    
11.tail command

Tail is similar to head, except that it displays the contents of the file from the tail.
Show the last 10 lines of the file:

tail -10 filename

Or:

tail -n 10 filename
12.touch command

The touch command can modify the file time or create a new file:

touch -t 201611151010 filename

Set file1 and file2 the same timestamp:

touch file1 file2
13.chown command

The Chown command is used to set the Owner property of a file.
Change the owner of the file to the root account:

chown root filename

Change the owner of the folder to the root account:

chown -R root A
14.find command

File Lookup command.
Find all the. txt format files in the current directory

find  . -name "*.txt" -print
15.tar command

The tar command can be used to decompress a file:

tar  -zxvf filename.tar.gz
16.grep command

The grep command is a powerful text-search tool that uses regular expressions to match text and print search results.
Find keywords from multiple files:

grep ‘linux‘ test1.txt test2.txt

Find the line that starts with H:

cat test.txt |grep ^h

Find the line content that does not start with H:

cat test.txt |grep ^[^h]

Find the line content that ends with the de:

cat  test.txt|grep de$

Displays the contents of the line containing the he or SH:

cat test.txt|grep -E "he|sh"

Displays the contents of the line with a. txt ending in the current directory and each string containing at least 7 lowercase letters:

grep  ‘[a-z]\{7\}‘ *.txt
17.source command

The source command is typically used to immediately execute an initialization file that has just been modified to take effect immediately without having to restart or log off.
For example, configure the Java environment variable, modify ~/.bash_profile, make it effective immediately:

source ~/.bash_profile
18. Switch Machine command 18.1 restart

Restart command:

reboot

Restart Now:

shutdown -r now

Restart immediately after 10 minutes:

shutdown -r 10

To set a specified time restart:

shutdown -r 20:10

If you set the restart through the shutdown command, you can cancel the restart with the Shutdown-c command.

18.2 Turn off the machine

Turn off the machine immediately:

halt

Or:

poweroff

Or:

shutdown -h now

Auto power off after 10 minutes

shutdown -h 10

If you set the shutdown through the shutdown command, you can cancel the restart with the Shutdown-c command.

19.mac View Java Home

Command:

/usr/libexec/java_home

JDK Path:

/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home

Common Linux commands for the big data base

Related Article

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.