EADST

Delete a User in Linux

Deleting a user in Linux is a common administrative task, especially when cleaning up old or inactive accounts. In this short guide, we'll walk you through the steps to safely remove a user from your system.

1. Check Existing Users

Before deleting a user, it's a good idea to confirm the user exists. You can check the list of users in the /etc/passwd file or run:

cat /etc/passwd
This command lists all system users.

2. Deleting a User

To delete a user, Linux provides the userdel command. If you simply want to remove the user without touching their home directory or files, run:

sudo userdel username
Replace username with the account you want to delete.

3. Delete the User and Home Directory

If you also want to remove the user’s home directory and mail spool, use the -r option:

sudo userdel -r username

4. Handling Active User Processes

If the user is currently logged in or running processes, you might see an error like:

userdel: user username is currently used by process 
To resolve this, terminate their processes with:
sudo killall -u username
Then, proceed with deleting the user.

Conclusion

Managing users in Linux is straightforward with the userdel command. Just be cautious, especially when using the -r option, as it permanently removes the user’s files.

This guide should help you effectively manage and clean up user accounts on your Linux system!

相关标签
About Me
XD
Goals determine what you are going to be.
Category
标签云
VPN Bert Pandas CLAP Excel PDF 签证 Website FP32 Dataset Rebuttal logger BF16 Paper Template WAN Numpy NLP Knowledge CV 公式 torchinfo Freesound Baidu Miniforge GGML Statistics Web Clash SAM Safetensors uWSGI Hilton git OpenCV FP16 Crawler Streamlit Tracking BeautifulSoup Permission Agent SQL Distillation 版权 Django Hotel UI Qwen2 Google Hungarian Zip Quantization 第一性原理 Python 阿里云 Jupyter Github Linux Algorithm 图形思考法 Ubuntu Password Qwen2.5 继承 Quantize Pickle UNIX AI Input Animate icon Food BTC DeepSeek Mixtral Attention tar ModelScope WebCrawler GIT LLM GPTQ FastAPI Claude Magnet 云服务器 Vmess LLAMA Augmentation MD5 图标 LoRA HaggingFace Shortcut ChatGPT Jetson 多进程 v0.dev 域名 YOLO CAM transformers Michelin Video C++ NLTK COCO Math API VGG-16 Breakpoint Transformers Llama Plotly TensorFlow IndexTTS2 Markdown CUDA 净利润 Vim Heatmap hf 多线程 diffusers TensorRT Git PyTorch PDB 算法题 音频 Paddle XML 顶会 llama.cpp RGB 腾讯云 Conda Card Sklearn LaTeX FP8 Data 搞笑 Review LeetCode Cloudreve 飞书 CC QWEN 递归学习法 Nginx uwsgi GPT4 Anaconda OpenAI PIP Ptyhon Bipartite git-lfs JSON CEIR NameSilo Plate PyCharm 关于博主 Qwen Domain InvalidArgumentError tqdm Image2Text Logo Translation Tiktoken Disk DeepStream Land Windows SPIE ResNet-50 Pillow TTS GoogLeNet XGBoost News Datetime Color 强化学习 Docker Tensor Diagram OCR TSV Base64 printf Gemma Pytorch Firewall EXCEL RAR Interview v2ray FP64 HuggingFace 财报 Proxy CSV Bitcoin CTC SVR Use VSCode SQLite ONNX 报税 Random Search FlashAttention mmap scipy Bin 证件照
站点统计

本站现有博文323篇,共被浏览795429

本站已经建立2493天!

热门文章
文章归档
回到顶部