Here in the above example we have executed memory utilisation check command on the remote host and redirected the output of the same to local file “/tmp/memory.txt”. Total used free shared buff/cache available ~]# ssh 'free -m' > ~]# cat /tmp/memory.txt In case you want to have the output of command executed on the remote host kindly follow below method. Jun 20 00:49:33 systemd: Started The Apache HTTP ~]# How to get output in the local Linux file by executing command on remote host. Jun 20 00:49:33 systemd: Starting The Apache HTTP Server. Status: "Total requests: 0 Current requests/sec: 0 Current traffic: 0 B/sec" Loaded: loaded (/usr/lib/systemd/system/rvice disabled vendor preset: disabled)Īctive: active (running) since Tue 00:49:33 EDT 56s ago Lets check the status of httpd service remotely using below ~]# ssh 'systemctl status httpd'.Now to start it again this httpd service use below ~]# ssh 'systemctl start httpd'.Since in the above example command consists of more than one word you need to enclose entire command in quotes ” ‘ “. In case you want to stop the httpd process on the remote ~]# ssh 'systemctl stop httpd'.Even you can reboot the server ~]#ssh reboot Run remote ssh command in Linux to Stop or Start any process or service.In case you want to have result of uptime command on the remote ~]# ssh uptimeĠ0:31:26 up 52 min, 2 users, load average: 0.00, 0.01, ~]#.In case you want to configure password less ssh between two server please read this article. Since we have configured password less ssh between two servers, system performed it without password prompt. In the above example system will prompt you for the password of your name on remote host. Lets say you want to have the mount point details of the remote ~]# ssh dfįilesystem 1K-blocks Used Available Use% Mounted on.HOST –> is the remote host on which you want to execute remote command.Ĭommand –> is the command that you want to execute on remote host. USER –> is the username on remote server. Ssh –> is the protocol or command being used for making connection with remote server. Basic syntax to run remote ssh command in Linux $ ssh 'command' Here: ![]() ![]() This is quite a common task for Linux system administrators, when there is need for execution of some command or a local Bash script from a one Linux server or Unix server on another remote Linux machine over SSH.In this article you will find the examples of how to run remote ssh command in Linux to Show result locally.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |