SSH Commands

Hi,

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.
oo7mlAsked:
Who is Participating?
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:
Reboot:
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".
http://www.cyberciti.biz/faq/ubuntu-linux-start-restart-stop-apache-web-server/
0

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:
http://www.sshcommands.co.uk/
0
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)?
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

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"
0
oo7mlAuthor Commented:
Ok great, thank you
0
rindiCommented:
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.
0
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.
0
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

Or

B - root poweroff
0
Tom ChadaraviciusSenior DeveloperCommented:
If you are "root", you do not need to prepend the command with "sudo", so it will be
"poweroff"
or
"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".
0
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 :-)
0
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
developer ALL=NOPASSWD: ALL

Open in new window

0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.