Familiar with common Linux operations

Source: Internet
Author: User
Tags create directory touch command

Please follow the Linux basic commands as required on the machine.

CD command: Switch directories

(1) Switch to directory/usr/local

Cd/usr/local

(2) Go to the current upper directory

Cd..

(3) Go back to your home folder

CD ~

ls command: View files and directories

(4) View directory/usr for all files

Ls–al/usr

mkdir command: Create new directory

(5) Enter the/tmp directory, create a directory named A, and see how many directories exist

Cd/tmp

mkdir A

ls–al/tmp/a

(6) Create directory A1/A2/A3/A4

Mkdir–p A1/A2/A3/A4

rmdir command: Delete empty directory

(7) Delete the directory A (/tmp) created in the example above

RmDir A

(8) Delete directory a1/a2/a3/a4 to see how many directories exist

Rmdir–p A1/A2/A3/A4

Ls-al

CP command: Copy files or directories

(9) Copy the. BASHRC under the home folder to/usr, named Bashrc1

CP ~/.bashrc/usr/bashrc1

(10) Create a new directory test in/tmp and copy the contents of this directory to/usr

mkdir test

CP TMP/TEST/USR

MV Command: Move files and directories, or rename

(11) Move the example file Bashrc1 to the directory/usr/test

MV Bashrc1/usr/test

(12) Rename the above example test directory to Test2

MV Test Test2

RM command: Removing files or directories

(13) Delete the Bashrc1 file copied from the previous example

Rm–i Test2/bashrc1

(14) Delete the Test2 directory of the above example

RmDir test2

Cat command: View file contents

(15) View the contents of the. bashrc file under the home folder

Cat. BASHRC

TAC Command: Reverse list

(16) Reverse View the contents of the. bashrc file in the home folder

Tac. BASHRC

More command: One page, one page turn to view

(17) Turn the page to view the contents of the. bashrc file in the home folder

More. BASHRC

Head command: Remove the previous lines

(18) View the first 20 lines of the contents of the. bashrc file in the home folder

Head–n 20.BASHRC

(19) View the contents of the. bashrc file in the home folder, followed by 50 lines, showing only the previous lines

Head–n-50.bashrc

Tail command: Take back a few lines

(20) View the contents of the. bashrc file in the home folder the last 20 lines

Tail–n. BASHRC

(21) View the contents of the. bashrc file in the home folder, listing only 50 rows of data

Tail–n-50. BASHRC

Touch command: Modify the file time or create a new file

(22) Create an empty file in/tmp Hello and check the time

Touch Hello

Ls–l Hello

(23) Modify the Hello file to adjust the date to 5 days ago

Touch–d "5 days Ago"

Chown command: Modify file Owner permissions

(24) Change the owner of the hello file to the root account and view the properties

sudo chown Root/tmp/hello

Ls–l/tmp/hello

Find command: File lookup

(25) Find the file named. BASHRC in the home folder

Find. BASHRC

Tar command: Compress command

(26) Create a new folder in/directory test and then package it in/directory into test.tar.gz

mkdir test

TAR–CZVF test.tar.gz Test

(27) Unzip to/tmp directory

TAR–XZVF test.tar.gz–c/tmp

grep command: Find string

(28) Find the string ' examples ' from the ~/.BASHRC file

grep examples. Basherc

(29) Configure Java environment variables, set in ~/.BASHRC

Gedit ~/.BASHRC

(30) View the value of the Java_home variable

Echo $JAVE _home

Familiar with common Linux operations

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.