Knowledgebase: Site Functions
Linux Shell Basics
Posted by ASO Admin on 05 February 2020 01:54 PM

Here are some basic commands to help you get started with Linux Shell commands. Shell is available on your account by default. If you have questions about your access you can create a ticket to speak with Support about it.

Access Shell
Log Into the Server
View Directories
Navigate Directories
File Management
Access MySQL

Access Shell

To use the following commands, you will need a Terminal (Mac or Linux-based) or Command Prompt (Windows). Alternatively, you can use a program such as PuTTY or WinSCP.

Log Into the Server

Using PuTTY

With a program like PuTTY, logging in is simple. Just type your domain name or server IP address in the Host field, enter 22 for the port, then click Open.

Shared and Reseller

In Terminal or Command Prompt, type the following:

ssh USER@SERVER -p 22

Be sure to replace USER with your primary username, and replace SERVER with the server IP or your domain name. Now you will be prompted for your primary user's password. You may not see the characters as you type them or when you paste from your clipboard, which is totally normal.

Dedicated and VPS

In Terminal or Command Prompt, type the following:

ssh USER@SERVER -p 22

 

Be sure to replace USER with your primary username, and replace SERVER with the server IP or your domain name. Now you will be prompted for your primary user's password. You may not see the characters as you type them or when you paste from your clipboard, which is totally normal.

View Directories

In Terminal or PuTTY, type the following to view a listing of all the files and subdirectories, complete with details:

ls -la

 

Alias/Shortcut

Shared and Reseller servers have a shortcut (alias) for the same detailed list.

ll

 

Alias/Shortcut Setup

The shortcut (alias) may not be set up on all servers, such as VPS or Dedicated. It can be set up with the command:

alias ll='ls -la'

 

Navigate Directories

Moving Between Folders

The following command takes you inside the specified directory where you can list the files to see what's inside. Be sure to replace FOLDER with the actual directory name.

cd FOLDER

 

The following command allows you to navigate directly into the file structure with the direct file path. Be sure to replace FOLDER/PATH/ETC with the actual directory name.

cd FOLDER/PATH/ETC

 

Moving Between Directories

To move up one directory, use the following:

cd ..

 

To move back to the previous directory, use the following:

cd -

 

File Management

View a File

The following command allows you to view a file without any possibility of modifying it. Be sure to replace FILE.NAME with the desired file name. 

cat FILE.NAME

 

Create a File

The following command creates a file if one does not exist or changes the timestamp on an existing file. Be sure to replace FILE.NAME with the desired file name.

touch FILE.NAME

 

Delete a File

The following command permanently removes files; so use with caution. Be sure to replace FILE.NAME with the desired file name.

rm FILE.NAME

 

Edit a File

These commands allow you to edit a file, so use them with caution. Be sure to replace FILE.NAME with the desired file name. Select an editor you are comfortable with before making changes to your files, in this case pico or nano editors.

pico FILE.NAME

 

or

nano FILE.NAME

 

Access MySQL

The following command takes you to MySQL where you can enter SQL syntax. Be sure to replace USER with your primary username or database user, and replace DB_NAME with the actual database name.

mysql -u USER -p DB_NAME

 

After using this command, you will be prompted for your primary password or the database user's password. Once logged into MySQL, the mysql> prompt will appear.

View Databases

At the mysql> prompt, type the following:

show databases;

 

View Tables

At the mysql> prompt, type the following:

use DB_NAME
show tables;

 

Be sure to replace DB_NAME with the actual database name, hit Enter or Return, then type the rest of the command.

View Table Attributes

At the mysql> prompt, type the following command:

use DB_NAME
describe TABLE;

 

Be sure to replace DB_NAME with the actual database name, press Enter or Return, then type the rest of the command, replacing TABLE with the actual table name.

MySQL Queries

At the mysql> prompt, type the SQL query as you normally would.

Exit MySQL

exit

 

Export a Database

The following command must be entered in the normal prompt, not the mysql> prompt. Be sure to exit MySQL if you are in it.

mysqldump -u USER -p DB_NAME > FILE.sql

 

Be sure to replace USER with your primary username or database user, replace DB_NAME with the actual database name and replace FILE with the desired backup file name. A prompt for your password will appear shortly after.

Importing a Database

This must be done in the normal prompt, not the mysql> prompt. Be sure to exit MySQL if you are in it.

mysql -u USER -p DB_NAME < FILE.sql

 

Be sure to replace USER with your primary username or database user, replace DB_NAME with the actual database name, and replace FILE with the known backup file name. A prompt for your password will appear shortly after.

(0 vote(s))
This article was helpful
This article was not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
Help Desk Software by Kayako fusion
ERROR: This domain name (kb.asmallorange.com), does not match the domain name in the license key file help.asmallorange.com.

For assistance with your license, please contact the Kayako support team: https://support.kayako.com