Linux User Management basic commands

Source: Internet
Author: User

1,uid and GID

User is divided into: ordinary user, root user, System user

Ordinary users can only operate in their home directory, System temp directory, or other authorized directory. id>500

Root User: root user, id=0

System User: User required to run the system


Command:

ID View UID GID

Groups viewing the owning group

LS-LN groups and users are represented by UID.

who/users/w Query Current Online users

Useradd-u 555 User1

Useradd-g user1 (user name) User2 (group name)

useradd-d Home/mydir3 User3

passwd User name (the second column in/etc/shadow is displayed as 2!) Indicates that the user is not allowed to log on to the system)

Modify User: Usermod

Modify user home directory usermod-d/home/directory name-m user name

Frozen account: Usermod-l user name/etc/shadow There is an exclamation mark in front of the password

Unfreeze Account: Usermod-u user name


2, Task management

The time at which the at is executed


Ctrl+d End

ATQ Querying at Task List

ATRM Task Number Delete task

/etc/at.deny can be set to prohibit certain users from using this feature.


Periodic control Task cron

Service is Crond

Crontab-e into edit mode

Crontab-l Viewing Scheduled Tasks

Crontab-r Delete all Scheduled Tasks

Crontab-u xixi-l View Scheduled tasks for a specified user

/etc/cron.deny prohibit certain users from using this feature


System Scheduled Tasks:

/etc/crontab

Run-parts indicates how to run the script using



3, File Management

Dos2unix file name---"The dos text file is converted to a text file under UNIX.


4. Permissions for files and directories

Hide attributes (Special permissions)

Lsattr Viewing hidden properties

Chattr Setting hidden Properties

Such as:

Chattr +-=[asacddiijsttu] (many settings should be performed under root)

A (Append): Even if Root cannot delete it, you can append content to the file in a new way

I: Even root can not write to the file, rename, delete and other operations.

+: Add a special parameter-: Delete a special parameter =: Set the parameters of the following parameters to the file only

A: Files can only be added to data and cannot be deleted or modified.

C: Automatic compression of files, read is automatic decompression.

I: Cannot delete, modify, add, connect and so on file

S: If deleted, remove from disk space.

U: If deleted, also on disk, you can recover files.


A: When you have access to this file (or record), when you have set a this, his access time atime will not be modified to avoid the I/O slower machine access disk. This is useful for slow computers.

S: The general file is written in a non-synchronous disk, if you add S this is a sex, when you make any file changes, it will "sync" to write to the disk.

A: When you set a, this file will only increase the information, not delete or modify the information, only the root can be set to this nature.

D: When the dump program is executed, the D-component will make the file (or catalog) not be dump-ready

I: This I can be very good harm! He can allow a file to "not be erased, renamed, or linked or written or added!" "It's a great help to the system security!" Only root can set this.

Note: The set value of a and I is commonly seen, and many of the settings must be root to be set


5, default permissions and Umask

Root user, create file permission is 644, directory permission is 755

Normal user, create file permission is 664, directory permission is 775

Umask: (matte) defines that the value of the default permissions for the directory is "Umask after mask 777, the definition of the default permissions for the file is" umask after masking 666.

In file/etc/profile, the user of uid>99 (normal user) umask=002, otherwise 022

Root user so created directory 777-022=755; file is 666-022=644;

The directory created by the ordinary user is 777-002=775; the file is 666-002=664;



6,find command







4.locate

Depending on a database file for lookups, the Lilnux system retrieves all the files in the system by default and then logs the files to the database. When you run the Locate command, you look for records directly in the database and print to the screen, so using locate is faster than find.

Sometimes you need to execute the updatedb command to update the database.


The 5,which is used to find the absolute path to the executable file from the variable directory defined by path.


6,tar

Package files, consolidate directories into packages, and compress them.

TAR-ZCVF boot.tgz/boot to compress the boot directory into a boot.tar.gz file.

-Z with gzip compression,-C to create a compressed file,-V is to display the currently compressed file process,-F refers to the use of file name (boot.tar.gz)

TAR-ZXCF BOOT.TAR.GZ-C/tmp unzip the boot.tgz file and set the path to/tmp


7,cpio Backup

Commonly used with the Find command,

Backup

find/etc/-name *.conf |cpio-cov >/tmp/conf.cpio

Restores:

Cpio--ABSOLUTE-FILRNAMES-ICVU </tmp/conf.cpio




This article from the "8687196" blog, reproduced please contact the author!

Linux User Management basic commands

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.