Practical Web Programming
Showing posts with label command. Show all posts
Showing posts with label command. Show all posts

Tuesday, April 15, 2014

Using scp (Secure Copy) to Copy Files from Remote Server

Copy a file from a remote host to a local machine

$ scp username@example.com:/home/kabalweg/my_archive.ta.gz /home/kabalweg/local

Copy a file from a local machine to a remote host

$ scp /home/kabalweg/local/my_archive.tar.gz username@example.com:/home/kabalweg
 

Compress/Uncompress in Linux/Unix

Compress the folder named sites inside the /home/kabalweg directory:

$ tar -zcvf my_archive.tar.gz /home/kabalweg/sites

Uncompress file into the current directory:

$ tar -zxvf my_archive.tar.gz

Where: 
z = compress archive using gzip program
c = create archive 
v = verbose i.e display progress while creating archive
f = archive File name 
x = extract files

Watching Log Files Using tail and less

Watch the error log and filter the output to the screen (using grep).

tail -f /var/log/apache/error.log | grep -v Exception | grep -v 'PHP Notice'

Output the error log to the screen, filter it before doing so (using grep).

less +F /var/log/apache/error.log | grep -v Exception | grep -v 'PHP Notice'

Note:

-v parameter in grep is reverse look up. It mean, all text except 'Exception' and 'PHP Notice'


Forward and Backward Search in less

/ – search for a pattern which will take you to the next occurrence. 
? – search for a pattern which will take you to the previous occurrence. 
n – for next match in backward direction 
N – for previous match in forward direction
Shift F - similar to tail -f

Monday, November 18, 2013

How to Connect to a Server via SSH


ssh -p 800 user@kabalweg.com

where:
kabalweg.com = is the server
user = the user defined in that server
800 = connection port to that server

Thursday, November 14, 2013

How to scp (Secure Copy) File from a Server to Local Machine

The console command below will copy the file from the remote server to the desktop using the same filename.


scp root@remote_server:/var/lib/backup/server_backup.gz ~/Desktop


where: 
root = the user to that server
remote_server = host entry in you ~/.ssh/config file

Recent Post