Switching to another user or script execution of an instruction

Delete Row's first space

  sed 's / ^ [\ t] * // g'

Delete end of the line spaces

  sed 's / [\ t] * $ // g'

Remove all spaces

   sed s/[[:space:]]//g

 

sudo su - user -c "command"

 

[mysql@localhost ~]$ sudo su - liu -c "mkdir ./123"

 

su switch user 
su - username is complete switch user
-c execute "This command when the user identity

  cat  test.sh

  sudo su - git -c "rsync -azrv gogs-repositories/ admin@IP:git.bak"

#!/bin/bash

su - USER << EOF

lsnrctl start

sqlplus /nolog

conn /as sysdba

startup

exit

EOF

 

su sum  su - target Ward Gender:

su switch user, without switching the user environment

su - switch user, the user is also switched environment

su - USER -c "XXX"    handover users, the user switch environment, perform the appropriate action

Guess you like

Origin www.cnblogs.com/liuzhiyun/p/11268389.html