SSH Commands


I am trying to learn SSH commands for logging in and controlling / managing a server.

The servers are usually Wordpress sites running on Ubuntu.

I understand how to login, but i am sure there are a lot of useful commands i need to learn such as restarting the server etc.

Appreciate any help you have on this.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tom ChadaraviciusSenior DeveloperCommented:
shutdwon -r now

Open in new window

. The "-r" switch is important, it tells to reboot after shutting down, else you will not bring up your server after shutdown
List files with details:
ls -l

Open in new window

Restart Apache (the slightly older way)
sudo service httpd restart

Open in new window

You need "sudo" unless you are "root".

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David AtkinTechnical DirectorCommented:
This is a useful site for learning SSH Commands:
oo7mlAuthor Commented:
Thanks guys... i'll always be logged in as root.

Newbie questions... what exactly are you restarting?

Do the commands differ based on your stack (Apache / Ubunto / Wordpress)?
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

Tom ChadaraviciusSenior DeveloperCommented:
You may need to reboot your server; and you will likely be restarting services .
"httpd" is the daemon (service) name for Apache.
The commands differ based on Linux breed and version (Ubuntu/Debian on one end, RHEL/CentOS/Fedora on the other). Wordpress relies on PHP and web service (Apache), so the Wordpress itself can be said to be "operating system blind"
oo7mlAuthor Commented:
Ok great, thank you
NEVER logon as root. Always use sudo. SSH if configured correctly won't allow you to connect as root.

Besides, that you aren't looking for "SSH Commands", SSH only allows you to connect to a remote system, it doesn't have commands as such. What you are looking for is mainly commands used in the Linux Terminal, as that is what you are connecting to.
David AtkinTechnical DirectorCommented:
Definitely agree with rindi about not using root. It's best practice to create another administrator account with an uncommon username and then disable the root account (after testing of course).

In addition it's also good practice to either change the ssh port from the standard 22 and enforce keys.
oo7mlAuthor Commented:
Thanks guys.

At the moment I am logging in as:

ssh root@##.##.##.##

Enter password and then I am in.

I'll look into disabling root later too.

So if I was to reboot the server under root account is it:

A - sudo poweroff


B - root poweroff
Tom ChadaraviciusSenior DeveloperCommented:
If you are "root", you do not need to prepend the command with "sudo", so it will be
"shutdown -r now".
But, if you create user "develop" (for example), add "develop" to sudoers and ssh develop@x.x.x.x,
then it will be
"sudo poweroff".
oo7mlAuthor Commented:
Thank you very much.

Now the next battle. How to turn off root and set up a new ssh user. I promise this is the last question :-)
Tom ChadaraviciusSenior DeveloperCommented:
1. Create a new user (I'll call it "developer")
2. Add it to "sudoers" file. The "sudoers" file usually sits in /etc/ directory, and by default can only be read by root. Root needs to change permits to read and write before the sudoers file can be saved
## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)
#includedir /etc/sudoers.d

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.