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

本站现有博文332篇,共被浏览895857

本站已经建立2597天!

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