Linux operation instructions

Source: Internet
Author: User
Tags parent directory

1. View as Action directory location
> pwd

2. View the contents of the file in the (current) directory
LS//list
Ls-l or ll//show file details
Ls-al//all Show file details (including hidden files)
LS-A//Show directory all file names (including hidden files)
ls [-al] Directory//view file information for the specified directory

3. Switching of directories

CD Catalog Name

Cd.. or CD: ///Parent Directory switch
Cd. or CD.///switch to the current directory
CD ~ or CD//switch directly to the user home directory

4. User Switching
> Su-or su-root//switch to root super admin
> su Normal user name//switch to normal user
> Exit//Return to original user

User Switching can result in overlay effects, so do not repeat the SU action (used with SU and exit pairs)
Jinnan--->root--->jinnan--->root--->jinnan

5. See who the current user is
> WhoAmI//Displays the user who is currently operating system
> Who am I//display user information for login system (not related to SU)

6. Graphical interface and command interface switch
># init 3//Switch to command interface
># init 5//Switch to graphical interface

7. View the executable file location for the instruction
> which directive

8. Direct output file contents to Terminal
> Cat Files

9. Clear the screen
> Clear

10. Directory Operations
① Creating directories Make Directory
> mkdir directory Name//create a single directory
> mkdir-p newdir1/newdir2/newdir3//Recursive creation of multilevel catalogs
> mkdir Dir1/dir2/newdir
> Mkdir-p dir1/newdir2/newdir3
The new directory has a level greater than or equal to 2, you need the-p parameter,
equals 1, no need.
> Mkdir/home/jinnan/shandong//"absolute path mode" for the relative root directory to create the Shandong directory

② Moving Directory Move
> MV Dir1 dir2//dir1 moved to the DIR2 directory
> MV Dir1/dir2 dir3//dir2 moved to the DIR3 directory
> MV Dir1/dir2 dir3/dir4//dir2 moved to the DIR4 directory
> Mv/home/jinnan/beijing/home/jinnan/shandong//absolute path mode: Beijing move to Shandong Directory
(The destination directory that you moved to is "existing")

③ Directory Change name operation
The second parameter of the MV instruction is the new name or the name change operation.
The name that exists is the move operation
MV is the "Move and change name" merge directive
> MV Dir1 newdir//dir1 move to the current directory and change the name to Newdir
> MV Dir1/dir2 dir3//dir2 move to dir3 directory and change name to original
> MV Dir1/dir2 dir3/newdir//dir2 move to the DIR3 directory and change the name to Newdir

④ copy (and change name) operation copy
-R Recursive Recursive
> Cp-r dir1 dir2//dir1 copied to Dir2, and renamed as original name
> cp-r dir1/dir2 dir3/newdir//dir2 Copy to Dir3, and change name to Newdir
> cp-r dir1/dir2 newdir//dir2 Copy to current directory and change name to Newdir

> CP Dir1/filea dir2//filea copied to Dir2 and renamed as original name
> CP dir1/filea dir2/dir3/newfile//filea Copy to Dir3, and change name to NewFile

⑤ Delete operation remove
-F Force Mandatory
> RM File//delete file files
> rm-r dir//delete directory
> RM-RF filename//recursive forced Delete file (directory)

> RM-RF///recursive forced delete "/slash" root directory

11. Simple File operation
① file Content View
> Cat filename//To output all content to the terminal at once
> more filename//view the contents of a file line by type
Q Key End View

> Less filename//"Up and down" key mode to view the contents of each part of the file (support back to see)
Q Key End View
> head-n filename//View the top n rows of a file
> tail-n filename//View the last n rows of a file
> WC filename//view file content line count

② Creating a file
> Touch filename//create filename file in current directory
> Touch dir/filename//create filename file in the specified directory
> Touch/home/jinnan/dir/newfile//Create NewFile file by absolute path mode

③ Append content to File
> Echo content > Files//Add "content" to a file in overwrite write
> Echo content >> files//Add "content" to a file in "append" mode
(When using the above two instructions, the file does not exist automatically created)

12. User actions (Create, modify, delete)
Corresponding configuration file:/etc/passwd
① Creating Useradd
># useradd-g Group Encoding-D Home Directory-u user number user name
># Useradd User Name

② modifying Usermod
># usermod-g Group-D home directory (manually created)-u user number-l newname user name

③ Delete Userdel
># userdel-r username//delete user information at the same time "home directory" also deleted

13. Operation of the group (create, modify, delete)
Corresponding configuration file:/etc/group
① Creating Groupadd
># Groupadd Group Name
② modifying Groupmod
># groupmod-g itself number-N New name Group name
③ Delete Groupdel (Note: User information inside the group is forbidden to delete)
># Groupdel Group

14. View the parameters that the directive can use
> Man command

Linux operation instructions

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.