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-l/user

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-l

(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 a1/a2/a3/a4
Ls-l

CP command: Copy files or directories

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

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

sudo cp-r/tmp/test/usr

MV Command: Move files and directories, or rename

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

(12) Rename the above example test directory to Test2

sudo mv/usr/test/usr/test2

RM command: Removing files or directories

(13) Delete the Bashrc1 file copied from the previous example
sudo rm/usr/test2/bashrc1

(14) Delete the Test2 directory of the above example
sudo rm-r/usr/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. 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
Mkdir/tmp/hello
Ls–al Tmp/hello

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

Touch--help
touch-d "5 days Ago" Hello

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 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
sudo mkdir test
SUDO–CZVF Tar test.tar.gz

(27) Unzip to/tmp directory
Tar test.tar.gz

grep command: Find string

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

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

(30) View the value of the Java_home variable
Echo $JAVA _home

Familiar with common Linux operations

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.