Linux Command Two

Source: Internet
Author: User

1. Create a new user account

Useradd-The user name of the new parameter

Parameter description:

-C < remarks > Add note text. Note text is saved in the remarks field of the passwd.

-D < login directory > Specify the start directory for user login.

-e< Expiration Date > the expiry date of the specified account. Time format:yyyy-mm-dd

-f< buffer days > Specify the number of days after the password expires to close the account.

-g< Group > Specify the group to which the user belongs.

-g< Group > Specify the additional groups to which the user belongs.

-M automatically establishes the user's login directory.

-M do not automatically establish the user's login directory.

-N cancels the creation of a group named after the user name.

-R Establish the system account number.

-s<shell> Specifies the shell to use when the user is logged in .

-u<uid> Specifying a user ID

-p (password) encrypted password, view using tail-l/etc/shadow ( use sparingly )

2, Modify the user's password

[[Email protected]~]# passwd user name

3 . Check the encrypted user account and password using tail-l/etc/shadow

4. Modify user account

Usermod- parameters [ user account ]

 -c< notes > Modify the notes text for the user account.

 -D Login directory > Modify User login directory.

 -e< expiry Date > Modification of account expiration date, format:yyyy-mm-dd

 -f< buffer days > Modify the number of days after the password expires to close the account

No.

-g< Group > Modify the group to which the user belongs.

 -g< Group > Modify the additional groups to which the user belongs.

 -l< account name > Modify user account name.

 -L LOCKS the user password to invalidate the password.

 -s<shell> modifies the shell used by the user when they log in .

 -u<uid> Modify the user ID.

 -U unlocks the password.

5. Delete user account

Userdel-r user account delete users and their home directories

Note: when the parameter R is not added, the user account is deleted and the relevant files are not deleted.

6. Set up user groups

Groupadd [-g GID] [-o]] [-R] [-f] GroupName

-g gid: Specify group ID number

-o: Allow user groups to create duplicate IDs

-R: Create System user group, lower than 499 SYSTEM account

Query team members with/etc/group can query team members

6. change the group ID or name

Groupmod [G < Group ID > <-o>][-n < New group name >][ group name ]

-G < Group identification code > set the group ID you want to use.

-O re-use the group identification code.

-N < new group name > set the new group name you want to use.

7. Delete Group

Groupdel [ group name ]

Note: When you need to delete a group from your system, you can use the Groupdel directive to do this. If some users are still included in the group, you must delete the users before you can delete the groups.

[[Email protected]]# groupdel linuxtest1 Delete linuxtest1 user Group

8. Modify File Permissions

chmod [-r] permission file name

(1) The file owner only has read-only permission, and the file belongs to the group user has read, write permissions, other users with

Read, write, and execute three kinds of permissions can be written as the following commands:

chmod 467 test "r=4,w=2,x=1"

(2) You can also use the following methods to set the user specified permissions

+: Add permissions (w,R,x)

-: Delete permissions (w,R,x)

U: File owner g: File belongs to group o: Other person a: everyone

[Email protected]]$ chmod u+x *

[Email protected]]$ chmod G+rx *

[Email protected]]$ chmod a-r *

9. Modify the file owner and the owning group

Chown [-r] permission file name

 -R recursively modifies all files in the directory and its subdirectories

10. Modify the user group to which the file belongs

CHGRP [-R] group name file name

11. compare two different files

diff [Options] file 1 file 2 (file 1 is a baseline)

which find files.

which [ file ...]

Note:the which directive looks for eligible files in the directory where the environment variable $PATH set. Commonly used to find executable commands

Which and Whereis:

The which command is to find out if a command exists, and where the command is stored.

the Whereis command can only be used to search for program names, and only binary files ( parameter - b), man description file ( parameter - m) and source code file ( parameter - s)

difference : Which can only be found under PATH environment variable executable file

12. Aliases

(1) aliases alias rm = ' Rm-i '

(2) Delete alias Unalias RM

13. Output Printing function

echo String Displays the text line or variable value, or enters a string into the file

echo 's common function:\c do not change the line \ tab \ n newline

Note: For Linux systems, you must use the- e option to make the above escape characters effective

Example:$ echo-e "hello\tboy"

$ Hello Boy

The echo command is sensitive to special characters, and if you want to output special characters, you need to mask their special meanings with a \(escape symbol).

Common special characters: double quotes "Anti-quote " backslash \

Example:$ echo " \" \"" // output ""

14. Setting Environment Variables

(1) Configure temporary environment variables export path= $PATH:/sbin

(2) Configure the current user's environment variables vi. BASHRC add export path= $PATH on the last line :/sbin

Source ~/.BASHRC Load This configuration file

(3) Configure the Global environment variables:

Vi/etc/profile added in the last line

Export path= $PATH:/sbin

Source/etc/profile Loading a global configuration file

Note:the source command : used to re-execute the newly modified initialization file to make it effective without having to log off and log back on

15.Stat Command

Stat File View Create file time, modify time, update permission time

16 . Hardlinkand Soft link for Linux (softlink):

Hard link:ln source file destination file

Soft link:ln-s source file destination file

The difference between the two:

(1) hard: The source file and the target file share an inode number; soft: source and destination inode numbers, proving they are not the same file

(2) thelink file in the soft link can be clearly seen through a command such as 'ls-l'

(3) each additional hard link, hard link number +1, when the number of hard links are all deleted, the file will really disappear

(4) Inconsistent file size

17, SU: switch User

the Su user name toggles the user name, but the original path does not change

Exit Toggle

Su- user name switch to root directory of user name

18. Search History Command:

(1) History i15 invoke previous commands

(2)!863

(3) Find a specific command in the history command

Linux Command Two

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.