Pages

Sunday, July 29, 2018

Changing Server Hostname

To change your hostname, enter the following command as root:

$ hostname servername.yourdomain.com

If you are using cPanel, you will need to resync your license with the cPanel license server.  To do this, use the following command:

$ /usr/local/cpanel/cpkeyclt

Creating a Welcome message for SSH logins

Did you ever want to change or create a new login message anytime someone logs into SSH? We'll show you how it's done.

First off login to the server as root. Then type in the following:
pico /etc/motd

Now type in the security login message you wish all users to see once they login to your server through SSH. Try something like this as a start:

This computer system is for authorized users only. All activity is logged and regulary checked by systems personal. Individuals using this system without authority or in excess of their authority are subject to having all their services revoked. Any illegal services run by user or attempts to take down this server or its services will be reported to local law enforcement, and said user will be punished to the full extent of the law. Anyone using this system consents to these terms.

Now type Ctrl+X then hit Y and enter.
Logout of SSH then log back in, you will receive your new greeting!

Common SSH Commands - Linux Shell Commands

Navigation

pwd Shows the full path of the current directory
ls Lists all the files in the current directory
ls -al Lists all files and information
ls –alR Lists all files and information in all subdirectories
ls -alR | more Same as ls –alR, pausing when screen becomes full
ls -alR > filename.txt Same as ls –alR, outputs the results to a file
ls *.html Lists all files ending with .html
cd [directory name] Changes to a new directory
cd .. Changes to directory above current one
clear Clears the screen
vdir Gives a more detailed listing than the "ls" command
exit Log off your shell

Moving, Copying, and Deleting Files

mv [old filename] [new filename] Move/rename a file
cp [filename] [new filename] Copies a file
rm [filename] Deletes a file
rm * Deletes all files in current directory
rm *.html Deletes all files ending in .html
Creating, Moving, Copying and Deleting Directories
mkdir [directory name] Creates a new directory
ls -d */ Lists all directories within current directory
cp -r [directory] [new directory] Copies a directory and all files/directories in it
Searching Files and Directories
find . -name [filename] -print Searches for a file starting with current directory
grep [text] [filename] Searches for text within a file