Linux Common Commands-users, rights management

Source: Internet
Author: User
Tags file permissions

SSH: Telnet

SSH [email protected]
SSH User name @ip

(1) WhoAmI: View Current user name

WhoAmI This command user to view the user name of the current system's current account. System user information can be viewed through cat/etc/passwd.

(2) Who: View logged in user

Who: View current logged in user information

(3) Exit: Log Out

If it is a graphical interface, exit the current terminal;

If you are using SSH telnet, log out of the login account;

If it is the logged-in user after the switch, exit will return to the previous login account.

(4) Useradd: Add user account
Useradd New user name-m-d/home/new user name-G group name

    • Linux each user must have a home directory, the home directory is the first login system, the user's default current directory (/home/users);
    • Each user must have a home directory, so when you create a user with Useradd, you must specify a home directory for the user;
    • The user's home directory is usually placed in the root directory of the home directory, the user's home directory and user name is the same;
    • If you do not specify a group name when creating a user, then the system automatically creates a group name that is the same as the user name.

(5) Userdel: Delete User

(6) passwd: Set User password

passwd User Name

(7) SU: Switch user name

The user name that SU needs to switch

Su-the user name that needs to be toggled, after switching the user, will also actively jump to the user's home directory

Note: If you have an Ubuntu platform, you need to add "sudo" before the command, and if you need an administrator to operate on some operations, Ubuntu does not need to switch to the root user to operate, just add "sudo".

sudo is a tool under the Ubuntu platform that allows the system administrator to let ordinary users perform some or all of the root commands, reducing the login and administration time of the root user and improving security.

(8) sudo : need to be added when you need Super Administrator's privileges, and at the front of the command line, space is required later
sudo passwd Laowang

Sudo-s switch directly to the root user

(9) See which user groups are available

Method One: Cat/etc/group

Method Two: Grounpmod + three times Tab key

(groupadd): Add group account

Groupadd YYY Add a YYY user group

(one) Groupdel: Delete group account
Groupdel YYY Delete a group,,, note that sudo is required

Groups: See which group the user is in

Groups Laowang: View all user groups that Laowang belongs to

(usermod): Modify the group in which the user is located

How to use: Usermod-g user Group user name

(14) Add sudo permissions to the created normal user

Usermod-g YYY Laowang Add the old king to the YYY group

Usermod-a-G xxx Laowang add Lao wang to XXX group

-G and-g,-g specify the default group

Useradd create a new user without sudo, or switch to root, need to add this user to ADM, sudo group inside can

(chmod): Permissions to modify files

There are two ways to use chmod to modify file permissions: Letter method and Digital method

Letter method: chmod u/g/o/a +/-/= rwx file

U: Owner
G: Same group
O: Others
A: all, i.e. U, G, O

+ Add Permissions
-Remove Permissions
= Set Permissions

Rwx

R: Read------> corresponding number is 4
W: Write------> corresponding number is 2
x: Execution------> corresponding number is 1

If executed: chmod u=rwx,g=rx,o=r filename is equivalent to: chmod u=7,g=5,o=4 filename

Note: If you want to recursively add the same permissions to all directories, you need to add the parameter "-R". such as: chmod 777 folder, only modify the folder permissions to 777, will not modify the permissions of the file inside, chmod 777 test/-R recursive test directory under All files plus 777 permissions

(+) Mount: Mount command

Chown: Modify File Owner

CHGRP: Modify the group to which the file belongs

VI: File editing
From command mode---Edit mode: I, A, O, I, A, O
----from edit mode command mode: ESC
From the command mode----the last line mode: Enter a colon, that is, shit+;

Last-line mode:
W Save
Q exit
! Forced

Commonly used for:
Wq save exit, equivalent to X (lowercase x),,, also equivalent to shit+2 z in command mode
q! Do not save exit

Command mode:
HJKL control up and down function
M Middle Position
L The last line of the current screen
YY Copy, 8yy: Indicates copying 8 rows from the line where the current cursor is located
P Paste
DD Cut, 8DD: Cuts 8 lines from the line where the current cursor is located

U undo
Ctl+r Anti-Revocation

G to the last 1 lines
15G means jump to line 15th
1G means jump to line 1th

GG Jump To line 1th

Linux Common Commands-users, rights management

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.