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

本站现有博文340篇,共被浏览1017867次

本站已经建立2718天!

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