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

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

本站已经建立2620天!

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