this is simple CLI to remove couple file on remote machine
ssh 22.214.171.124 "rm -f /etc/yum.repos.d/repo.1 master.er top.fg REPO.l"
but only repo.1 file was deleted
what is wrong with my syntax
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
rm -f /etc/yum.repos.d/repo.1 master.er top.fg REPO.l will delete exactly those files. The files other than the first are being deleted in the current directory, which is likely to be your home directory on the remote machine.
If all four files are to be deleted from
/etc/yum.repos.d, you may use
ssh 126.96.36.199 "cd /etc/yum.repos.d && rm -f repo.1 master.er top.fg REPO.l"
This will first changed the current directory, and if that is successful, it will delete the files.
Also note that you ideally should not work as root but as an unprivileged user. This may mean that your
ssh command may end up looking as
ssh 188.8.131.52 "cd /etc/yum.repos.d && sudo rm -f repo.1 master.er top.fg REPO.l"
and that you execute this as a non-root user with
sudo access on the remote machine (there is seldom a reason to allow SSH access by root).
The benefit of this is that you explicitly state your intention to issue an operation as root, and that the commands executed as root are logged. The logging is important if you need to recover what operations may have hosed a system.