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

本站现有博文332篇,共被浏览875410

本站已经建立2583天!

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