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

本站现有博文323篇,共被浏览800646

本站已经建立2499天!

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