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

本站现有博文322篇,共被浏览783896

本站已经建立2477天!

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