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

本站现有博文330篇,共被浏览861948

本站已经建立2570天!

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