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

本站现有博文333篇,共被浏览922075

本站已经建立2628天!

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