Replace mysql user shell in /etc/passwd

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.

Actual

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

Desired

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

Replay

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

or

$ 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: shell Time: 2016-07-31 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

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