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

本站现有博文337篇,共被浏览956660次

本站已经建立2668天!

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