Basics
- cd: change directories
- ls: list files in current directory
cdSSH with iterm on Mac
- Open iterm
- Enter command “SSH user@IP” (e.g. “SSH [email protected]”
- Might need to also enter -p2200 for KH VPS
- You will be prompted for password, enter and you’ll be logged in.
grep search command
grep -winr “string to search for” ./*
./* = current directory
Or
Navigate to the folder you want to search and use:
grep -rl “search string here” *
This will show the file names
How to compress a file with SSH
From main root run this command
zip -r backupfilename.zip sourcedirectory/
E.g. (from 1 directory back from public_html) zip -r public_htmlbackup9.8.18.zip public_html/
How do I uncompress a file with SSH
If a file ends in .zip (for example, file.zip), type:
unzip file.zip
If a file ends in .tar (e.g., file.tar), type:
tar -xvf file.tar
If a file ends in .gz (for example, file.gz), type:
gzip -d file.gz
If a file ends in .tar.gz (e.g. file.tar.gz), type:
gzip -d file.tar.gz
and then
tar -xvf file.tar
If a file ends in .tgz (e.g. file.tgz), type:
tar -xvzf file.tgz
Change Host File
- type: sudo nano /etc/hosts and then hit return.
- Enter your administrator password and then hit return.
- You’re now in the Nano text editor.
- Use cursor to navigate to bottom of file
- Add your line of code i.e.
- 111.222.33.111 domain.com www.domain.com
Delete files/folders
Folder: rm -rf foldername/
File: rm myFile.txt myFile1.txt myFile2.txt
All files in a folder: rm -rf *
CHMOD – Change File Permissions
Syntax: chmod -R 755 /home/camelbac/public_html/new
Note: this changes all files and folders, which screws things up.
Josh Notes
Backup publichtml only, run from web/(websitename)
Ls – list folders/files in current directory
Cd location – changes current directory