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

本站现有博文320篇,共被浏览760860

本站已经建立2432天!

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