Replace mysql user shell in /etc/passwd using sed

I am searching a way to replace the mysql user shell configuration in /etc/passwd from command line as there are multiple servers where I want to disable the shell for mysql user.


mysql:x:498:498:MySQL server:/var/lib/mysql:/bin/bash 


mysql:x:498:498:MySQL server:/var/lib/mysql:/sbin/nologin 


Don't modify /etc/passwd with sed. Use the tools provided for interfacing with that file instead.

In this case, chpass/chsh, or possibly the more general usermod.

On most systems:

$ sudo chpass -s /sbin/nologin mysql


$ sudo chsh -s /sbin/nologin mysql

would work.

You don't want to edit /etc/passwd with sed (or with vim/emacs), and definitely not with sed -i.

Category: mysql Time: 2016-07-31 Views: 3
Tags: mysql passwd

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.237 (s). 12 q(s)