Linux Command notepad

Source: Internet
Author: User

----- Delete a user

If a user is no longer using it, he or she can delete it from the system. To delete a user, you must delete the user information in the/etc/passwd,/etc/shadow,/etc/group, and other system folders, if necessary, delete the user's home directory (Home Directory). The command used is userdel.

Userdel option Username

The common parameter-R is used to delete the user's home directory. If this parameter is not added, the home directory is not deleted.

Warning do not use this parameter easily. If you have important files, back up them in advance.

Of course, you can also go to/etc/passwd to delete some information about the user you want to delete. I am a beginner and do not recommend this because I accidentally deleted the error.

Another method is as follows:

Go to/usr CD/usr

Or some sbin CD sbin systems need this.

Enter the./userdel-r username.

I feel so troublesome. I don't know the same principle as the first one. Why ?? Leave questions for the moment.

-- Permanently delete a user

Userdel Username

Groupdel User Name

Usermod-G username force Delete All subdirectories and sub-files under the user's home directory and Home Directory

----- Delete a non-empty directory

Rm-RF directory name

To delete a non-empty directory in Linux, a prompt is displayed, indicating that the directory is not empty and cannot be deleted. You can add the-F parameter to force the deletion, which is the meaning of-F force. -R is a recursive delete operation. This is much easier than rmdir. Of course, you must be clear about the consequences of deleting directories.

----- Add a system user

Useradd-o-u number Username

The instructor mentioned that the UID of the System user is from 0 ~ 499, (including 0, 499 ). However, in practice today, we found that the uid n is not unique is prompted when useradd username-u number (UID) is used. Later, it was successful through Google. The-O parameter must be added. I still don't know the specific reason.

----- View the file type

File Path Name

Generally, I use the LS command to view some attributes of the file. You can also use the path name after the file to view the type of the corresponding directory/file.

----- Show hidden files

L. Or ls-D .*

The preceding two commands list "." and "..". If not, add the-a parameter. This has not been tested yet. CTRL + l clear screen. Haha.

----- Add existing users to the group

Gpasswd-a username group name

Or The usermod-G group name and username feel pretty handsome .. Haha

----- Temporarily close a user

Find the user to be processed in the/etc/shadow file (generally, the user we created is at the end ). Add * to the front of the Second Field, and remove * to restore it to the previous step. Or run the following command:

Passwd username-l recovery: passwd username-u ps: Lock unlock

Usermod-l user name locked-u unlock TT told me

----- Display User Information

Id username or go to/etc/passwd to view.

----- Modify the file creation time (in virtualbox)

Touch-c-t hhmmmmddyy file name

----- Manage user tools or commands

 

Related Article

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.