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

本站现有博文327篇,共被浏览833198

本站已经建立2538天!

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