SSH Cheatsheet
Server / Spec Checks
Checking the server memory (RAM) consumption:-
free -m
Checking the server HDD consumption:-
df -h
Checking the size of each top-level directories from a directory:-
du -h --max-depth=1 /path/to/directory/
Checking the server date/time:-
date
Checking Linux build/version:-
uname -a
Checking server operating system version:-
cat /etc/redhat-release
Basic Commands
Navigate to a particular directory:-
cd /var/www/vhosts/example.com/
List the contents of the current directory:-
ls
Edit a file:-
vi /etc/httpd/httpd.conf
Save and exit a file:-
:wq
Exit a file without saving:-
:q
Working with Files & Folders on the Linux Command Line
Creating Archives
Tar
Everything in current directory:-
tar cf filename.tar *
Everything in specific directory:-
tar -cf filename.tar directoryname/
Zip
Working with MySQL on the Linux Command Line
Exporting MySQL Database
mysqldump -u username -p database > filename.sql
You will be prompted to enter the password for the database user after entering the above.
Be sure to replace username
with the database username, database
with the name of the database and filename
with whatever you wish to call the dump file.
Importing MySQL Database
mysql -u username -p database < filename.sql
Be sure to replace username
with the database username, database
with the name of the database and filename
with whatever the name of the dump file you’re importing is.