Connecting to SSH

ssh USERNAME@SERVERNAME (for example: ssh hilih_2312@rask22.raskesider.no)

You will be prompted for your password, and can log in.

Basic file system commands

man [commandname] Show help page for any command

ls -la List files in a directory

cd [directoryname] Go in to a directory

cd .. Go up one level

cd ~ Go to your home directory (typically /kunder/group/username)

pwd Display current path

cat [filename] Print contents of file to console

nano [filename] Handy text-editor with easy controls and onscreen help (certainly easier than vi or vim)

gzip / gunzip [filename/folder] Pack/unpack .gz files

zip / unzip [filename/folder] Zip/unzip .zip files

tar -xvf [filename] Unpack a .tar archive

tar -xvzf [filename] Unpack a .tgz archive

Permissions on files

Many online articles tell you to set permissions on files in order to make something work. Our file system is properly configured, and unless you are doing any advanced sharing of files across hosts - your directories only need 700 permissions, and your files need 600 to be usable by the web server.

chmod 700 [directoryname]

chmod 600 [filename]

To recursively fix permissions for all files in your public/ folder, run the following commands from your home directory.

find public/ -type d -exec chmod 700 {} \;

find public/ -type f -exec chmod 600 {} \;

Importing and exporting databases

To export the database to a text file, sql dump (.sql) run:

mysqldump -u USERNAME -p DATABASENAME > FILENAME.sql

To make sure database dumps are consistent, the --single-transaction should be added, like:

mysqldump --single-transaction -u USERNAME -p DATABASENAME > FILENAME.sql

To import a database from an sql dump, run:

mysql -u USERNAME -p DATABASENAME < FILENAME.sql

Viewing and examining log files

The Apache webserver stores its logs in the logs/ folder. 

Accesslog
Contains all requests that are passed back from the front-end webserver (nginx)

Errorlog
Contains all errors 

The following command will display log entries as they are added in realtime:

tail -f logs/*log List everything from both the Accesslog and the Errorlog

tail -f logs/Errorlog Print only additions to the Errorlog

grep - Finding content in files

To find an occurence of [searchstring] in any file recursively from your current directory, write:

grep -R [searchstring] *

You can make it case insensitve by adding the -i parameter (grep -iR ...)
Was this article helpful?
Thank you!