Lab Solution: Using sed
To get output on standard out (terminal screen):
student:/tmp> sed s/'\/sbin\/nologin'/'\/bin\/bash'/g /etc/passwd
or to direct to a file:
student:/tmp> sed s/'\/sbin\/nologin'/'\/bin\/bash'/g /etc/passwd > passwd_new
Note this is kind of painful and obscure because we are
trying to use the forward slash ( / ) as
both a string and a delimiter between fields. One can do
instead:
student:/tmp> sed s:'/sbin/nologin':'/bin/bash':g /etc/passwd
where we have used the colon ( : ) as the delimiter
instead. (You are free to choose your delimiting character!)
In fact when doing this we do not even need the single
quotes:
student:/tmp> sed s:/sbin/nologin:/bin/bash:g /etc/passwd works
just fine.