Command su
sudo su - some_user
is short for
sudo -s -u some_user
Breakdown:
-s
-> run the shell specified in the environment variableSHELL
if set, else the user's login shell.-u
-> run the command as the specified user rather than root (->sudo su -
)
Another useful command:
sudo su - some_user –c command_you_want_to_execute
which executes the single command_you_want_to_execute
with some_user
privileges.
SCP file transfer
It is relatively common that after you ssh into a machine you need to switch to a different user via sudo su
to be able to do stuff. Along with this there might be a need to download files. This is not possible in one go. You need to copy your file somewhere where your default ssh user also has access (try /tmp
) and then do a regular scp using that path:
scp my_ssh_user_name@my_company.com@your_ip_address:/tmp/your_file.txt .
The above copies your_file.txt
to the current directory -> .