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

本站现有博文320篇,共被浏览760833

本站已经建立2432天!

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