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

本站现有博文311篇,共被浏览740097

本站已经建立2377天!

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