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

本站现有博文328篇,共被浏览839983

本站已经建立2544天!

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